home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 148
/
MOBICLIC148.ISO
/
mac
/
DATA
/
DSS148
/
DSS148_01
/
DSS148_01.swf
/
scripts
/
dss148
/
Commun.as
next >
Wrap
Text File
|
2012-10-16
|
18KB
|
435 lines
package dss148
{
import com.milanpresse.engine.Engine;
import com.milanpresse.engine.timelines.TimelineLinear;
import com.milanpresse.engineaddons.facades.EngineExt;
import com.milanpresse.engineaddons.initdisplayobject.ExtendedClip;
import com.milanpresse.engineaddons.labelstypes.Attente2;
import com.milanpresse.tools.GlobalesFunctions;
import flash.display.MovieClip;
import flash.text.TextField;
public class Commun
{
private var _engine:Engine;
private var _e:EngineExt;
private var _w;
public var memo:Memo;
private var codesTriches:Array;
public var trichCodeCallback:Function = null;
private var ecranChoix:ExtendedClip;
private var ecranCode:ExtendedClip;
private var ecranInterface:ExtendedClip;
private var pouvoirOuvre:ExtendedClip;
public var trichCodeVisible:Boolean = false;
private var numFails:int = 0;
public function Commun(param1:Engine)
{
this.codesTriches = ["TITANIC","SOLEIL","RASCAR","POSEIDON"];
super();
this._engine = param1;
this.memo = new Memo(this._engine);
}
public function init(param1:*) : void
{
var world:* = param1;
this._w = world;
this._e = new EngineExt(this._engine,this._w._timelineManager);
var interfaceCommune:MovieClip = this._engine.showSwf({
"id":"_INTERFACE_COMMUNE_",
"parent":this._engine.config.layers["menu"]
}).swfContent;
interfaceCommune.CADRE.visible = false;
this.ecranInterface = new ExtendedClip(interfaceCommune,this._e);
this.ecranInterface.movie.mouseChildren = true;
this.ecranInterface.movie.useHandCursor = false;
this.ecranInterface.visible = false;
this.ecranInterface.attente = new Attente2(this._e);
this._e.instanceToDestroyAdd(this.ecranInterface.attente);
this.ecranInterface.attente.buttons = [];
var buttons:Array = [];
buttons.push({
"clip":this.ecranInterface.getChildByName("BT_SOS") as MovieClip,
"onRollOverState":{
"label":"E2",
"noiseCode":"B_SOS"
}
});
this.ecranInterface.attente.buttons = buttons;
this.ecranInterface.attente.getButton("BT_SOS").onRollOver = function():void
{
trichCodeVisible = true;
_w.sleep();
};
this.ecranInterface.attente.getButton("BT_SOS").onRollOut = function():void
{
trichCodeVisible = false;
_w.wake();
};
this.ecranInterface.attente.onClick = function(param1:String, param2:* = null):void
{
switch(param1)
{
case "BT_SOS":
ecranInterface.attente.getButton("BT_SOS").enabled = false;
ecranInterface.attente.getButton("BT_SOS").visible = false;
ecranCode.visible = true;
trichCodeVisible = true;
_e.soundPlay({
"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01",
"autoDetectType":false
});
}
};
var ecran_code:MovieClip = this._engine.showSwf({
"id":"_FENETRE_CODE_",
"parent":this._engine.config.layers["menu"]
}).swfContent;
this.ecranCode = new ExtendedClip(ecran_code,this._e);
this.ecranCode.gotoAndStop("ATTENTE");
this.ecranCode.movie.mouseChildren = true;
this.ecranCode.movie.useHandCursor = false;
this.ecranCode.visible = false;
this.ecranCode.movie.CADRE.visible = false;
this.ecranCode.attente = new Attente2(this._e);
this._e.instanceToDestroyAdd(this.ecranCode.attente);
this.ecranCode.attente.buttons = [];
buttons = [];
buttons.push({
"clip":this.ecranCode.getChildByName("BT_CROIX") as MovieClip,
"onRollOverState":{
"label":"E2",
"noiseCode":"B_SOS"
}
});
buttons.push({
"clip":this.ecranCode.getChildByName("BT_VALIDE") as MovieClip,
"onRollOverState":{
"label":"E2",
"noiseCode":"B_SOS"
}
});
buttons.push({
"clip":this.ecranCode.getChildByName("LM_TITRE_02") as MovieClip,
"onRollOverState":{
"label":"E2",
"noiseCode":"B_SOS"
}
});
this.ecranCode.attente.buttons = buttons;
this.ecranCode.attente.onClick = function(param1:String, param2:* = null):void
{
var name:String = param1;
var data:* = param2;
switch(name)
{
case "BT_CROIX":
ecranCode.visible = false;
trichCodeVisible = false;
_w.wake();
_engine.stopSound({"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01"});
ecranInterface.attente.getButton("BT_SOS").enabled = true;
ecranInterface.attente.getButton("BT_SOS").visible = true;
break;
case "BT_VALIDE":
if((ecranCode.movie.CODE_TEXT as TextField).text.toUpperCase() == codesTriches[_e.config.moduleNum - 1])
{
_engine.stopSound({"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01"});
_e.noisePlay({
"code":"B_VALIDE",
"callback":function():void
{
ecranCode.visible = false;
_w.wake();
trichCodeVisible = false;
trichCodeCallback();
}
});
ecranInterface.visible = false;
}
else
{
_e.noisePlay({
"code":"B_NO",
"callback":function():void
{
ecranCode.movie.CODE_TEXT.text = "";
}
});
}
break;
case "LM_TITRE_02":
_engine.stopSound({"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01"});
_e.openUrl("http://www.mobiclic.com/4-super-pouvoirs-nature/?tc=" + _e.config.moduleNum);
}
};
var ecran:MovieClip = this._engine.showSwf({
"id":"_FENETRE_CHOIX_",
"parent":this._engine.config.layers["menu"]
}).swfContent;
this.ecranChoix = new ExtendedClip(ecran,this._e);
this.ecranChoix.movie.mouseChildren = true;
this.ecranChoix.movie.useHandCursor = false;
this.ecranChoix.timeline = new TimelineLinear(ecran,this._engine,this,this._w._timelineManager,{});
this.ecranChoix.timeline.GotoAndPlayUntil({"labelStop":"ATTENTE"});
this.ecranChoix.visible = false;
var animClip:ExtendedClip = new ExtendedClip(ecran.getChildByName("ROBOT_P") as MovieClip,this._e);
animClip.gotoAndStop(1);
animClip.visible = false;
this.ecranChoix.ROBOT_P = animClip;
animClip = new ExtendedClip(ecran.getChildByName("ZONES_POUV") as MovieClip,this._e);
animClip.gotoAndStop(1);
animClip.visible = false;
animClip.movie.mouseChildren = true;
animClip.movie.useHandCursor = false;
this.ecranChoix.ZONES_POUV = animClip;
animClip = new ExtendedClip(ecran.getChildByName("LOGI_P") as MovieClip,this._e);
animClip.gotoAndStop(1);
animClip.visible = false;
this.ecranChoix.LOGI_P = animClip;
animClip = new ExtendedClip(ecran.getChildByName("LOGI_ROB_AT") as MovieClip,this._e);
animClip.gotoAndStop(1);
animClip.visible = false;
this.ecranChoix.LOGI_ROB_AT = animClip;
animClip = new ExtendedClip(ecran.getChildByName("LOGI_MONTRE") as MovieClip,this._e);
animClip.gotoAndStop(1);
animClip.visible = false;
this.ecranChoix.LOGI_MONTRE = animClip;
animClip = new ExtendedClip(ecran.getChildByName("DECORS") as MovieClip,this._e);
animClip.gotoAndStop(1);
animClip.visible = false;
this.ecranChoix.DECORS = animClip;
animClip = new ExtendedClip(ecran.getChildByName("LOGI_SUCCES") as MovieClip,this._e);
animClip.gotoAndStop(1);
animClip.visible = false;
this.ecranChoix.LOGI_SUCCES = animClip;
this.pouvoirOuvre = new ExtendedClip(ecran.getChildByName("POUVOIR_OUVRE") as MovieClip,this._e);
this.pouvoirOuvre.gotoAndStop(1);
this.pouvoirOuvre.movie.mouseChildren = true;
this.pouvoirOuvre.movie.useHandCursor = false;
this.pouvoirOuvre.visible = false;
this.ecranChoix.LOGI_ROB_AT.visible = true;
this.ecranChoix.ZONES_POUV.visible = true;
this.ecranChoix.DECORS.visible = true;
this.ecranChoix.attente = new Attente2(this._e);
this._e.instanceToDestroyAdd(this.ecranChoix.attente);
this.ecranChoix.attente.buttons = [];
buttons = [];
var i:int = 1;
while(i <= 4)
{
buttons.push({
"clip":this.ecranChoix.ZONES_POUV.getChildByName("POUV_" + GlobalesFunctions.gimme2digits(i)),
"data":i,
"onRollOverState":{
"label":"E2",
"noiseCode":"B_0" + i,
"ibId":"IB_0" + i
}
});
i++;
}
this.ecranChoix.attente.buttons = buttons;
this.ecranChoix.attente.onClick = function(param1:String, param2:* = null):void
{
var name:String = param1;
var data:* = param2;
ecranChoix.attente.enabled = false;
ecranChoix.LOGI_ROB_AT.visible = false;
ecranChoix.ROBOT_P.visible = true;
ecranChoix.ROBOT_P.gotoAndPlay(1);
_e.soundPlay({
"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_DEST_0" + data,
"callback":function():void
{
ecranChoix.ROBOT_P.gotoAndStop(1);
ecranChoix.ROBOT_P.visible = false;
ecranChoix.attente.visible = false;
ecranChoix.LOGI_MONTRE.gotoAndPlay(1,function():void
{
ecranChoix.LOGI_MONTRE.stop();
_engine.host.changeModule({"numMod":data});
});
ecranChoix.LOGI_MONTRE.visible = true;
}
});
};
}
public function ecranChoixShow(param1:Boolean = false) : void
{
var succes:Boolean = param1;
this.ecranChoix.DECORS.gotoAndStop("D0" + this.memo.savePoint.moduleNum);
this.ecranChoix.attente.enabled = false;
this.refresh();
this.ecranChoix.visible = true;
this.pouvoirOuvre.gotoAndPlay(1,function():void
{
pouvoirOuvre.visible = false;
pouvoirOuvre.gotoAndStop(1);
if(succes)
{
succesRetour();
}
});
this.pouvoirOuvre.visible = true;
}
public function ecranInterfaceShow() : void
{
++this.numFails;
if(this.numFails >= 3)
{
this.ecranInterface.visible = true;
}
}
public function ecranCodeHide() : void
{
this.ecranCode.visible = false;
this.trichCodeVisible = false;
this._engine.stopSound({"id":"S_" + this._e.config.lang + "_" + this._e.config.rubriqueName + "_TRI_01"});
this.ecranInterface.attente.getButton("BT_SOS").enabled = true;
this.ecranInterface.attente.getButton("BT_SOS").visible = true;
}
private function refresh() : void
{
var _loc1_:ExtendedClip = null;
var _loc2_:int = 1;
while(_loc2_ <= 4)
{
_loc1_ = this.ecranChoix.attente.buttons[_loc2_ - 1].btn as ExtendedClip;
if(this.memo.modules[_loc2_].vu)
{
_loc1_.enabled = false;
_loc1_.gotoAndStop("E4_FIXE");
}
else
{
_loc1_.gotoAndStop("E1");
_loc1_.enabled = true;
}
_loc2_++;
}
}
private function succesRetour() : void
{
this.ecranChoix.attente.buttons[this.memo.module.no - 1].btn.enabled = false;
this.ecranChoix.attente.buttons[this.memo.module.no - 1].btn.gotoAndStop("E3");
this._e.noisePlay({
"code":"B_VALIDE",
"callback":function():void
{
if(getNbFounded() < 4)
{
ecranChoix.LOGI_ROB_AT.visible = false;
ecranChoix.LOGI_P.visible = true;
ecranChoix.LOGI_P.gotoAndPlay(1);
ecranChoix.attente.buttons[memo.module.no - 1].btn.gotoAndStop("E4");
_e.soundPlay({
"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_POUV_0" + memo.module.no,
"callback":function():void
{
ecranChoix.attente.buttons[memo.module.no - 1].btn.gotoAndStop("E4_FIXE");
ecranChoix.LOGI_ROB_AT.visible = true;
ecranChoix.LOGI_P.visible = false;
ecranChoix.LOGI_P.gotoAndStop(1);
_e.soundPlay({
"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_CHOIX_0" + getNbFounded(),
"callback":function():void
{
refresh();
}
});
}
});
}
else
{
ecranChoix.attente.buttons[memo.module.no - 1].btn.gotoAndStop("E4");
_e.noisePlay({
"code":"B_OK",
"callback":function():void
{
ecranChoix.LOGI_P.visible = false;
var i:* = 0;
while(i < ecranChoix.attente.buttons.length)
{
ecranChoix.attente.buttons[i].btn.gotoAndStop("E5");
i++;
}
_e.noisePlay({
"code":"B_GAGNE",
"callback":function():void
{
ecranChoix.LOGI_SUCCES.visible = true;
ecranChoix.LOGI_ROB_AT.visible = false;
var i:* = 0;
while(i < ecranChoix.attente.buttons.length)
{
ecranChoix.attente.buttons[i].btn.gotoAndStop("E5_FIXE");
ecranChoix.attente.buttons[i].btn.visible = false;
i++;
}
ecranChoix.LOGI_SUCCES.gotoAndPlay(1,function():void
{
ecranChoix.LOGI_SUCCES.gotoAndStop(1);
});
_e.soundPlay({
"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_GAGNE",
"callback":function():void
{
ecranChoix.LOGI_SUCCES.visible = false;
ecranChoix.LOGI_ROB_AT.visible = true;
var _loc1_:* = 0;
while(_loc1_ < ecranChoix.attente.buttons.length)
{
ecranChoix.attente.buttons[_loc1_].btn.visible = true;
_loc1_++;
}
_engine.host.changeModule({"numMod":5});
}
});
}
});
}
});
}
}
});
}
private function getNbFounded() : int
{
var _loc1_:int = 0;
var _loc2_:int = 1;
while(_loc2_ <= 4)
{
if(this.memo.modules[_loc2_].vu)
{
_loc1_++;
}
_loc2_++;
}
return _loc1_;
}
}
}