home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 151 / MOBICLIC151.ISO / mac / DATA / BLA151 / BLA151_00 / BLA151_00.swf / scripts / bla_00 / CapsuleAlgo.as
Text File  |  2013-01-17  |  8KB  |  221 lines

  1. package bla_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.          switch(this._engine.config.callerParameters.fromCodeRub)
  92.          {
  93.             case "BLA":
  94.                this.gBlague = this.gListeOrdreBLA.indexOf(this._engine.config.callerParameters.fromNumMod.toString()) + 1;
  95.          }
  96.          this.TOTO = new InteractiveMovie(this.mainTimeline["TOTO"],this._timelineManager);
  97.          this.TOTO.gotoAndStop(this.TOTO.mc.timeline.turnLabelIntoFrame(this.TOTO.mc,"E" + this.gBlague) - 1);
  98.          this.timerTOTO = new ExtendedTimer(3000);
  99.          this.timerTOTO.addEventListener(TimerEvent.TIMER,this.desinitToto);
  100.          this.initToto();
  101.          this.initTriche();
  102.          this._keyManager = new KeyManager(this.mainTimeline,this.testeKeyDown,this.testeKeyUp);
  103.       }
  104.       
  105.       public function testeKeyDown(e:*) : void
  106.       {
  107.       }
  108.       
  109.       public function testeKeyUp(e:*) : void
  110.       {
  111.       }
  112.       
  113.       public function initToto() : void
  114.       {
  115.          trace("initToto",this.gBlague);
  116.          var myLM:TextBloc = this._engine.showLM({
  117.             "id":"LM_" + this.G2D(this.gListeOrdreBLA[this.gBlague - 1]),
  118.             "findModelPattern":this.mainTimeline.LM_XX.LM,
  119.             "target":this.mainTimeline.LM_XX.LM
  120.          });
  121.          this.mainTimeline.LM_XX.LM.border = false;
  122.          this.TOTO_BLA = new InteractiveMovie(this.mainTimeline.TOTO.TOTO_BLA,this._timelineManager);
  123.          this.TOTO_BLA.mc.rollOutFrame = "E" + this.gListeOrdreTOTO[this.gBlague - 1];
  124.          this.TOTO_BLA.mc.rollOverFrame = "E5";
  125.          this.TOTO_BLA.mc.onRollOver = function():void
  126.          {
  127.             this.timeline.kilListeners();
  128.             _engine.playNoise(new NoiseObject({"code":"B_MOI"}));
  129.             this.timeline.GotoAndStop("E5");
  130.             timerTOTO.stop();
  131.          };
  132.          this.TOTO_BLA.mc.onRollOut = function():void
  133.          {
  134.             desinitToto();
  135.          };
  136.          this.TOTO_BLA.mc.onPress = function():void
  137.          {
  138.             this.kill();
  139.             timerTOTO.removeEventListener(TimerEvent.TIMER,desinitToto);
  140.             _engine.host.changeModule({"numMod":gListeOrdreBLA[gBlague - 1]});
  141.          };
  142.          this.TOTO_BLA.activeMC();
  143.          this.timerTOTO.start();
  144.       }
  145.       
  146.       public function desinitToto(e:TimerEvent = null) : void
  147.       {
  148.          var pLabelStop:String = null;
  149.          trace("desinitToto",this.gBlague);
  150.          this._engine.stopNoise(new NoiseObject({"code":"B_MOI"}));
  151.          this.timerTOTO.stop();
  152.          this.TOTO_BLA.mc.timeline.GotoAndStop("E6");
  153.          this.TOTO_BLA.kill();
  154.          var pLabelPlay:String = "E" + this.gBlague;
  155.          if(this.gBlague < 3)
  156.          {
  157.             pLabelStop = "E" + (this.gBlague + 1);
  158.             this.gBlague += 1;
  159.          }
  160.          else
  161.          {
  162.             pLabelStop = "E1";
  163.             this.gBlague = 1;
  164.          }
  165.          this.TOTO.gotoAndPlayUntil({
  166.             "labelPlay":pLabelPlay,
  167.             "beforeLabelStop":pLabelStop,
  168.             "callback":this.initToto
  169.          });
  170.       }
  171.       
  172.       public function initTriche() : void
  173.       {
  174.          var myMc:InteractiveMovie = null;
  175.          for(var i:int = 1; i <= 3; i++)
  176.          {
  177.             myMc = new InteractiveMovie(this.mainTimeline["triche_" + i],this._timelineManager);
  178.             myMc.mc.useHandCursor = false;
  179.             myMc.mc.pNum = i;
  180.             myMc.mc.onPress = function():void
  181.             {
  182.                if(_keyManager.isKeyPressed(Keyboard.SPACE) == true)
  183.                {
  184.                   _engine.host.changeModule({"numMod":this.pNum});
  185.                }
  186.             };
  187.          }
  188.       }
  189.       
  190.       public function G2D(value:int) : String
  191.       {
  192.          return GlobalesFunctions.gimme2digits(value);
  193.       }
  194.       
  195.       public function endMODULE() : void
  196.       {
  197.          trace("fin du module");
  198.       }
  199.       
  200.       public function sleep() : void
  201.       {
  202.          this.timerTOTO.pause();
  203.          this._pauseManager = new PauseManager(this._engine,this._timelineManager);
  204.          this._pauseManager.sleepMovie(this.mainTimeline);
  205.       }
  206.       
  207.       public function wake() : void
  208.       {
  209.          this.timerTOTO.resume();
  210.          this._pauseManager.wakeMovie(this.mainTimeline);
  211.       }
  212.       
  213.       public function destroy() : void
  214.       {
  215.          this.timerTOTO.removeEventListener(TimerEvent.TIMER,this.desinitToto);
  216.          this._engine.stopAllSounds();
  217.          this._timeline_.kilListeners();
  218.       }
  219.    }
  220. }
  221.