Drawing line in flash- via Action script
I need to draw a line in ActionScript(based on calculated conditions for length and rotation)
I tried the following code- the triangle with the fill appears- but not the line with the lineStyle- Could you pls help me开发者_StackOverflow社区 out on this... c is defined as UIComponent
var myShape:Shape=new Shape();
myShape.graphics.moveTo(100,100);
myShape.graphics.lineTo(200,200);
myShape.graphics.lineStyle(2,0xFF0000,.75);
c.addChild(myShape);
var triangleHeight:uint = 100;
var triangle:Shape = new Shape();
// red triangle
triangle.graphics.beginFill(0xFF0000);
triangle.graphics.moveTo(triangleHeight/2, 200);
triangle.graphics.lineTo(triangleHeight, triangleHeight);
triangle.graphics.lineTo(0, triangleHeight);
triangle.graphics.lineTo(triangleHeight/2, 200);
c.addChild(triangle);
You should declare line style before your drawing.
精彩评论