Responding to Event.ACTIVATE and Event.DEACTIVATE : Event : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Event »

 

Responding to Event.ACTIVATE and Event.DEACTIVATE


 
package {
  import flash.display.*;
  import flash.utils.*;
  import flash.events.*;

  public class Main extends Sprite {
    private var timer:Timer;
    private var rect:Sprite;

    public function Main() {
      rect = new Sprite(  );
      rect.x = 200;
      rect.y = 200;
      rect.graphics.lineStyle(1);
      rect.graphics.beginFill(0x0000FF);
      rect.graphics.drawRect(0015075);
      addChild(rect);

      addEventListener(Event.ACTIVATE, activateListener);
      addEventListener(Event.DEACTIVATE, deactivateListener);

      timer = new Timer(500);
      timer.addEventListener(TimerEvent.TIMER, timerListener);
    }

    private function timerListener (e:TimerEvent):void {
      rect.rotation += 10;
    }

    private function activateListener (e:Event):void {
      timer.start(  );
    }

    private function deactivateListener (e:Event):void {
      timer.stop(  );
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» Event