home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 150
/
MOBICLIC150.ISO
/
pc
/
DATA
/
DSS150
/
DSS150_01
/
DSS150_01.swf
/
scripts
/
dss150_01
/
ATTENTE.as
next >
Wrap
Text File
|
2012-12-19
|
5KB
|
188 lines
package dss150_01
{
import com.milanpresse.engineaddons.facades.GameEngine;
import com.milanpresse.engineaddons.gamesprotos.Actor;
import com.milanpresse.engineaddons.gamesprotos.actors.actorClip.IActorClip;
import com.milanpresse.engineaddons.timers.TimerChild;
import flash.display.MovieClip;
import flash.ui.Mouse;
public class ATTENTE
{
private var game:GameEngine;
public var onEvent:Function = null;
private var _container:IActorClip;
private var attente:Actor;
private var timerIsOn:TimerChild;
private var timerRelance:TimerChild;
private var torche:IActorClip;
private var faisceau:IActorClip;
private var morceau:IActorClip;
private var _mouseVisible:Boolean = true;
protected var isSleeping:Boolean = false;
protected var sleepState:Object;
public function ATTENTE(game:GameEngine, container:IActorClip)
{
var clip:IActorClip = null;
this.sleepState = {"mouseVisible":true};
super();
this.game = game;
this._container = container;
this.attente = game.addActor(new Actor(game));
this.attente.name = "ATTENTE";
this.torche = this.attente.addActor({"mc":this._container.getChildByName("DECOR.LUZ") as MovieClip});
clip = this.attente.addActor({"mc":this._container.getChildByName("DECOR.CERCLE") as MovieClip});
clip.initAs();
clip.dragEnabled = true;
clip.enabled = false;
this.morceau = this.attente.addActor({"mc":this._container.getChildByName("ZONE") as MovieClip});
clip.dragDrop.dropTargets = [this.morceau];
clip.onDrag = this.onDrag;
this.faisceau = clip;
this.faisceau.limitZone = {
"x":0,
"y":0,
"width":game.stage.stageWidth,
"height":game.stage.stageHeight
};
this.timerRelance = game.mainTimer.addFromObj({
"id":"timerRelance",
"delay":game.moduleConfig.relanceDelayMS,
"loop":1,
"onDelay":function(tc:TimerChild):void
{
game.commentPlay({
"code":"JEU_AIDE",
"callback":function():void
{
timerRelance.reset();
timerRelance.start();
}
});
}
});
this.timerIsOn = game.mainTimer.addFromObj({
"id":"timerIsOn",
"delay":game.moduleConfig.TrouveDelayMS,
"loop":1,
"onDelay":function(tc:TimerChild):void
{
finish();
}
});
this.mouseVisible = false;
game.mainTimer.start();
this.faisceau.dragStart();
}
public function get mouseVisible() : Boolean
{
return this._mouseVisible;
}
public function set mouseVisible(value:Boolean) : void
{
if(value == true)
{
Mouse.show();
}
else
{
Mouse.hide();
}
this._mouseVisible = value;
}
private function onDrag(actor:IActorClip) : void
{
if(this.isSleeping)
{
return;
}
this.faisceau.setToPos(this.game.stage.mouseX,this.game.stage.mouseY);
this.torche.x = this.faisceau.x;
this.torche.y = this.faisceau.y;
if(actor.dragDrop.dropTarget != null)
{
if(this.timerIsOn.running == false)
{
this.timerIsOn.reset();
this.timerIsOn.start();
}
}
else
{
this.timerIsOn.stop();
}
}
protected function stop() : void
{
if(this.attente != null)
{
this.faisceau.dragStop();
this.game.commentStop();
this.timerRelance.stop();
this.timerIsOn.stop();
this.mouseVisible = true;
}
}
private function finish() : void
{
trace("finish");
this.destroy();
if(this.onEvent != null)
{
this.onEvent({"action":"succes"});
}
}
public function sleep() : void
{
if(this.isSleeping)
{
return;
}
this.isSleeping = true;
this.sleepState.mouseVisible = this._mouseVisible;
this.mouseVisible = true;
}
public function wake() : void
{
if(this.isSleeping == false)
{
return;
}
this.isSleeping = false;
this.mouseVisible = this.sleepState.mouseVisible;
}
public function destroy() : void
{
this.stop();
if(this.attente != null)
{
this.attente.dissociate();
this.attente.destroy();
}
this.attente = null;
}
}
}