home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 145
/
MOBICLIC145.ISO
/
pc
/
DATA
/
DSS145
/
DSS145_02
/
DSS145_02.swf
/
scripts
/
dss145_02
/
CapsuleAlgo.as
< prev
Wrap
Text File
|
2012-07-18
|
24KB
|
641 lines
package dss145_02
{
import com.milanpresse.engine.Engine;
import com.milanpresse.engine.initmovieclip.InteractiveMovie;
import com.milanpresse.engine.managers.PauseManager;
import com.milanpresse.engine.managers.TimelineManager;
import com.milanpresse.engine.medias.MediaSwf;
import com.milanpresse.engine.timelines.Timeline;
import com.milanpresse.engine.timelines.TimelineLinear;
import com.milanpresse.engine.timers.ExtendedTimer;
import com.milanpresse.engine.typeargument.CommentObject;
import com.milanpresse.engine.typeargument.NoiseObject;
import com.milanpresse.tools.GlobalesFunctions;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.geom.Point;
import flash.net.SharedObject;
import flash.ui.Mouse;
public class CapsuleAlgo
{
private var menu:MediaSwf;
private var menuTimeline:MovieClip;
private var menuTL:Timeline;
private var mainClip:MediaSwf;
private var mainTimeline:MovieClip;
private var _engine:Engine;
private var labelList:Array;
private var _timeline_:TimelineLinear;
private var _timelineManager:TimelineManager;
private var _pauseManager:PauseManager;
private var _pauseManager_:PauseManager;
private var _pausedAIDE:Boolean = false;
private var labelsCallback:Object;
private var firstLabel:String;
private var so:SharedObject;
private var gListDone:Array;
private var gListeObjet:Array;
private var gListeCibles:Array;
private var gListeCurrentCibles:Array;
private var gDoneDepart:Boolean;
private var BT_RETOUR:BtRetour;
private var CURSEUR_TORCHE:MovieClip;
private var PANO_AIDE:MovieClip;
private var BT_AIDE:InteractiveMovie;
private var BT_REJOUER:InteractiveMovie;
private var HERAKLES:InteractiveMovie;
private var gListeDone:Array;
private var gListeTete:Array;
private var timeGame:Number;
private var timeTotal:Number;
private var timeAttaque:int;
private var timer_JEU:ExtendedTimer;
private var timer_TOTAL:ExtendedTimer;
private var timer_HERAKLES:ExtendedTimer;
private var TIMER:InteractiveMovie;
private var gCountTete:int;
private var gCountSec:int;
private var gCountSecCouTete:int;
private var HYDREteteActive:InteractiveMovie;
private var HYDREdemo:InteractiveMovie;
private var jeuPerdu:Boolean = false;
private var _startTime:Number;
private var _startTimeJEU:Number;
public function CapsuleAlgo(engine:Engine)
{
this.labelsCallback = {
"_07":this.label_07,
"_08":"prioAnim",
"PERDU":this.labelPERDU
};
super();
this._engine = engine;
this._engine.playMusic({"code":"MU"});
this._engine.setSubtitles(this._engine.host.subtitlesOn);
this._engine.setFrameRate(12);
this.mainClip = this._engine.showSwf({
"code":"A_" + this._engine.config.moduleName,
"parent":this._engine.config.layers["content"]
});
this.mainTimeline = this.mainClip.swfContent;
this._timelineManager = new TimelineManager();
this._timeline_ = new TimelineLinear(this.mainTimeline,this._engine,this,this._timelineManager,this.labelsCallback);
this._engine.levelCZ = this._engine.config.layers["content"];
this.firstLabel = this.mainTimeline.currentLabels[0].name;
this._timeline_.GotoAndPlayUntil({"labelStop":this.firstLabel});
this.so = SharedObject.getLocal(this._engine.config.rubriqueName,"/");
this.gListDone = this.so.data.listDone;
this.gDoneDepart = this.gListDone[this._engine.config.moduleNum - 1] == 1;
this.BT_RETOUR = new BtRetour(this._engine,this._timelineManager,this.so);
this.BT_RETOUR.setFunctionHideCursorSpecial(this.hideCursorSpecial);
this.BT_RETOUR.setFunctionShowCursorSpecial(this.showCursorSpecial);
this.BT_RETOUR.setFunctionFin(this.endMODULE);
this.timeTotal = Number(this._engine.config.XmlConfig.Module.Config.timeTotal.toString());
this.timeAttaque = Number(this._engine.config.XmlConfig.Module.Config.frequenceAttaque.toString());
this.timeGame = Number(this._engine.config.XmlConfig.Module.Config.dureeCou.toString());
this.timer_TOTAL = new ExtendedTimer(1000,this.timeTotal);
this.timer_TOTAL.addEventListener(TimerEvent.TIMER,this.refreshTimer);
this.timer_TOTAL.addEventListener(TimerEvent.TIMER_COMPLETE,this.finTimerJeu);
this.timer_HERAKLES = new ExtendedTimer(this.timeAttaque * 1000);
this.timer_HERAKLES.addEventListener(TimerEvent.TIMER,this.heraklesAction);
this.timer_JEU = new ExtendedTimer(1000,this.timeGame);
this.timer_JEU.addEventListener(TimerEvent.TIMER,this.refreshCouTete);
this.timer_JEU.addEventListener(TimerEvent.TIMER_COMPLETE,this.finSequenceJeu);
}
private function enterFrame(evt:Event) : void
{
var tpoint:Point = new Point(this.CURSEUR_TORCHE.parent.mouseX,this.CURSEUR_TORCHE.parent.mouseY);
this.CURSEUR_TORCHE.x = tpoint.x;
this.CURSEUR_TORCHE.y = tpoint.y;
}
public function label_01() : void
{
var myMc:InteractiveMovie = null;
for(var i:int = 1; i <= 8; i++)
{
myMc = new InteractiveMovie(this.mainTimeline["HYDRE_" + this.G2D(i)],this._timelineManager);
myMc.gotoAndStop("E1");
}
}
public function label_06() : void
{
if(this.HYDREdemo !== null)
{
this.HYDREdemo.gotoAndStop("E3");
}
}
public function label_07() : void
{
var tl:Timeline = null;
var mc:MovieClip = this.mainTimeline["anim"];
this._engine.playComment(new CommentObject({
"code":"07",
"zapBlock":"NOZAP_NOBLOCK",
"callback":this._timeline_.nextLabel
}));
if(mc !== null)
{
tl = new Timeline(mc,this._timelineManager);
tl.GotoAndPlayUntil({
"labelPlay":1,
"labelStop":mc.totalFrames
});
}
}
public function coupeTete() : void
{
this.HERAKLES.gotoAndStop("E1");
this.HYDREdemo = new InteractiveMovie(this.mainTimeline["HYDRE_03"],this._timelineManager);
this.HYDREdemo.gotoAndStop("E2");
}
public function stopAutresTetes() : void
{
var myMc:MovieClip = this.mainTimeline["HYDRE"];
myMc.mouseEnabled = false;
var pLength:int = this.gListeTete.length;
for(var i:int = 1; i < pLength; i++)
{
myMc = this.mainTimeline["HYDRE_0" + this.gListeTete[i]];
myMc.mouseEnabled = false;
myMc.mouseChildren = false;
if(myMc.kill is Function)
{
myMc.kill();
}
}
}
public function coupeTeteAleatoire() : void
{
trace("coupeTeteAleatoire","HYDRE_0" + this.gListeTete[0]);
this.HERAKLES.gotoAndStop("E1");
this.HYDREteteActive = new InteractiveMovie(this.mainTimeline["HYDRE_0" + this.gListeTete[0]],this._timelineManager);
this.HYDREteteActive.mc.mouseEnabled = true;
this.HYDREteteActive.mc.mouseChildren = true;
this.HYDREteteActive.gotoAndStop("E2");
this.stopAutresTetes();
this._engine.playNoise(new NoiseObject({"code":"B_COU_COUIC"}));
this.gCountSecCouTete = 0;
this.timer_JEU.reset();
this.timer_JEU.start();
this._startTime = new Date().time;
this.initJEU();
}
public function showCursorSpecial(lFirst:int = 0) : void
{
if(lFirst == 1)
{
this.CURSEUR_TORCHE = this.mainTimeline.CURSEUR_TORCHE;
}
trace("SHOW CURSEUR_TORCHE",this.CURSEUR_TORCHE);
if(this.CURSEUR_TORCHE !== null)
{
if(this.BT_RETOUR._gameOn == true || lFirst == 1)
{
Mouse.hide();
this.CURSEUR_TORCHE.visible = true;
if(this.mainTimeline.hasEventListener(Event.ENTER_FRAME) == false)
{
this.CURSEUR_TORCHE.mouseEnabled = false;
this.CURSEUR_TORCHE.mouseChildren = false;
this.enterFrame(new Event(""));
this.mainTimeline.addEventListener(Event.ENTER_FRAME,this.enterFrame);
}
}
}
}
public function leaveStage(evt:Event) : void
{
trace("leaveStage");
this.hideCursorSpecial();
this.mainTimeline.stage.addEventListener(MouseEvent.MOUSE_MOVE,this.enterStage);
}
public function enterStage(evt:MouseEvent) : void
{
trace("enterStage");
this.showCursorSpecial();
this.mainTimeline.stage.removeEventListener(MouseEvent.MOUSE_MOVE,this.enterStage);
}
public function hideCursorSpecial() : void
{
trace("HIDE CURSEUR_TORCHE",this.CURSEUR_TORCHE);
if(this.CURSEUR_TORCHE !== null)
{
if(this.BT_RETOUR._gameOn == true)
{
Mouse.show();
this.CURSEUR_TORCHE = this.mainTimeline.CURSEUR_TORCHE;
this.CURSEUR_TORCHE.visible = false;
}
}
}
public function label_05() : void
{
this.showCursorSpecial(1);
this.mainTimeline.stage.addEventListener(Event.MOUSE_LEAVE,this.leaveStage);
this.HERAKLES = new InteractiveMovie(this.mainTimeline["HERAKLES"],this._timelineManager);
this.HERAKLES.gotoAndPlayUntil({
"labelPlay":"E2",
"beforeLabelStop":"E3",
"callback":this.coupeTete
});
this._engine.playNoise(new NoiseObject({"code":"B_ATTAQUE"}));
}
public function labelATTENTE_JEU() : void
{
trace("labelATTENTE_JEU");
this.HYDREdemo = new InteractiveMovie(this.mainTimeline["HYDRE_03"],this._timelineManager);
this.HYDREdemo.gotoAndStop("E1");
this.PANO_AIDE = this.mainTimeline.PANO_AIDE;
this.PANO_AIDE.visible = false;
this.BT_AIDE = new InteractiveMovie(this.mainTimeline["BT_AIDE"],this._timelineManager);
this.BT_AIDE.gotoAndStop("E1");
this.BT_REJOUER = new InteractiveMovie(this.mainTimeline["BT_REJOUER"],this._timelineManager);
this.BT_REJOUER.gotoAndStop("E1");
this.BT_REJOUER.mc.visible = false;
this.HERAKLES = new InteractiveMovie(this.mainTimeline["HERAKLES"],this._timelineManager);
this.HERAKLES.gotoAndStop("E1");
this.TIMER = new InteractiveMovie(this.mainTimeline["TIMER"],this._timelineManager);
this.TIMER.gotoAndStop(1);
this.TIMER.mc.pDoneSon = false;
this.label_01();
this.gListeDone = [0,0,0,0,0,0,0,0];
this.gListeTete = GlobalesFunctions.randomArrayFromXtoY(1,8);
trace("____________________gListeTete",this.gListeTete);
this.gCountTete = 0;
this.gCountSec = 0;
this.jeuPerdu = false;
this.timer_TOTAL.reset();
this.timer_TOTAL.start();
this._startTimeJEU = new Date().time;
this.heraklesAction(null);
this.initBT_AIDE();
this.BT_RETOUR._gameOn = true;
this.showCursorSpecial();
}
public function initJEU() : void
{
var myMc:InteractiveMovie = new InteractiveMovie(this.HYDREteteActive.mc.COU,this._timelineManager);
myMc.gotoAndPlayUntilTheEnd(1);
myMc = new InteractiveMovie(this.HYDREteteActive.mc.COU.TETE,this._timelineManager);
myMc.mc.useHandCursor = false;
myMc.mc.onRollOver = function(p:Object):void
{
CURSEUR_TORCHE.alpha = 0.5;
};
myMc.mc.onRollOut = function(p:Object):void
{
CURSEUR_TORCHE.alpha = 1;
};
myMc.mc.onPress = function(p:Object):void
{
trace("useTorche",this.parent.parent.name);
_engine.playNoise(new NoiseObject({"code":"B_BRULE"}));
CURSEUR_TORCHE.alpha = 1;
timer_JEU.stop();
HYDREteteActive.gotoAndStop("E4");
gCountTete += 1;
trace("gCountTete",gCountTete);
gListeTete.splice(0,1);
trace("__________________gListeTete",gListeTete);
if(gListeTete.length == 0)
{
trace("gagne");
timer_TOTAL.stop();
timer_HERAKLES.stop();
timer_JEU.stop();
mainTimeline.removeEventListener(Event.ENTER_FRAME,enterFrame);
mainTimeline.stage.removeEventListener(Event.MOUSE_LEAVE,leaveStage);
hideCursorSpecial();
save();
BT_RETOUR._gameOn = false;
_timeline_.GotoAndPlayUntil({"labelStop":"_07"});
}
else
{
timer_HERAKLES.reset();
timer_HERAKLES.start();
}
};
myMc.activeMC();
}
public function finSequenceJeu(evt:TimerEvent) : void
{
trace("timer_JEU.delay",this.timer_JEU.delay);
trace("fin TETE HYDRE",this.HYDREteteActive.mc.name);
var myMc:InteractiveMovie = new InteractiveMovie(this.HYDREteteActive.mc.COU.TETE,this._timelineManager);
myMc.kill();
myMc.mc.mouseEnabled = false;
myMc.mc.mousechildren = false;
this.timer_JEU.stop();
this.HYDREteteActive.gotoAndStop("E3");
this.gListeTete = GlobalesFunctions.randomArray(this.gListeTete);
this.timer_HERAKLES.reset();
this.timer_HERAKLES.start();
}
public function heraklesAction(evt:TimerEvent) : void
{
trace("timer_HERAKLES.delay",this.timer_HERAKLES.delay);
trace("heraklesAction");
this.timer_HERAKLES.stop();
this.HERAKLES.gotoAndPlayUntil({
"labelPlay":"E2",
"beforeLabelStop":"E3",
"callback":this.coupeTeteAleatoire
});
this._engine.playNoise(new NoiseObject({"code":"B_ATTAQUE"}));
}
public function refreshCouTete(evt:TimerEvent) : void
{
var myMc:InteractiveMovie = null;
this.gCountSecCouTete += 1;
var pCent:int = Math.floor(this.gCountSecCouTete / this.timeGame * 100);
trace("pCentCouTete",pCent);
if(pCent <= 100)
{
myMc = new InteractiveMovie(this.HYDREteteActive.mc.COU,this._timelineManager);
myMc.gotoAndStop(Math.floor(pCent));
}
}
public function refreshTimer(evt:TimerEvent) : void
{
this.gCountSec += 1;
var pCent:int = Math.floor(this.gCountSec / this.timeTotal * 100);
trace("pCent",pCent);
if(pCent <= 100)
{
this.TIMER.gotoAndStop(pCent);
if(pCent >= 80 && this.TIMER.mc.pDoneSon == false)
{
this.TIMER.mc.pDoneSon = true;
this._engine.playNoise(new NoiseObject({"code":"B_TIME"}));
}
}
}
public function finTimerJeu(evt:TimerEvent) : void
{
trace("timer_TOTAL.delay",this.timer_TOTAL.delay);
trace("_finTimeJEU",new Date().time - this._startTimeJEU);
this.hideCursorSpecial();
this.mainTimeline.stage.removeEventListener(Event.MOUSE_LEAVE,this.leaveStage);
this.jeuPerdu = true;
this.BT_RETOUR._gameOn = false;
this.timer_TOTAL.stop();
this.timer_HERAKLES.stop();
this.timer_JEU.stop();
this.HYDREteteActive.mc.mouseEnabled = false;
this.HYDREteteActive.mc.mouseChildren = false;
this._engine.playNoise(new NoiseObject({"code":"B_TIME_END"}));
this.mainTimeline.removeEventListener(Event.ENTER_FRAME,this.enterFrame);
this._timeline_.GotoAndPlayUntil({"labelStop":"PERDU"});
}
public function labelPERDU() : void
{
this._engine.playComment(new CommentObject({"code":"PERDU"}));
var myMc:InteractiveMovie = this.BT_REJOUER;
myMc.mc.visible = true;
myMc.mc.pNoiseRoll = "B_REJ";
myMc.mc.onRollOver = function(p:Object):void
{
_engine.playNoise(new NoiseObject({"code":this.pNoiseRoll}));
};
myMc.mc.onRollOut = function(p:Object):void
{
_engine.stopNoise(new NoiseObject({"code":this.pNoiseRoll}));
};
myMc.mc.onPress = function(p:Object):void
{
_engine.stopNoise(new NoiseObject({"code":this.pNoiseRoll}));
_timeline_.GotoAndPlayUntil({"labelStop":"ATTENTE_JEU"});
};
myMc.activeMC();
}
public function initBT_AIDE() : void
{
var myMc:InteractiveMovie = null;
trace("initBT_AIDE");
myMc = this.BT_AIDE;
myMc.mc.pNoiseRoll = "B_AIDE";
myMc.mc.clicked = undefined;
myMc.mc.onRollOver = function(p:Object):void
{
trace("ROLL");
trace("BT_RETOUR._gameOn",BT_RETOUR._gameOn);
hideCursorSpecial();
_engine.playNoise(new NoiseObject({"code":this.pNoiseRoll}));
};
myMc.mc.onRollOut = function(p:Object):void
{
trace("OUT");
if(this.clicked == undefined)
{
showCursorSpecial();
_engine.stopNoise(new NoiseObject({"code":this.pNoiseRoll}));
}
};
myMc.mc.onPress = function(p:Object):void
{
var cz:Sprite = null;
trace("PRESS");
this.clicked = true;
BT_RETOUR._gameOn = false;
_engine.stopNoise(new NoiseObject({"code":this.pNoiseRoll}));
PANO_AIDE.visible = true;
sleepAIDE(false);
if(jeuPerdu == false)
{
_engine.playComment(new CommentObject({"code":"AIDE"}));
cz = GlobalesFunctions.createRectangle({
"color":65280,
"alpha":0
});
cz.addEventListener(MouseEvent.CLICK,function():void
{
trace("clic retour au jeu");
BT_RETOUR._gameOn = true;
wakeAIDE();
_engine.stopComment();
cz.parent.removeChild(cz);
PANO_AIDE.visible = false;
myMc.mc.clicked = undefined;
});
_engine.config.layers["content"].addChild(cz);
cz.useHandCursor = true;
cz.visible = true;
}
else
{
_engine.playComment(new CommentObject({
"code":"AIDE",
"callback":cachePANO_AIDE
}));
}
};
myMc.activeMC();
}
public function cachePANO_AIDE() : void
{
this.PANO_AIDE.visible = false;
this.wakeAIDE();
}
public function G2D(value:int) : String
{
return GlobalesFunctions.gimme2digits(value);
}
public function save() : void
{
this.BT_RETOUR._gameWon = true;
this.gListDone[this._engine.config.moduleNum - 1] = 1;
if(this.gDoneDepart)
{
this.so.data.lastDone = 2;
}
else
{
this.so.data.lastDone = 1;
}
this.so.data.listDone = this.gListDone;
this.so.flush();
}
public function endMODULE() : void
{
trace("fin du module");
this.mainTimeline.stage.removeEventListener(MouseEvent.MOUSE_MOVE,this.enterStage);
this.mainTimeline.stage.removeEventListener(Event.MOUSE_LEAVE,this.leaveStage);
Mouse.show();
this._engine.host.changeModule({"numMod":0});
}
public function sleepAIDE(coupeSon:Boolean = true) : void
{
this._pausedAIDE = true;
this.timer_TOTAL.pause();
this.timer_HERAKLES.pause();
this.timer_JEU.pause();
this.hideCursorSpecial();
this._pauseManager_ = new PauseManager(this._engine,this._timelineManager,coupeSon);
this._pauseManager_.sleepMovie(this.mainTimeline);
}
public function wakeAIDE() : void
{
this._pausedAIDE = false;
this.timer_TOTAL.resume();
this.timer_HERAKLES.resume();
this.timer_JEU.resume();
this.showCursorSpecial();
this._pauseManager_.wakeMovie(this.mainTimeline);
}
public function sleep(coupeSon:Boolean = true) : void
{
if(this._pausedAIDE == false)
{
this.timer_TOTAL.pause();
this.timer_HERAKLES.pause();
this.timer_JEU.pause();
this.hideCursorSpecial();
}
this._pauseManager = new PauseManager(this._engine,this._timelineManager,coupeSon);
this._pauseManager.sleepMovie(this.mainTimeline);
}
public function wake() : void
{
if(this._pausedAIDE == false)
{
this.timer_TOTAL.resume();
this.timer_HERAKLES.resume();
this.timer_JEU.resume();
this.showCursorSpecial();
}
this._pauseManager.wakeMovie(this.mainTimeline);
}
public function destroy() : void
{
this.timer_TOTAL.removeEventListener(TimerEvent.TIMER,this.refreshTimer);
this.timer_TOTAL.removeEventListener(TimerEvent.TIMER_COMPLETE,this.finTimerJeu);
this.timer_HERAKLES.removeEventListener(TimerEvent.TIMER,this.heraklesAction);
this.timer_JEU.removeEventListener(TimerEvent.TIMER,this.refreshCouTete);
this.timer_JEU.removeEventListener(TimerEvent.TIMER_COMPLETE,this.finSequenceJeu);
this.mainTimeline.removeEventListener(Event.ENTER_FRAME,this.enterFrame);
this._engine.stopAllSounds();
this._timeline_.kilListeners();
}
}
}