home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 145 / MOBICLIC145.ISO / pc / DATA / DCV145 / DCV145_00 / DCV145_00.swf / scripts / dcv145_00 / CapsuleAlgo.as
Text File  |  2012-07-18  |  20KB  |  564 lines

  1. package dcv145_00
  2. {
  3.    import com.milanpresse.engine.Engine;
  4.    import com.milanpresse.engine.initmovieclip.InitMovieclip;
  5.    import com.milanpresse.engine.managers.PauseManager;
  6.    import com.milanpresse.engine.managers.PrintManager;
  7.    import com.milanpresse.engine.managers.TimelineManager;
  8.    import com.milanpresse.engine.medias.MediaImage;
  9.    import com.milanpresse.engine.medias.MediaImageBatch;
  10.    import com.milanpresse.engine.medias.MediaSwf;
  11.    import com.milanpresse.engine.timelines.Timeline;
  12.    import com.milanpresse.engine.timelines.TimelineLinear;
  13.    import com.milanpresse.engine.typeargument.CommentObject;
  14.    import com.milanpresse.engine.typeargument.NoiseObject;
  15.    import flash.display.MovieClip;
  16.    import flash.display.Sprite;
  17.    import flash.net.SharedObject;
  18.    
  19.    public class CapsuleAlgo
  20.    {
  21.        
  22.       
  23.       private var mainClip:MediaSwf;
  24.       
  25.       private var mainTimeline:MovieClip;
  26.       
  27.       private var _engine:Engine;
  28.       
  29.       private var labelList:Array;
  30.       
  31.       private var labelsCallback:Object;
  32.       
  33.       private var _timeline_:TimelineLinear;
  34.       
  35.       private var _timelineManager:TimelineManager;
  36.       
  37.       private var _pauseManager:PauseManager;
  38.       
  39.       private var so:SharedObject;
  40.       
  41.       private var _pauseOn:Boolean = false;
  42.       
  43.       private var ciel:String;
  44.       
  45.       private var constellations:Object;
  46.       
  47.       private var constellationsDone:Object;
  48.       
  49.       private var countDone:int;
  50.       
  51.       private var doneSucces:Boolean = false;
  52.       
  53.       private var actualConstel:MovieClip;
  54.       
  55.       public function CapsuleAlgo(param1:Engine)
  56.       {
  57.          this.constellations = {
  58.             "CIEL_NORD":["00","01","02","03","04"],
  59.             "CIEL_SUD":["05","06","07"],
  60.             "CIEL_EST":["03_B","08","09","10"],
  61.             "CIEL_OUEST":["01_B","11","12"]
  62.          };
  63.          super();
  64.          this._engine = param1;
  65.          this._engine.playMusic({"code":"MU"});
  66.          this._engine.setSubtitles(this._engine.host.subtitlesOn);
  67.          this._engine.setFrameRate(12);
  68.          this.so = SharedObject.getLocal(this._engine.config.rubriqueName,"/");
  69.          var _loc2_:* = this._engine.config.callerParameters.fromCodeRub == "MOB";
  70.          if(_loc2_ == true)
  71.          {
  72.             this.so.clear();
  73.             this.constellationsDone = {
  74.                "CIEL_NORD":[0,0,0,0,0],
  75.                "CIEL_SUD":[0,0,0],
  76.                "CIEL_EST":[0,0,0,0],
  77.                "CIEL_OUEST":[0,0,0]
  78.             };
  79.             this.countDone = 0;
  80.             this.saveConstellations();
  81.          }
  82.          else if(this.so.size == 0)
  83.          {
  84.             this.constellationsDone = {
  85.                "CIEL_NORD":[0,0,0,0,0],
  86.                "CIEL_SUD":[0,0,0],
  87.                "CIEL_EST":[0,0,0,0],
  88.                "CIEL_OUEST":[0,0,0]
  89.             };
  90.             this.countDone = 0;
  91.          }
  92.          else
  93.          {
  94.             this.constellationsDone = this.so.data.constellationsDone;
  95.             this.countDone = this.so.data.countDone;
  96.          }
  97.          this.mainClip = this._engine.showSwf({
  98.             "code":"A_" + this._engine.config.moduleName,
  99.             "parent":this._engine.config.layers["content"]
  100.          });
  101.          this.mainTimeline = this.mainClip.swfContent;
  102.          this.labelList = [];
  103.          var _loc3_:int = 0;
  104.          while(_loc3_ < this.mainTimeline.currentLabels.length)
  105.          {
  106.             this.labelList.push(this.mainTimeline.currentLabels[_loc3_].name);
  107.             _loc3_++;
  108.          }
  109.          this.labelsCallback = {
  110.             "CIEL_NORD":this.initConstellations,
  111.             "CIEL_SUD":this.initConstellations,
  112.             "CIEL_EST":this.initConstellations,
  113.             "CIEL_OUEST":this.initConstellations,
  114.             "_C00_04":this.manageFrame_RETURN,
  115.             "_C01_02":this.manageFrame_RETURN,
  116.             "_C02_02":this.manageFrame_RETURN,
  117.             "_C03_02":this.manageFrame_RETURN,
  118.             "_C04_02":this.manageFrame_RETURN,
  119.             "_C05_02":this.manageFrame_RETURN,
  120.             "_C06_02":this.manageFrame_RETURN,
  121.             "_C07_02":this.manageFrame_RETURN,
  122.             "_C08_02":this.manageFrame_C08_02,
  123.             "_C09_02":this.manageFrame_RETURN,
  124.             "_C10_02":this.manageFrame_RETURN,
  125.             "_C11_02":this.manageFrame_RETURN,
  126.             "_C01_B_01":this.manageFrame_C01_B_01,
  127.             "_C01_B_02":this.manageFrame_C01_B_02,
  128.             "_C03_B_01":this.manageFrame_C03_B_01,
  129.             "_C03_B_02":this.manageFrame_C03_B_02,
  130.             "_C08_03":this.manageFrame_C08_03,
  131.             "_C08_04":this.manageFrame_C08_04,
  132.             "_C12_02":this.manageFrame_C12_02
  133.          };
  134.          this._timelineManager = new TimelineManager();
  135.          this._timeline_ = new TimelineLinear(this.mainTimeline,this._engine,this,this._timelineManager,this.labelsCallback);
  136.          if(this._engine.config.musicOn == true)
  137.          {
  138.             this._engine.playMusic({"code":"MU"});
  139.          }
  140.          this.ciel = "NORD";
  141.          this.initBTS();
  142.          if(_loc2_ == true)
  143.          {
  144.             this._timeline_.GotoAndPlayUntil({"labelStop":"_00_00"});
  145.          }
  146.          else
  147.          {
  148.             this._timeline_.GotoAndStop("CIEL_NORD");
  149.             this.initConstellations();
  150.          }
  151.       }
  152.       
  153.       private function saveConstellations() : void
  154.       {
  155.          this.so.data.constellationsDone = this.constellationsDone;
  156.          this.so.data.countDone = this.countDone;
  157.          this.so.flush();
  158.       }
  159.       
  160.       public function sleep() : void
  161.       {
  162.          this._pauseManager = new PauseManager(this._engine,this._timelineManager);
  163.          this._pauseManager.sleepMovie(this.mainTimeline);
  164.       }
  165.       
  166.       public function wake() : void
  167.       {
  168.          this._pauseManager.wakeMovie(this.mainTimeline);
  169.       }
  170.       
  171.       public function destroy() : void
  172.       {
  173.          this._engine.stopAllSounds();
  174.       }
  175.       
  176.       private function initBTS() : void
  177.       {
  178.          var myMc:MovieClip = this.mainTimeline.BT_IMPRIM;
  179.          var _timeline:Timeline = new Timeline(myMc,this._timelineManager);
  180.          InitMovieclip.InitMc({"mc":myMc});
  181.          _timeline.GotoAndStop(1);
  182.          myMc.pBruitRoll = "B_IMPRIM";
  183.          myMc.onPress = function(param1:Object):void
  184.          {
  185.             _engine.stopNoise({"code":param1.mc.pBruitRoll});
  186.             initPrint();
  187.          };
  188.          myMc.onRollOver = function(param1:Object):void
  189.          {
  190.             _engine.playNoise(new NoiseObject({"code":param1.mc.pBruitRoll}));
  191.          };
  192.          myMc.onRollOut = function(param1:Object):void
  193.          {
  194.             _engine.stopNoise({"code":param1.mc.pBruitRoll});
  195.          };
  196.          myMc = this.mainTimeline.BT_ASTRES;
  197.          _timeline = new Timeline(myMc,this._timelineManager);
  198.          InitMovieclip.InitMc({"mc":myMc});
  199.          _timeline.GotoAndStop(1);
  200.          myMc.pBruitRoll = "B_ASTRES";
  201.          myMc.onPress = function():void
  202.          {
  203.             _engine.host.changeModule({
  204.                "codeRub":_engine.config.rubriqueCode,
  205.                "numMod":1
  206.             });
  207.          };
  208.          myMc.onRollOver = function(param1:Object):void
  209.          {
  210.             _engine.playNoise(new NoiseObject({"code":param1.mc.pBruitRoll}));
  211.          };
  212.          myMc.onRollOut = function(param1:Object):void
  213.          {
  214.             _engine.stopNoise({"code":param1.mc.pBruitRoll});
  215.          };
  216.          var cardinalPoints:Array = new Array("BT_NORD","BT_SUD","BT_EST","BT_OUEST");
  217.          var i:int = 0;
  218.          while(i < cardinalPoints.length)
  219.          {
  220.             myMc = this.mainTimeline[cardinalPoints[i]];
  221.             myMc.ciel = myMc.name.split("_")[1];
  222.             _timeline = new Timeline(myMc,this._timelineManager);
  223.             InitMovieclip.InitMc({"mc":myMc});
  224.             if(myMc.ciel == this.ciel)
  225.             {
  226.                myMc.desactive();
  227.                myMc.mouseEnabled = false;
  228.                myMc.mouseChildren = false;
  229.                _timeline.GotoAndStop("E2");
  230.             }
  231.             else
  232.             {
  233.                _timeline.GotoAndStop(1);
  234.                myMc.mouseEnabled = true;
  235.                myMc.mouseChildren = true;
  236.             }
  237.             myMc.pBruitRoll = "B_ROLL";
  238.             myMc.onPress = function(param1:Object):void
  239.             {
  240.                _engine.stopNoise({"code":param1.mc.pBruitRoll});
  241.                changeCiel(param1.mc.name.split("_")[1]);
  242.             };
  243.             myMc.onRollOver = function(param1:Object):void
  244.             {
  245.                _engine.playNoise(new NoiseObject({"code":param1.mc.pBruitRoll}));
  246.             };
  247.             myMc.onRollOut = function(param1:Object):void
  248.             {
  249.                _engine.stopNoise({"code":param1.mc.pBruitRoll});
  250.             };
  251.             i++;
  252.          }
  253.       }
  254.       
  255.       private function changeCiel(param1:String) : void
  256.       {
  257.          this.mainTimeline["BT_" + this.ciel].active();
  258.          this.mainTimeline["BT_" + this.ciel].timeline.GotoAndStop("E1");
  259.          this.mainTimeline["BT_" + this.ciel].mouseEnabled = true;
  260.          this.mainTimeline["BT_" + this.ciel].mouseChildren = true;
  261.          this._timeline_.GotoAndStop("CIEL_" + param1);
  262.          this.ciel = param1;
  263.          this.mainTimeline["BT_" + this.ciel].desactive();
  264.          this.mainTimeline["BT_" + this.ciel].timeline.GotoAndStop("E2");
  265.          this.mainTimeline["BT_" + this.ciel].mouseEnabled = false;
  266.          this.mainTimeline["BT_" + this.ciel].mouseChildren = false;
  267.          var _loc2_:Boolean = false;
  268.          var _loc3_:int = 0;
  269.          while(_loc3_ < this.constellationsDone["CIEL_" + this.ciel].length)
  270.          {
  271.             if(this.constellationsDone["CIEL_" + this.ciel][_loc3_] == 0)
  272.             {
  273.                _loc2_ = true;
  274.             }
  275.             _loc3_++;
  276.          }
  277.          if(_loc2_ == true)
  278.          {
  279.             this._engine.playComment(new CommentObject({"code":this.ciel}));
  280.          }
  281.          this.initConstellations();
  282.       }
  283.       
  284.       private function initConstellations() : void
  285.       {
  286.          var myCiel:String = null;
  287.          var myMc:MovieClip = null;
  288.          var _timeline:Timeline = null;
  289.          var lm:String = null;
  290.          myCiel = "CIEL_" + this.ciel;
  291.          var i:int = 0;
  292.          while(i < this.constellations[myCiel].length)
  293.          {
  294.             myMc = this.mainTimeline["CONSTEL_" + this.constellations[myCiel][i]];
  295.             myMc.index = i;
  296.             _timeline = new Timeline(myMc,this._timelineManager);
  297.             InitMovieclip.InitMc({
  298.                "mc":myMc,
  299.                "rollOverFrame":"E1",
  300.                "rollOutFrame":"E0"
  301.             });
  302.             lm = this.constellations[myCiel][i];
  303.             if(this.constellationsDone[myCiel][i])
  304.             {
  305.                _timeline.GotoAndStop("E2");
  306.                this.mainTimeline["LM_" + lm].visible = true;
  307.             }
  308.             else
  309.             {
  310.                _timeline.GotoAndStop(1);
  311.                this.mainTimeline["LM_" + lm].visible = false;
  312.             }
  313.             myMc.pBruitRoll = "B_CONSTEL";
  314.             myMc.onPress = function(param1:Object):void
  315.             {
  316.                _engine.stopNoise({"code":param1.mc.pBruitRoll});
  317.                mDownConstellation(this);
  318.                if(!constellationsDone[myCiel][this.index])
  319.                {
  320.                   if(ciel == "NORD")
  321.                   {
  322.                      if(this.index !== 0)
  323.                      {
  324.                         countDone += 1;
  325.                      }
  326.                   }
  327.                   else
  328.                   {
  329.                      countDone += 1;
  330.                   }
  331.                   constellationsDone[myCiel][this.index] = 1;
  332.                   if(ciel == "NORD" && this.index == 1)
  333.                   {
  334.                      constellationsDone["CIEL_OUEST"][0] = 1;
  335.                   }
  336.                   if(ciel == "OUEST" && this.index == 0)
  337.                   {
  338.                      constellationsDone["CIEL_NORD"][1] = 1;
  339.                   }
  340.                   if(ciel == "NORD" && this.index == 3)
  341.                   {
  342.                      constellationsDone["CIEL_EST"][0] = 1;
  343.                   }
  344.                   if(ciel == "EST" && this.index == 0)
  345.                   {
  346.                      constellationsDone["CIEL_NORD"][3] = 1;
  347.                   }
  348.                   saveConstellations();
  349.                }
  350.             };
  351.             myMc.onRollOver = function(param1:Object):void
  352.             {
  353.                var _loc2_:Timeline = null;
  354.                _engine.playNoise(new NoiseObject({"code":param1.mc.pBruitRoll}));
  355.                if(this.name !== "CONSTEL_00")
  356.                {
  357.                   _loc2_ = new Timeline(this.ANIM,_timelineManager);
  358.                   _loc2_.GotoAndPlayUntil({
  359.                      "labelPlay":1,
  360.                      "labelStop":this.ANIM.totalFrames
  361.                   });
  362.                }
  363.             };
  364.             myMc.onRollOut = function(param1:Object):void
  365.             {
  366.                _engine.stopNoise({"code":param1.mc.pBruitRoll});
  367.                if(constellationsDone[myCiel][this.index])
  368.                {
  369.                   param1.mc.timeline.GotoAndStop("E2");
  370.                }
  371.             };
  372.             i++;
  373.          }
  374.       }
  375.       
  376.       private function mDownConstellation(param1:MovieClip) : void
  377.       {
  378.          this.actualConstel = param1;
  379.          var _loc2_:String = param1.name.substring(8);
  380.          this._timeline_.GotoAndPlayUntil({"labelStop":"_C" + _loc2_ + "_01"});
  381.       }
  382.       
  383.       private function manageFrame_RETURN() : void
  384.       {
  385.          var _loc4_:Timeline = null;
  386.          this.actualConstel.gotoAndStop("E0");
  387.          var _loc1_:String = this.mainTimeline.currentFrameLabel;
  388.          var _loc2_:MovieClip = this.mainTimeline["anim"];
  389.          if(_loc2_ !== null)
  390.          {
  391.             (_loc4_ = new Timeline(_loc2_,this._timelineManager)).GotoAndPlayUntil({
  392.                "labelPlay":1,
  393.                "labelStop":_loc2_.totalFrames
  394.             });
  395.          }
  396.          var _loc3_:String = _loc1_.substring(1);
  397.          this._engine.playComment(new CommentObject({
  398.             "code":_loc3_,
  399.             "callback":this.goCiel
  400.          }));
  401.       }
  402.       
  403.       private function goCiel() : void
  404.       {
  405.          var _loc3_:MovieClip = null;
  406.          var _loc4_:Timeline = null;
  407.          var _loc5_:String = null;
  408.          if(this.countDone == 12 && !this.doneSucces)
  409.          {
  410.             this.doneSucces = true;
  411.             this._engine.playComment(new CommentObject({"code":"SUCCES"}));
  412.          }
  413.          this._timeline_.GotoAndStop("CIEL_" + this.ciel);
  414.          var _loc1_:String = "CIEL_" + this.ciel;
  415.          var _loc2_:int = 0;
  416.          while(_loc2_ < this.constellations[_loc1_].length)
  417.          {
  418.             _loc3_ = this.mainTimeline["CONSTEL_" + this.constellations[_loc1_][_loc2_]];
  419.             _loc3_.index = _loc2_;
  420.             _loc4_ = new Timeline(_loc3_,this._timelineManager);
  421.             InitMovieclip.InitMc({
  422.                "mc":_loc3_,
  423.                "rollOverFrame":"E1",
  424.                "rollOutFrame":"E0"
  425.             });
  426.             _loc5_ = this.constellations[_loc1_][_loc2_];
  427.             if(this.constellationsDone[_loc1_][_loc2_])
  428.             {
  429.                _loc4_.GotoAndStop("E2");
  430.                this.mainTimeline["LM_" + _loc5_].visible = true;
  431.             }
  432.             else
  433.             {
  434.                _loc4_.GotoAndStop(1);
  435.                this.mainTimeline["LM_" + _loc5_].visible = false;
  436.             }
  437.             _loc2_++;
  438.          }
  439.       }
  440.       
  441.       private function manageFrame_C01_B_01() : void
  442.       {
  443.          var _loc3_:Timeline = null;
  444.          var _loc1_:String = this.mainTimeline.currentFrameLabel;
  445.          var _loc2_:MovieClip = this.mainTimeline["anim"];
  446.          if(_loc2_ !== null)
  447.          {
  448.             _loc3_ = new Timeline(_loc2_,this._timelineManager);
  449.             _loc3_.GotoAndPlayUntil({
  450.                "labelPlay":1,
  451.                "labelStop":_loc2_.totalFrames
  452.             });
  453.          }
  454.          this._engine.playComment(new CommentObject({
  455.             "code":"C01_01",
  456.             "callback":this._timeline_.nextLabel
  457.          }));
  458.       }
  459.       
  460.       private function manageFrame_C01_B_02() : void
  461.       {
  462.          this.actualConstel.gotoAndStop("E0");
  463.          this._engine.playComment(new CommentObject({
  464.             "code":"C01_02",
  465.             "callback":this.goCiel
  466.          }));
  467.       }
  468.       
  469.       private function manageFrame_C03_B_01() : void
  470.       {
  471.          var _loc3_:Timeline = null;
  472.          var _loc1_:String = this.mainTimeline.currentFrameLabel;
  473.          var _loc2_:MovieClip = this.mainTimeline["anim"];
  474.          if(_loc2_ !== null)
  475.          {
  476.             _loc3_ = new Timeline(_loc2_,this._timelineManager);
  477.             _loc3_.GotoAndPlayUntil({
  478.                "labelPlay":1,
  479.                "labelStop":_loc2_.totalFrames
  480.             });
  481.          }
  482.          this._engine.playComment(new CommentObject({
  483.             "code":"C03_01",
  484.             "callback":this._timeline_.nextLabel
  485.          }));
  486.       }
  487.       
  488.       private function manageFrame_C03_B_02() : void
  489.       {
  490.          this.actualConstel.gotoAndStop("E0");
  491.          this._engine.playComment(new CommentObject({
  492.             "code":"C03_02",
  493.             "callback":this.goCiel
  494.          }));
  495.       }
  496.       
  497.       private function manageFrame_C08_02() : void
  498.       {
  499.          this.actualConstel.gotoAndStop("E0");
  500.          this._engine.playComment(new CommentObject({
  501.             "code":"C08_02",
  502.             "callback":this._timeline_.nextLabel
  503.          }));
  504.       }
  505.       
  506.       private function manageFrame_C08_03() : void
  507.       {
  508.          this.actualConstel.gotoAndStop("E2");
  509.          this._engine.playComment(new CommentObject({
  510.             "code":"C08_03",
  511.             "callback":this._timeline_.nextLabel
  512.          }));
  513.       }
  514.       
  515.       private function manageFrame_C08_04() : void
  516.       {
  517.          var mc:MovieClip = null;
  518.          mc = this.mainTimeline.image_holder.image;
  519.          this._engine.showImage({
  520.             "parent":mc,
  521.             "code":"PHOTO_C8_04"
  522.          });
  523.          this._engine.playComment(new CommentObject({
  524.             "code":"C08_04",
  525.             "callback":function():void
  526.             {
  527.                _engine.hideImage({
  528.                   "parent":mc,
  529.                   "code":"PHOTO_C8_04"
  530.                });
  531.                goCiel();
  532.             }
  533.          }));
  534.       }
  535.       
  536.       private function manageFrame_C12_02() : void
  537.       {
  538.          this.actualConstel.gotoAndStop("E0");
  539.          this._engine.playComment(new CommentObject({
  540.             "code":"C12_02",
  541.             "callback":this.goCiel
  542.          }));
  543.       }
  544.       
  545.       private function initPrint() : void
  546.       {
  547.          var _loc3_:MediaImage = null;
  548.          var _loc1_:MediaImageBatch = new MediaImageBatch();
  549.          var _loc2_:Array = new Array("CARTE_CIEL","MASQUE_CARTE","MODE_EMPLOI");
  550.          var _loc4_:int = 0;
  551.          while(_loc4_ < _loc2_.length)
  552.          {
  553.             _loc3_ = this._engine.getMediaImage(_loc2_[_loc4_]);
  554.             _loc1_.addMediaImage(_loc3_);
  555.             _loc4_++;
  556.          }
  557.          var _loc5_:PrintManager = PrintManager.getInstance();
  558.          var _loc6_:Sprite = new Sprite();
  559.          _loc5_.setPrintMc(this.mainTimeline);
  560.          _loc5_.printExternalImageArray(_loc1_);
  561.       }
  562.    }
  563. }
  564.