home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 148
/
MOBICLIC148.ISO
/
mac
/
DATA
/
DSS148
/
DSS148_01
/
DSS148_01.swf
/
scripts
/
dss148
/
Relance.as
< prev
Wrap
Text File
|
2012-10-16
|
2KB
|
78 lines
package dss148
{
import flash.events.TimerEvent;
import flash.utils.Timer;
public class Relance
{
private var timer:Timer;
public var method:Function = null;
public var isSleeping:Boolean = false;
public function Relance(param1:Number = 0, param2:Function = null)
{
super();
this.method = param2;
this.timer = new Timer(param1,1);
}
public function set delai(param1:Number) : void
{
this.timer.delay = param1;
}
public function start() : void
{
this.timer.addEventListener(TimerEvent.TIMER_COMPLETE,this.timerHandler);
this.timer.reset();
this.timer.start();
}
public function stop() : void
{
this.timer.removeEventListener(TimerEvent.TIMER_COMPLETE,this.timerHandler);
this.timer.stop();
}
private function timerHandler(param1:TimerEvent) : void
{
this.stop();
this.method(this.methodCallback);
}
public function methodCallback() : void
{
this.start();
}
public function sleep() : void
{
if(this.timer.running)
{
this.timer.stop();
this.isSleeping = true;
}
}
public function wake() : void
{
if(this.isSleeping)
{
this.timer.start();
this.isSleeping = false;
}
}
public function destroy() : void
{
this.stop();
this.timer = null;
this.method = null;
}
}
}