Add frame event listener to MovieClip : MovieClip « Development « Flash / Flex / ActionScript






Add frame event listener to MovieClip

 
package {
     
     import flash.display.MovieClip;
     import flash.events.Event;
     
     public class Motion extends MovieClip {
          
          public function Motion() {
               trace("Motion class instantiated");
               addEventListener(Event.ENTER_FRAME, update);
          }
          private function updatePosition():void {
               this.x++;
               this.y++;
          }
          private function update(evtObj:Event):void {
               this.updatePosition();
          }
          
     }
}

        








Related examples in the same category

1.extends MovieClip
2.Change MovieClip position
3.Variable and Function Definitions in Frame Scripts
4.Working with the MovieClip: Using stop() and gotoAndPlay()