home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 155
/
MOBICLIC155.ISO
/
mac
/
DATA
/
DSS155
/
DSS155_01
/
MOD149_00.swf
/
scripts
/
mod149_00
/
MainAlgo.as
Wrap
Text File
|
2013-07-08
|
14KB
|
346 lines
package mod149_00
{
import com.milanpresse.engine.medias.MediaImage;
import com.milanpresse.engine.medias.MediaTexte;
import com.milanpresse.engineaddons.facades.GameEngine;
import com.milanpresse.engineaddons.gamesprotos.Actor;
import com.milanpresse.engineaddons.gamesprotos.actors.actorClip.ActorClip;
import com.milanpresse.engineaddons.gamesprotos.actors.actorClip.IActorClip;
import com.milanpresse.tools.GlobalesFunctions;
import flash.display.MovieClip;
public dynamic class MainAlgo
{
private var _e:GameEngine;
public var mainTimeline:IActorClip;
public var interfaceGroup:Actor;
public function MainAlgo(game:GameEngine)
{
super();
this._e = game;
this._e.levelCZ = this._e.config.layers.content;
this.mainTimeline = this._e.addActor({
"code":"A_" + this._e.config.moduleName,
"parent":this._e.config.layers.content
});
this.mainTimeline.onLabelEnter = this.onEachLabel;
this.mainTimeline.onLabelExit = this.onLabelExit;
}
public function start() : void
{
this.mainTimeline.gotoAndPlay(this.mainTimeline.currentLabels[0].name);
}
public function onEachLabel(result:Object = null) : void
{
trace("onEachLabel",this.mainTimeline.currentLabel);
this.interfaceGroup = this._e.addActor(new Actor(this._e));
this.interfaceGroup.name = "interfaceGroupe";
switch(this.mainTimeline.currentLabel)
{
case "_E_0" + this._e.memo.etapeEnCours + "_01":
this._E_XX_01();
break;
case "_E_0" + this._e.memo.etapeEnCours + "_FIN":
this._e.memo.quizListAlea = GlobalesFunctions.randomArray([1,2,3,4]);
this.quizInit();
break;
case "ATTENTE_0" + this._e.memo.etapeEnCours:
case "_E_0" + this._e.memo.etapeEnCours + "_SUCCES":
case "_E_0" + this._e.memo.etapeEnCours + "_ECHEC":
this.quizInit();
}
this.setPhotoIfExists();
this.interfaceShow();
}
public function onLabelExit(result:Object = null) : void
{
trace("onLabelExit",result.label);
if(this.interfaceGroup != null)
{
this.interfaceGroup.foreach(function(actor:Actor):void
{
(actor as ActorClip).restore();
(actor as ActorClip).dissociate();
});
this.interfaceGroup.destroy();
}
}
public function interfaceShow() : void
{
var clip:IActorClip = null;
if(this.mainTimeline.getChildByName("PERSO") != null)
{
clip = this.interfaceGroup.addActor({"mc":this.mainTimeline.getChildByName("PERSO") as MovieClip});
clip.initAs();
clip.enabled = false;
}
if(this.mainTimeline.getChildByName("BT_FERMER_CONT.BT_FERMER") != null)
{
clip = this.interfaceGroup.addActor({
"mc":this.mainTimeline.getChildByName("BT_FERMER_CONT.BT_FERMER") as MovieClip,
"onRollOverState":{"noiseCode":"B_FERME"}
});
clip.parent = this._e.config.layers.menu;
clip.x = this.mainTimeline.getChildByName("BT_FERMER_CONT").x;
clip.y = this.mainTimeline.getChildByName("BT_FERMER_CONT").y;
clip.initAs();
clip.onClick = function(actor:ActorClip):void
{
trace("click",actor,this);
_e.engine.stopComment();
mainTimeline.gotoAndStop("ATTENTE");
};
clip.enabled = true;
clip.visible = true;
}
for(var i:int = 1; i <= 3; i++)
{
if(this.mainTimeline.getChildByName("EXP_0" + i) != null)
{
clip = this.interfaceGroup.addActor({
"mc":this.mainTimeline.getChildByName("EXP_0" + i) as MovieClip,
"onRollOverState":{
"ibId":"IB_E_0" + i,
"ibRef":{"position":12},
"noiseCode":"B0" + i
}
});
clip["no"] = i;
clip.initAs();
clip.onClick = function(actor:ActorClip):void
{
trace("click",actor,this);
_e.memo.etapeEnCours = actor["no"];
mainTimeline.gotoAndPlay("_E_0" + _e.memo.etapeEnCours + "_01",{"labelLastCallback":function():void
{
(interfaceGroup.getActor("PERSO") as ActorClip).gotoAndStop("E2");
}});
};
clip.enabled = true;
}
if(this.mainTimeline.getChildByName("BT_DEC_0" + i) != null)
{
clip = this.interfaceGroup.addActor({
"mc":this.mainTimeline.getChildByName("BT_DEC_0" + i) as MovieClip,
"no":i,
"onRollOverState":{
"ibId":"IB0" + i,
"ibRef":{"position":6},
"noiseCode":"B_DEC"
}
});
clip["no"] = i;
clip.initAs();
clip.onClick = function(actor:ActorClip):void
{
trace("click",actor,this);
_e.memo.etapeEnCours = actor["no"];
mainTimeline.gotoAndPlay("_0" + _e.memo.etapeEnCours + "_01",{
"labelLast":"_0" + _e.memo.etapeEnCours + "_FIN",
"labelLastCallback":function():void
{
mainTimeline.gotoAndStop("ATTENTE");
}
});
};
if(this._e.memo["vu" + i] != true)
{
clip.visible = false;
}
else
{
clip.visible = true;
}
if(this.mainTimeline.currentLabel != "ATTENTE")
{
if(i == this._e.memo.etapeEnCours)
{
clip.gotoAndStop("E3");
}
else
{
clip.gotoAndStop("E1");
}
clip.enabled = false;
}
else
{
clip.enabled = true;
}
}
}
}
public function _E_XX_01() : void
{
var texteMedia:MediaTexte = this._e.getMediaText({"id":"LM0" + this._e.memo.etapeEnCours});
var target:MovieClip = this.mainTimeline.getChildByName("LMXX") as MovieClip;
if(target != null && texteMedia != null)
{
this._e.showTextBloc({
"text":texteMedia.text.split("§").join("\n"),
"target":target.TEXTE,
"idStyle":"LM.LM_MATERIEL"
});
target.TEXTE.border = false;
}
}
public function quizInit() : void
{
var texteMedia:MediaTexte = null;
var target:MovieClip = null;
var zone:ActorClip = null;
for(var j:int = 1; j <= 4; j++)
{
texteMedia = this._e.getMediaText({"id":"LM_E_0" + this._e.memo.etapeEnCours + "_0" + this._e.memo.quizListAlea[j - 1]});
target = this.mainTimeline.getChildByName("QUIZ_LMS.LM_E_XX_0" + j) as MovieClip;
if(target != null && texteMedia != null)
{
this._e.showTextBloc({
"text":texteMedia.text,
"target":target.TEXTE,
"idStyle":"LM.LM_REPONSE"
});
target.TEXTE.border = false;
}
zone = this.interfaceGroup.addActor({"mc":target});
zone.initAs();
zone.noReponse = this._e.memo.quizListAlea[j - 1];
zone.onClick = function(actor:ActorClip):void
{
trace("click",actor,this);
if(actor.noReponse == 1)
{
_e.memo["vu" + _e.memo.etapeEnCours] = true;
mainTimeline.gotoAndPlay("_E_0" + _e.memo.etapeEnCours + "_SUCCES",{"labelLastCallback":function():void
{
mainTimeline.gotoAndStop("ATTENTE");
}});
}
else
{
mainTimeline.gotoAndPlay("_E_0" + _e.memo.etapeEnCours + "_ECHEC",{"labelLastCallback":function():void
{
mainTimeline.gotoAndStop("ATTENTE_0" + _e.memo.etapeEnCours);
}});
}
};
if(this.mainTimeline.currentLabel == "_E_0" + this._e.memo.etapeEnCours + "_SUCCES")
{
zone.enabled = false;
if(zone.noReponse == 1)
{
zone.gotoAndStop("E2");
}
}
else if(this.mainTimeline.currentLabel == "ATTENTE_0" + this._e.memo.etapeEnCours)
{
zone.enabled = true;
zone.gotoAndStop("E1");
}
else
{
zone.enabled = false;
zone.gotoAndStop("E1");
}
}
}
public function setPhotoIfExists() : void
{
var noSousEtape:int = 0;
var photoLast:MediaImage = null;
var zone:ActorClip = null;
var photoCode:String = this.mainTimeline.currentLabel.search(/^_E/) != -1 ? this.mainTimeline.currentLabel.replace("_E","PH") : this.mainTimeline.currentLabel.replace("_","PH_");
noSousEtape = int(this.mainTimeline.currentLabel.split("_")[3]);
if(this._e.getMediaImage(photoCode) != null && this.mainTimeline.getChildByName("PHOTO") != null)
{
trace("photo",photoCode);
photoLast = this._e.showImage({
"code":photoCode,
"parent":this.mainTimeline.getChildByName("PHOTO")
});
if(this.mainTimeline.getChildByName("FLECHES_CONT.BT_REC") != null)
{
zone = this.interfaceGroup.addActor({
"mc":this.mainTimeline.getChildByName("FLECHES_CONT.BT_REC") as MovieClip,
"onRollOverState":{"noiseCode":"B_REC"}
});
zone.initAs();
zone.parent = this._e.config.layers.menu;
zone.x += this.mainTimeline.getChildByName("FLECHES_CONT").x;
zone.y += this.mainTimeline.getChildByName("FLECHES_CONT").y;
zone.onClick = function(actor:ActorClip):void
{
trace("click",actor,this);
mainTimeline.gotoAndPlay("_E_0" + _e.memo.etapeEnCours + "_0" + int(noSousEtape - 1),{"labelLastCallback":function():void
{
(interfaceGroup.getActor("PERSO") as ActorClip).gotoAndStop("E2");
}});
};
if(this.mainTimeline.hasLabel("_E_0" + this._e.memo.etapeEnCours + "_0" + int(noSousEtape - 1)))
{
zone.enabled = true;
}
else
{
zone.enabled = false;
zone.gotoAndStop("E0");
}
zone = this.interfaceGroup.addActor({
"mc":this.mainTimeline.getChildByName("FLECHES_CONT.BT_AV"),
"onRollOverState":{"noiseCode":"B_AV"}
});
zone.initAs();
zone.onClick = function(actor:ActorClip):void
{
trace("click",actor,this);
if(mainTimeline.hasLabel("_E_0" + _e.memo.etapeEnCours + "_0" + int(noSousEtape + 1)))
{
zone.nextLabel = "_E_0" + _e.memo.etapeEnCours + "_0" + int(noSousEtape + 1);
mainTimeline.gotoAndPlay(actor.nextLabel,{"labelLastCallback":function():void
{
(interfaceGroup.getActor("PERSO") as ActorClip).gotoAndStop("E2");
}});
}
else
{
zone.nextLabel = "_E_0" + _e.memo.etapeEnCours + "_FIN";
mainTimeline.gotoAndPlay(actor.nextLabel);
}
};
zone.parent = this._e.config.layers.menu;
zone.x += this.mainTimeline.getChildByName("FLECHES_CONT").x;
zone.y += this.mainTimeline.getChildByName("FLECHES_CONT").y;
zone.enabled = true;
}
}
}
public function sleep() : void
{
this._e.sleep();
}
public function wake() : void
{
this._e.wake();
}
public function destroy() : void
{
this._e.destroy();
}
}
}