The following example shows how you can draw shapes in ActionScript 3.0 and ActionScript 2.0 using the drawRect() method (ActionScript 3.0) and the moveTo() and lineTo() methods (ActionScript 2.0).
Full code after the jump.
// ActionScript 3.0 var movieClip:MovieClip = new MovieClip(); movieClip.graphics.beginFill(0xFF0000); movieClip.graphics.drawRect(0, 0, 100, 80); movieClip.graphics.endFill(); movieClip.x = 10; movieClip.y = 10; addChild(movieClip);
To draw the same rectangle in ActionScript 2.0, you would call the graphic functions directly on the MovieClip instance rather than the Graphic object, as seen in the following example:
// ActionScript 2.0 createEmptyMovieClip("movieClip", 0); movieClip.beginFill(0xFF0000); movieClip.moveTo(0, 0); movieClip.lineTo(100, 0); movieClip.lineTo(100, 80); movieClip.lineTo(0, 80); movieClip.endFill(); movieClip._x = 10; movieClip._y = 10;
{ 1 comment… read it below or add one }
Thanks !! im still a noobie when it comes to creating stuff using pure actionscript in flash, this really helped ^^