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
Wrap
Text File
|
2012-07-18
|
3KB
|
124 lines
package dss145_05
{
import com.touchmypixel.games.utils.Animation;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.utils.getTimer;
public class OiseauxManager
{
private var _limitLayer:Sprite;
private var _timer:Timer;
private var _fps:Number = 200;
private var _client:AttenteJeu;
private var _timeLast:int;
private var _timeNow:int;
public var speed:Number = 1;
private var _attackTimeLast:Number;
private var _attackInterval:Number;
private var _attackIntervalMinimum:Number = 12000;
private var _attackIntervalMaximum:Number = 13000;
private var _isStarted:Boolean = false;
private var _speedInterval:int = 10;
private var _animFond:Animation;
private var _oiseau01:Animation;
public function OiseauxManager(param1:AttenteJeu)
{
super();
this._client = param1;
this.init();
}
private function init() : void
{
this._timer = new Timer(1);
this._limitLayer = new Sprite();
var _loc1_:int = 0;
this._client.CONTAINER.addChildAt(this._limitLayer,_loc1_ + 1);
}
public function reset() : void
{
}
public function start() : void
{
if(this._isStarted == true)
{
return;
}
this._isStarted = true;
this.reset();
this._timer.addEventListener(TimerEvent.TIMER,this.timerHandler);
this._client.CONTAINER.addEventListener(MouseEvent.MOUSE_DOWN,this.clicHandler);
this._timeLast = this._attackTimeLast = this._timeNow = getTimer();
this._attackInterval = this._attackIntervalMinimum + Math.random() * (this._attackIntervalMaximum - this._attackIntervalMinimum);
this._timer.start();
}
private function clicHandler(param1:MouseEvent) : void
{
this.pause();
}
public function pause() : void
{
if(this._isStarted)
{
this._isStarted = false;
this._timer.stop();
this._timer.removeEventListener(TimerEvent.TIMER,this.timerHandler);
this._client.CONTAINER.stage.frameRate = 0;
}
else
{
this._isStarted = true;
this._timer.addEventListener(TimerEvent.TIMER,this.timerHandler);
this._timer.start();
this._client.CONTAINER.stage.frameRate = 12;
}
}
public function stop() : void
{
if(this._isStarted == false)
{
return;
}
this._isStarted = false;
this._timer.stop();
this._timer.removeEventListener(TimerEvent.TIMER,this.timerHandler);
}
private function timerHandler(param1:TimerEvent) : void
{
this._timeNow = getTimer();
if(this._timeNow - this._timeLast > this._speedInterval)
{
this._timeLast = this._timeNow;
this._client.ANIM_OISEAUX_FOND.rotation += 2;
param1.updateAfterEvent();
}
}
}
}