home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 145 / MOBICLIC145.ISO / pc / DATA / BLA145 / BLA145_00 / BLA145_00.swf / scripts / bla145_00 / CapsuleAlgo.as
Text File  |  2012-07-18  |  7KB  |  215 lines

  1. package bla145_00
  2. {
  3.    import com.milanpresse.engine.Engine;
  4.    import com.milanpresse.engine.initmovieclip.InteractiveMovie;
  5.    import com.milanpresse.engine.managers.KeyManager;
  6.    import com.milanpresse.engine.managers.PauseManager;
  7.    import com.milanpresse.engine.managers.TimelineManager;
  8.    import com.milanpresse.engine.medias.MediaSwf;
  9.    import com.milanpresse.engine.text.TextBloc;
  10.    import com.milanpresse.engine.timelines.Timeline;
  11.    import com.milanpresse.engine.timelines.TimelineLinear;
  12.    import com.milanpresse.engine.timers.ExtendedTimer;
  13.    import com.milanpresse.engine.typeargument.NoiseObject;
  14.    import com.milanpresse.tools.GlobalesFunctions;
  15.    import flash.display.MovieClip;
  16.    import flash.events.TimerEvent;
  17.    import flash.ui.Keyboard;
  18.    
  19.    public class CapsuleAlgo
  20.    {
  21.        
  22.       
  23.       private var menu:MediaSwf;
  24.       
  25.       private var menuTimeline:MovieClip;
  26.       
  27.       private var menuTL:Timeline;
  28.       
  29.       private var mainClip:MediaSwf;
  30.       
  31.       private var mainTimeline:MovieClip;
  32.       
  33.       private var _engine:Engine;
  34.       
  35.       private var labelList:Array;
  36.       
  37.       private var _timeline_:TimelineLinear;
  38.       
  39.       private var _timelineManager:TimelineManager;
  40.       
  41.       private var _pauseManager:PauseManager;
  42.       
  43.       private var labelsCallback:Object;
  44.       
  45.       private var firstLabel:String = "ATTENTE";
  46.       
  47.       private var gListeOrdreBLA:Array;
  48.       
  49.       private var gListeOrdreTOTO:Array;
  50.       
  51.       private var gBlague:int = 1;
  52.       
  53.       private var TOTO:InteractiveMovie;
  54.       
  55.       private var TOTO_BLA:InteractiveMovie;
  56.       
  57.       private var timerTOTO:ExtendedTimer;
  58.       
  59.       private var textBloc1:TextBloc;
  60.       
  61.       private var textBloc2:TextBloc;
  62.       
  63.       private var textBloc3:TextBloc;
  64.       
  65.       private var _keyManager:KeyManager;
  66.       
  67.       public function CapsuleAlgo(engine:Engine)
  68.       {
  69.          this.labelsCallback = {};
  70.          super();
  71.          this._engine = engine;
  72.          this._engine.playMusic({"code":"MU"});
  73.          this._engine.setSubtitles(this._engine.host.subtitlesOn);
  74.          this._engine.setFrameRate(12);
  75.          this.mainClip = this._engine.showSwf({
  76.             "code":"A_" + this._engine.config.moduleName,
  77.             "parent":this._engine.config.layers["content"]
  78.          });
  79.          this.mainTimeline = this.mainClip.swfContent;
  80.          this._timelineManager = new TimelineManager();
  81.          this._timeline_ = new TimelineLinear(this.mainTimeline,this._engine,this,this._timelineManager,this.labelsCallback);
  82.          this._engine.levelCZ = this._engine.config.layers["content"];
  83.          this.gListeOrdreBLA = this._engine.config.XmlConfig.Module.Config.ordreBureauBLA.toString().split(",");
  84.          this.gListeOrdreTOTO = this._engine.config.XmlConfig.Module.Config.ordreBureauTOTO.toString().split(",");
  85.          this._timeline_.GotoAndPlayUntil({"labelStop":this.firstLabel});
  86.       }
  87.       
  88.       public function labelATTENTE() : void
  89.       {
  90.          trace("labelATTENTE");
  91.          this.TOTO = new InteractiveMovie(this.mainTimeline["TOTO"],this._timelineManager);
  92.          this.TOTO.gotoAndStop(1);
  93.          this.timerTOTO = new ExtendedTimer(3000);
  94.          this.timerTOTO.addEventListener(TimerEvent.TIMER,this.desinitToto);
  95.          this.mainTimeline.LM_XX.LM_01.visible = false;
  96.          this.mainTimeline.LM_XX.LM_02.visible = false;
  97.          this.mainTimeline.LM_XX.LM_03.visible = false;
  98.          this.initToto();
  99.          this.initTriche();
  100.          this._keyManager = new KeyManager(this.mainTimeline,this.testeKeyDown,this.testeKeyUp);
  101.       }
  102.       
  103.       public function testeKeyDown(e:*) : void
  104.       {
  105.       }
  106.       
  107.       public function testeKeyUp(e:*) : void
  108.       {
  109.       }
  110.       
  111.       public function initToto() : void
  112.       {
  113.          trace("initToto",this.gBlague);
  114.          this.mainTimeline.LM_XX["LM_" + this.G2D(this.gListeOrdreBLA[this.gBlague - 1])].visible = true;
  115.          this.TOTO_BLA = new InteractiveMovie(this.mainTimeline.TOTO.TOTO_BLA,this._timelineManager);
  116.          this.TOTO_BLA.mc.rollOutFrame = "E" + this.gListeOrdreTOTO[this.gBlague - 1];
  117.          this.TOTO_BLA.mc.rollOverFrame = "E5";
  118.          this.TOTO_BLA.mc.onRollOver = function():void
  119.          {
  120.             this.timeline.kilListeners();
  121.             _engine.playNoise(new NoiseObject({"code":"B_MOI"}));
  122.             this.timeline.GotoAndStop("E5");
  123.             timerTOTO.stop();
  124.          };
  125.          this.TOTO_BLA.mc.onRollOut = function():void
  126.          {
  127.             desinitToto();
  128.          };
  129.          this.TOTO_BLA.mc.onPress = function():void
  130.          {
  131.             this.kill();
  132.             timerTOTO.removeEventListener(TimerEvent.TIMER,desinitToto);
  133.             _engine.host.changeModule({"numMod":gListeOrdreBLA[gBlague - 1]});
  134.          };
  135.          this.TOTO_BLA.activeMC();
  136.          this.timerTOTO.start();
  137.       }
  138.       
  139.       public function desinitToto(e:TimerEvent = null) : void
  140.       {
  141.          var pLabelStop:String = null;
  142.          trace("desinitToto",this.gBlague);
  143.          this.mainTimeline.LM_XX["LM_" + this.G2D(this.gListeOrdreBLA[this.gBlague - 1])].visible = false;
  144.          this._engine.stopNoise(new NoiseObject({"code":"B_MOI"}));
  145.          this.timerTOTO.stop();
  146.          this.TOTO_BLA.mc.timeline.GotoAndStop("E6");
  147.          this.TOTO_BLA.kill();
  148.          var pLabelPlay:String = "E" + this.gBlague;
  149.          if(this.gBlague < 3)
  150.          {
  151.             pLabelStop = "E" + (this.gBlague + 1);
  152.             this.gBlague += 1;
  153.          }
  154.          else
  155.          {
  156.             pLabelStop = "E1";
  157.             this.gBlague = 1;
  158.          }
  159.          this.TOTO.gotoAndPlayUntil({
  160.             "labelPlay":pLabelPlay,
  161.             "beforeLabelStop":pLabelStop,
  162.             "callback":this.initToto
  163.          });
  164.       }
  165.       
  166.       public function initTriche() : void
  167.       {
  168.          var myMc:InteractiveMovie = null;
  169.          for(var i:int = 1; i <= 3; i++)
  170.          {
  171.             myMc = new InteractiveMovie(this.mainTimeline["triche_" + i],this._timelineManager);
  172.             myMc.mc.useHandCursor = false;
  173.             myMc.mc.pNum = i;
  174.             myMc.mc.onPress = function():void
  175.             {
  176.                if(_keyManager.isKeyPressed(Keyboard.SPACE) == true)
  177.                {
  178.                   _engine.host.changeModule({"numMod":this.pNum});
  179.                }
  180.             };
  181.          }
  182.       }
  183.       
  184.       public function G2D(value:int) : String
  185.       {
  186.          return GlobalesFunctions.gimme2digits(value);
  187.       }
  188.       
  189.       public function endMODULE() : void
  190.       {
  191.          trace("fin du module");
  192.       }
  193.       
  194.       public function sleep() : void
  195.       {
  196.          this.timerTOTO.pause();
  197.          this._pauseManager = new PauseManager(this._engine,this._timelineManager);
  198.          this._pauseManager.sleepMovie(this.mainTimeline);
  199.       }
  200.       
  201.       public function wake() : void
  202.       {
  203.          this.timerTOTO.resume();
  204.          this._pauseManager.wakeMovie(this.mainTimeline);
  205.       }
  206.       
  207.       public function destroy() : void
  208.       {
  209.          this.timerTOTO.removeEventListener(TimerEvent.TIMER,this.desinitToto);
  210.          this._engine.stopAllSounds();
  211.          this._timeline_.kilListeners();
  212.       }
  213.    }
  214. }
  215.