Drawing triangles in FP10


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // set the vertices as points
  2. var point1:Point = new Point(0, 0);
  3. var point2:Point = new Point(100, 0);
  4. var point3:Point = new Point(0, 100);
  5.  
  6. // translate it into actual verticies
  7. var vertices:Vector.<Number> = Vector.<Number>([point1.x, point1.y, point2.x, point2.y, point3.x, point3.y]);
  8.  
  9. // make a new display object - where the triangle will be drawn
  10. var triangle:Sprite = new Sprite();
  11.  
  12. // draw
  13. triangle.graphics.beginFill(0x00ff00, 1);
  14. triangle.graphics.drawTriangles(vertices);
  15. triangle.graphics.endFill();
  16.  
  17. // add it to the display list
  18. addChild(triangle);

URL: http://www.izaias.com/tutorials/flash/drawing_triangle_fp10_example.zip

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.