home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 145 / MOBICLIC145.ISO / pc / DATA / DSS145 / DSS145_05 / DSS145_05.swf / scripts / dss145_05 / OiseauxManager.as < prev   
Text File  |  2012-07-18  |  3KB  |  124 lines

  1. package dss145_05
  2. {
  3.    import com.touchmypixel.games.utils.Animation;
  4.    import flash.display.Sprite;
  5.    import flash.events.MouseEvent;
  6.    import flash.events.TimerEvent;
  7.    import flash.utils.Timer;
  8.    import flash.utils.getTimer;
  9.    
  10.    public class OiseauxManager
  11.    {
  12.        
  13.       
  14.       private var _limitLayer:Sprite;
  15.       
  16.       private var _timer:Timer;
  17.       
  18.       private var _fps:Number = 200;
  19.       
  20.       private var _client:AttenteJeu;
  21.       
  22.       private var _timeLast:int;
  23.       
  24.       private var _timeNow:int;
  25.       
  26.       public var speed:Number = 1;
  27.       
  28.       private var _attackTimeLast:Number;
  29.       
  30.       private var _attackInterval:Number;
  31.       
  32.       private var _attackIntervalMinimum:Number = 12000;
  33.       
  34.       private var _attackIntervalMaximum:Number = 13000;
  35.       
  36.       private var _isStarted:Boolean = false;
  37.       
  38.       private var _speedInterval:int = 10;
  39.       
  40.       private var _animFond:Animation;
  41.       
  42.       private var _oiseau01:Animation;
  43.       
  44.       public function OiseauxManager(param1:AttenteJeu)
  45.       {
  46.          super();
  47.          this._client = param1;
  48.          this.init();
  49.       }
  50.       
  51.       private function init() : void
  52.       {
  53.          this._timer = new Timer(1);
  54.          this._limitLayer = new Sprite();
  55.          var _loc1_:int = 0;
  56.          this._client.CONTAINER.addChildAt(this._limitLayer,_loc1_ + 1);
  57.       }
  58.       
  59.       public function reset() : void
  60.       {
  61.       }
  62.       
  63.       public function start() : void
  64.       {
  65.          if(this._isStarted == true)
  66.          {
  67.             return;
  68.          }
  69.          this._isStarted = true;
  70.          this.reset();
  71.          this._timer.addEventListener(TimerEvent.TIMER,this.timerHandler);
  72.          this._client.CONTAINER.addEventListener(MouseEvent.MOUSE_DOWN,this.clicHandler);
  73.          this._timeLast = this._attackTimeLast = this._timeNow = getTimer();
  74.          this._attackInterval = this._attackIntervalMinimum + Math.random() * (this._attackIntervalMaximum - this._attackIntervalMinimum);
  75.          this._timer.start();
  76.       }
  77.       
  78.       private function clicHandler(param1:MouseEvent) : void
  79.       {
  80.          this.pause();
  81.       }
  82.       
  83.       public function pause() : void
  84.       {
  85.          if(this._isStarted)
  86.          {
  87.             this._isStarted = false;
  88.             this._timer.stop();
  89.             this._timer.removeEventListener(TimerEvent.TIMER,this.timerHandler);
  90.             this._client.CONTAINER.stage.frameRate = 0;
  91.          }
  92.          else
  93.          {
  94.             this._isStarted = true;
  95.             this._timer.addEventListener(TimerEvent.TIMER,this.timerHandler);
  96.             this._timer.start();
  97.             this._client.CONTAINER.stage.frameRate = 12;
  98.          }
  99.       }
  100.       
  101.       public function stop() : void
  102.       {
  103.          if(this._isStarted == false)
  104.          {
  105.             return;
  106.          }
  107.          this._isStarted = false;
  108.          this._timer.stop();
  109.          this._timer.removeEventListener(TimerEvent.TIMER,this.timerHandler);
  110.       }
  111.       
  112.       private function timerHandler(param1:TimerEvent) : void
  113.       {
  114.          this._timeNow = getTimer();
  115.          if(this._timeNow - this._timeLast > this._speedInterval)
  116.          {
  117.             this._timeLast = this._timeNow;
  118.             this._client.ANIM_OISEAUX_FOND.rotation += 2;
  119.             param1.updateAfterEvent();
  120.          }
  121.       }
  122.    }
  123. }
  124.