Variable and Function Definitions in Frame Scripts : MovieClip « Development « Flash / Flex / ActionScript






Variable and Function Definitions in Frame Scripts

 
package {
  import flash.display.MovieClip;
  import flash.utils.Timer;
  import flash.events.TimerEvent;

  public class Main extends MovieClip {
    private var timer:Timer;

    public function Main() {
      timer = new Timer(100, 0);
      timer.addEventListener(TimerEvent.TIMER, timerListener);
      timer.start(  );
    }

    private function timerListener (e:TimerEvent):void {
      randomFade(  );
    }

    private function randomFade (  ):void {
      alpha = Math.random(  );
    }

    public function dispose (  ):void {
      timer.stop(  );
    }
  }
}

        








Related examples in the same category

1.extends MovieClip
2.Add frame event listener to MovieClip
3.Change MovieClip position
4.Working with the MovieClip: Using stop() and gotoAndPlay()