home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 145
/
MOBICLIC145.ISO
/
pc
/
DATA
/
BLA145
/
BLA145_01
/
BLA145_01.swf
/
scripts
/
bla145_01
/
CapsuleAlgo.as
Wrap
Text File
|
2012-07-18
|
10KB
|
279 lines
package bla145_01
{
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.typeargument.NoiseObject;
import com.milanpresse.tools.GlobalesFunctions;
import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.Point;
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_:Timeline;
private var _timelineManager:TimelineManager;
private var _pauseManager:PauseManager;
private var firstLabel:String = "_01";
private var gSon:int = 1;
private var gOutilBLA:int;
private var gTypeINTER:int;
private var outil:MovieClip;
public function CapsuleAlgo(engine:Engine)
{
super();
this._engine = engine;
trace(" ",this._engine.host.subtitlesOn);
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 Timeline(this.mainTimeline,this._timelineManager);
this._engine.levelCZ = this._engine.config.layers["content"];
this.gOutilBLA = Number(this._engine.config.XmlConfig.Module.Config.OUTIL.toString());
this.gTypeINTER = Number(this._engine.config.XmlConfig.Module.Config.INTERACTIVITE.toString());
this._timeline_.GotoAndPlay(2);
this.mainTimeline.addEventListener(Event.FRAME_CONSTRUCTED,this.frameContructedListener);
trace("gOutilBLA",this.gOutilBLA);
var BT_FERMER:InteractiveMovie = new InteractiveMovie(this.mainTimeline.BT_FERMER,this._timelineManager);
BT_FERMER.mc.onPress = function():void
{
endMODULE();
};
BT_FERMER.activeMC();
}
public function frameContructedListener(evt:Event) : void
{
if(this.mainTimeline.currentFrameLabel !== null)
{
if(this.mainTimeline.currentFrameLabel == "ATTENTE")
{
this.labelATTENTE();
}
else if(this.mainTimeline.currentFrameLabel.substr(3,3) == "fin")
{
this.masqueST();
}
else
{
this.afficheST();
}
}
}
public function afficheST() : void
{
this._engine.config.subtitlesBloc.showByCommentID(this._engine.config.commentName + this.mainTimeline.currentFrameLabel.substr(1,2));
this.gSon += 1;
}
public function masqueST() : void
{
this._engine.config.subtitlesBloc.hide();
var pNextLabel:int = this.getNextLabel();
if(pNextLabel == -1)
{
this.mainTimeline.removeEventListener(Event.FRAME_CONSTRUCTED,this.frameContructedListener);
this._timeline_.GotoAndPlayUntilTheEnd(this.mainTimeline.currentFrame + 1,this.endMODULE);
}
}
public function getNextLabel() : int
{
var pos:int = this._timeline_.getPosFrameLabelByName(this.mainTimeline,this.mainTimeline.currentLabel);
if(pos < this.mainTimeline.currentLabels.length - 1)
{
return this.mainTimeline.currentLabels[pos + 1].frame;
}
return -1;
}
public function labelATTENTE() : void
{
trace("labelATTENTE");
this.mainTimeline.removeEventListener(Event.FRAME_CONSTRUCTED,this.frameContructedListener);
this._timeline_.Stop();
this._engine.playNoise(new NoiseObject({"code":"B_ZONE"}));
var myMc:InteractiveMovie = new InteractiveMovie(this.mainTimeline.zone,this._timelineManager);
this.outil = this._engine.showSwf({
"code":"OUTIL_" + this.G2D(this.gOutilBLA),
"parent":this._engine.config.layers["content"]
}).swfContent;
this.outil.mouseEnabled = false;
this.outil.mouseChildren = false;
this.outil.visible = false;
myMc.mc.pNoiseRoll = "B_Z_" + this.G2D(this.gOutilBLA);
this.initMC(myMc);
}
public function initMC(myMc:InteractiveMovie) : void
{
myMc.mc.onRollOver = function():void
{
_engine.playNoise(new NoiseObject({"code":this.pNoiseRoll}));
Mouse.hide();
var point:Point = new Point(this.parent.mouseX + 400,this.parent.mouseY + 300);
outil.ref = this;
outil.x = point.x;
outil.y = point.y;
outil.enterFrame = function(evt:Event):void
{
var point:Point = null;
if(evt.target.visible == true)
{
point = new Point(outil.ref.parent.mouseX + 400,outil.ref.parent.mouseY + 300);
outil.x = point.x;
outil.y = point.y;
}
};
outil.addEventListener(Event.ENTER_FRAME,outil.enterFrame);
outil.visible = true;
};
myMc.mc.onRollOut = function():void
{
Mouse.show();
outil.visible = false;
_engine.stopNoise(new NoiseObject({"code":"B_Z_" + G2D(gOutilBLA)}));
};
myMc.mc.onMouseDown = function():void
{
this.gDownXY = new Point(this.parent.mouseX + 400,this.parent.mouseY + 300);
};
myMc.mc.onMouseUp = function():void
{
_engine.stopNoise(new NoiseObject({"code":"B_Z_" + G2D(gOutilBLA)}));
var point:Point = new Point(this.parent.mouseX + 400,this.parent.mouseY + 300);
switch(gTypeINTER)
{
case 1:
this.onValide();
break;
case 2:
if(point.y > this.gDownXY.y)
{
this.onValide();
}
else
{
this.returnOrigPoint();
}
break;
case 3:
if(point.y < this.gDownXY.y)
{
this.onValide();
}
else
{
this.returnOrigPoint();
}
break;
case 4:
if(point.x > this.gDownXY.x)
{
this.onValide();
}
else
{
this.returnOrigPoint();
}
break;
case 5:
if(point.x < this.gDownXY.x)
{
this.onValide();
}
else
{
this.returnOrigPoint();
}
break;
case 6:
if(point.x !== this.gDownXY.x && point.y !== this.gDownXY.y)
{
this.onValide();
}
else
{
this.returnOrigPoint();
}
}
this.gDown = undefined;
};
myMc.mc.onValide = function():void
{
Mouse.show();
outil.visible = false;
outil.removeEventListener(Event.ENTER_FRAME,outil.enterFrame);
this.useHandCursor = false;
myMc.kill();
mainTimeline.addEventListener(Event.FRAME_CONSTRUCTED,frameContructedListener);
_timeline_.GotoAndPlay(mainTimeline.currentFrame + 1);
};
myMc.activeDragAndDropMC();
}
public function G2D(value:int) : String
{
return GlobalesFunctions.gimme2digits(value);
}
public function endMODULE() : void
{
trace("fin du module");
this._engine.host.changeModule({"numMod":0});
}
public function sleep() : void
{
this._pauseManager = new PauseManager(this._engine,this._timelineManager);
this._pauseManager.sleepMovie(this.mainTimeline);
}
public function wake() : void
{
this._pauseManager.wakeMovie(this.mainTimeline);
}
public function destroy() : void
{
this.mainTimeline.removeEventListener(Event.FRAME_CONSTRUCTED,this.frameContructedListener);
this._engine.stopAllSounds();
this._timeline_.kilListeners();
}
}
}