Ready for some animation? It’s quite easy: just listen for the ENTER_FRAME event sent by the “stage” (the object representing the canvas on which all graphics are drawn) as follows:
package { import flash.display.Sprite; import flash.events.Event; import flash.display.Stage; public class HelloWorld extends Sprite { private var size:int = 40; public function HelloWorld( ) { stage.addEventListener( Event.ENTER_FRAME, onRender ); } private function onRender( event:Event ):void { graphics.beginFill( 0xFFCC00 ); graphics.drawCircle( 40, 40, size ); size += 10; } } }
Check out the Stage documentation for how to set the framerate and such.