home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 155 / MOBICLIC155.ISO / mac / DATA / DSS155 / DSS155_03 / DSS155_03.swf / scripts / dss155_03 / CapsuleAlgo.as
Text File  |  2013-07-08  |  13KB  |  385 lines

  1. package dss155_03
  2. {
  3.    import com.milanpresse.engine.Engine;
  4.    import com.milanpresse.engine.initmovieclip.InteractiveMovie;
  5.    import com.milanpresse.engine.managers.PauseManager;
  6.    import com.milanpresse.engine.managers.TimelineManager;
  7.    import com.milanpresse.engine.medias.MediaSwf;
  8.    import com.milanpresse.engine.timelines.Timeline;
  9.    import com.milanpresse.engine.timelines.TimelineLinear;
  10.    import com.milanpresse.engine.typeargument.CommentObject;
  11.    import com.milanpresse.engine.typeargument.NoiseObject;
  12.    import com.milanpresse.tools.GlobalesFunctions;
  13.    import flash.display.MovieClip;
  14.    import flash.events.Event;
  15.    import flash.net.SharedObject;
  16.    
  17.    public class CapsuleAlgo
  18.    {
  19.        
  20.       
  21.       private var menu:MediaSwf;
  22.       
  23.       private var menuTimeline:MovieClip;
  24.       
  25.       private var menuTL:Timeline;
  26.       
  27.       private var mainClip:MediaSwf;
  28.       
  29.       private var mainTimeline:MovieClip;
  30.       
  31.       private var _engine:Engine;
  32.       
  33.       private var labelList:Array;
  34.       
  35.       private var _timeline_:TimelineLinear;
  36.       
  37.       private var _timelineManager:TimelineManager;
  38.       
  39.       private var _pauseManager:PauseManager;
  40.       
  41.       private var labelsCallback:Object;
  42.       
  43.       private var firstLabel:String;
  44.       
  45.       private var so:SharedObject;
  46.       
  47.       private var goLabelATTENTE:String;
  48.       
  49.       private var BT_ZAP_INTRO:InteractiveMovie;
  50.       
  51.       private var zapIntroDone:Boolean = false;
  52.       
  53.       private var gClic:int;
  54.       
  55.       private var gRoll:MovieClip;
  56.       
  57.       private var gListDone:Array;
  58.       
  59.       private var gDoneMythe:Boolean = false;
  60.       
  61.       private var gFromNumMod:int;
  62.       
  63.       public var gDrag:MovieClip = null;
  64.       
  65.       public var gListeCible:Array;
  66.       
  67.       private var playedDER_EPR:Boolean = false;
  68.       
  69.       private var F_AIDE:InteractiveMovie;
  70.       
  71.       private var gPieceSelected:MovieClip = null;
  72.       
  73.       private var gZone:int;
  74.       
  75.       private var CARTE:MovieClip;
  76.       
  77.       private var gDoneSonAT:Boolean = false;
  78.       
  79.       public function CapsuleAlgo(engine:Engine)
  80.       {
  81.          this.labelsCallback = {
  82.             "_01_07":this.testeFin,
  83.             "_02_05":this.testeFin,
  84.             "_03_06":this.testeFin,
  85.             "_04_05":this.testeFin
  86.          };
  87.          this.gListDone = [0,0,0,0];
  88.          this.gListeCible = [];
  89.          super();
  90.          this._engine = engine;
  91.          this._engine.playMusic({"code":"MU"});
  92.          this._engine.setSubtitles(this._engine.host.subtitlesOn);
  93.          this._engine.setFrameRate(24);
  94.          this.mainClip = this._engine.showSwf({
  95.             "code":"A_" + this._engine.config.moduleName,
  96.             "parent":this._engine.config.layers["content"]
  97.          });
  98.          this.mainTimeline = this.mainClip.swfContent;
  99.          this._timelineManager = new TimelineManager();
  100.          this._timeline_ = new TimelineLinear(this.mainTimeline,this._engine,this,this._timelineManager,this.labelsCallback);
  101.          this._engine.levelCZ = this._engine.config.layers["content"];
  102.          this.so = SharedObject.getLocal(this._engine.config.rubriqueName,"/");
  103.          this.so.data.gModule = this._engine.config.moduleNum;
  104.          this.so.flush();
  105.          this.firstLabel = this.mainTimeline.currentLabels[0].name;
  106.          this._timeline_.GotoAndPlayUntil({"labelStop":this.firstLabel});
  107.       }
  108.       
  109.       public function label_09() : void
  110.       {
  111.          this._engine.showImage({
  112.             "code":"PH_09",
  113.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  114.          });
  115.       }
  116.       
  117.       public function label_10() : void
  118.       {
  119.          this._engine.showImage({
  120.             "code":"PH_10",
  121.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  122.          });
  123.       }
  124.       
  125.       public function labelATTENTE_01() : void
  126.       {
  127.          var myIm:InteractiveMovie = null;
  128.          var myIm2:InteractiveMovie = null;
  129.          var myIm3:InteractiveMovie = null;
  130.          trace("gDoneSonAT : " + this.gDoneSonAT);
  131.          if(this.gDoneSonAT == false)
  132.          {
  133.             this._engine.playComment(new CommentObject({"code":"AT_00"}));
  134.             this.gDoneSonAT = true;
  135.          }
  136.          this._engine.cursorInit({
  137.             "mc":this.mainTimeline.CURSEUR_CIBLE,
  138.             "parent":this.mainTimeline
  139.          });
  140.          for(var i:int = 1; i <= 4; i++)
  141.          {
  142.             myIm = new InteractiveMovie(this.mainTimeline["ZONE_" + this.G2D(i)],this._timelineManager);
  143.             myIm2 = new InteractiveMovie(this.mainTimeline["ICONE_" + this.G2D(i)],this._timelineManager);
  144.             myIm3 = new InteractiveMovie(this.mainTimeline["LM_Z_" + this.G2D(i)],this._timelineManager);
  145.             myIm3.mc.mouseEnabled = false;
  146.             myIm2.mc.pNum = i;
  147.             myIm2.mc.onPress = function(p:Object):void
  148.             {
  149.                _engine.playNoise(new NoiseObject({"code":"B_ZONE"}));
  150.                gZone = this.pNum;
  151.                _engine.cursor.destroy();
  152.                _timeline_.GotoAndPlayUntil({"labelStop":"_" + G2D(gZone) + "_01"});
  153.             };
  154.             myIm.mc.pNum = i;
  155.             myIm.mc.mcI = myIm;
  156.             myIm.mc.icone = myIm2;
  157.             myIm.mc.LM = myIm3;
  158.             if(this.gListDone[i - 1] == 0)
  159.             {
  160.                myIm.mc.rollOverFrame = "E0";
  161.                myIm.mc.rollOutFrame = "E0";
  162.                myIm2.gotoAndStop("E0");
  163.                myIm3.gotoAndStop("E1");
  164.                myIm.mc.onPress = function(p:Object):void
  165.                {
  166.                   _engine.playNoise(new NoiseObject({"code":"B_ZONE"}));
  167.                   this.mcI.gotoAndStop("E2");
  168.                   this.rollOutFrame = "E1";
  169.                   this.rollOverFrame = "E1";
  170.                   this.icone.gotoAndStop("E1");
  171.                   this.icone.activeMC();
  172.                   this.LM.gotoAndStop("E2");
  173.                   this.kill();
  174.                   gZone = this.pNum;
  175.                   gListDone[this.pNum - 1] = 1;
  176.                   CARTE.removeEventListener(Event.ENTER_FRAME,CARTE.onEnterFrame);
  177.                   _engine.cursor.change("fleche");
  178.                   _engine.cursor.destroy();
  179.                   _engine.playComment(new CommentObject({
  180.                      "code":"AT_" + G2D(this.pNum),
  181.                      "callback":goZone
  182.                   }));
  183.                };
  184.                myIm.activeMC();
  185.             }
  186.             else
  187.             {
  188.                myIm.mc.rollOverFrame = "E2";
  189.                myIm.mc.rollOutFrame = "E1";
  190.                myIm2.gotoAndStop("E1");
  191.                myIm2.activeMC();
  192.                myIm3.gotoAndStop("E2");
  193.             }
  194.             myIm.gotoAndStop(myIm.mc.rollOutFrame);
  195.             if(this.gListDone[i - 1] == 0)
  196.             {
  197.                myIm.mc.BTN.useHandCursor = false;
  198.             }
  199.          }
  200.          this.CARTE = this.mainTimeline["CARTE"];
  201.          this.CARTE.mouseEnabled = false;
  202.          this.CARTE.onEnterFrame = function(p:Object):void
  203.          {
  204.             var pPixX:Number = NaN;
  205.             var pPixY:Number = NaN;
  206.             if(CARTE.hitTestPoint(mainTimeline.mouseX,mainTimeline.mouseY,true))
  207.             {
  208.                _engine.cursor.change("E1");
  209.                pPixX = mainTimeline.CURSEUR_CIBLE.x - CARTE.x + 250;
  210.                pPixY = mainTimeline.CURSEUR_CIBLE.y - CARTE.y + 250;
  211.                mainTimeline.CURSEUR_CIBLE.LONGITUDE.text = Math.round((117.3 - pPixX / 500) * 100) / 100 + " O";
  212.                mainTimeline.CURSEUR_CIBLE.LATITUDE.text = Math.round((37 - pPixY / 500) * 100) / 100 + " N";
  213.             }
  214.             else
  215.             {
  216.                _engine.cursor.change("fleche");
  217.             }
  218.          };
  219.          this.CARTE.addEventListener(Event.ENTER_FRAME,this.CARTE.onEnterFrame);
  220.       }
  221.       
  222.       public function testeFin() : void
  223.       {
  224.          if(this.gListDone.indexOf(0) == -1)
  225.          {
  226.             this._timeline_.GotoAndPlayUntil({"labelStop":"_F_01"});
  227.          }
  228.          else
  229.          {
  230.             this._engine.playComment(new CommentObject({
  231.                "code":this.mainTimeline.currentFrameLabel.substr(1,this.mainTimeline.currentFrameLabel.length - 1),
  232.                "callback":this.retourATTENTE_01
  233.             }));
  234.          }
  235.       }
  236.       
  237.       public function goZone() : void
  238.       {
  239.          this._timeline_.GotoAndPlayUntil({"labelStop":"_" + this.G2D(this.gZone) + "_01"});
  240.       }
  241.       
  242.       public function retourATTENTE_01() : void
  243.       {
  244.          this._timeline_.GotoAndPlayUntil({"labelStop":"ATTENTE_01"});
  245.       }
  246.       
  247.       public function label_01_04() : void
  248.       {
  249.          this._engine.showImage({
  250.             "code":"PH_01_04",
  251.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  252.          });
  253.       }
  254.       
  255.       public function label_01_06() : void
  256.       {
  257.          this._engine.showImage({
  258.             "code":"PH_01_06",
  259.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  260.          });
  261.       }
  262.       
  263.       public function label_02_04() : void
  264.       {
  265.          this._engine.showImage({
  266.             "code":"PH_02_04",
  267.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  268.          });
  269.       }
  270.       
  271.       public function label_03_02() : void
  272.       {
  273.          this._engine.showImage({
  274.             "code":"PH_03_02",
  275.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  276.          });
  277.       }
  278.       
  279.       public function label_03_05() : void
  280.       {
  281.          this._engine.showImage({
  282.             "code":"PH_03_05",
  283.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  284.          });
  285.       }
  286.       
  287.       public function label_04_02() : void
  288.       {
  289.          this._engine.showImage({
  290.             "code":"PH_04_02",
  291.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  292.          });
  293.       }
  294.       
  295.       public function label_04_04() : void
  296.       {
  297.          this._engine.showImage({
  298.             "code":"PH_04_04",
  299.             "parent":this.mainTimeline.anim.CADRE_PHOTO.PHOTO
  300.          });
  301.       }
  302.       
  303.       public function labelATTENTE_02() : void
  304.       {
  305.          var myIm:InteractiveMovie = null;
  306.          trace("labelATTENTE_02 : ");
  307.          this._engine.cursorInit({
  308.             "mc":this.mainTimeline.CURSEUR_CIBLE,
  309.             "parent":this.mainTimeline
  310.          });
  311.          myIm = new InteractiveMovie(this.mainTimeline["ZONE"],this._timelineManager);
  312.          myIm.mc.onPress = function(p:Object):void
  313.          {
  314.             this.kill();
  315.             CARTE.removeEventListener(Event.ENTER_FRAME,CARTE.onEnterFrame);
  316.             _engine.cursor.change("fleche");
  317.             _engine.cursor.destroy();
  318.             _timeline_.nextLabel();
  319.          };
  320.          myIm.activeMC();
  321.          this.CARTE = this.mainTimeline["CARTE"];
  322.          this.CARTE.mouseEnabled = false;
  323.          this.CARTE.onEnterFrame = function(p:Object):void
  324.          {
  325.             var pPixX:Number = NaN;
  326.             var pPixY:Number = NaN;
  327.             if(CARTE.hitTestPoint(mainTimeline.mouseX,mainTimeline.mouseY,true))
  328.             {
  329.                _engine.cursor.change("E1");
  330.                pPixX = mainTimeline.CURSEUR_CIBLE.x - CARTE.x + 250;
  331.                pPixY = mainTimeline.CURSEUR_CIBLE.y - CARTE.y + 250;
  332.                mainTimeline.CURSEUR_CIBLE.LONGITUDE.text = Math.round((117.3 - pPixX / 500) * 100) / 100 + " O";
  333.                mainTimeline.CURSEUR_CIBLE.LATITUDE.text = Math.round((37 - pPixY / 500) * 100) / 100 + " N";
  334.             }
  335.             else
  336.             {
  337.                _engine.cursor.change("fleche");
  338.             }
  339.          };
  340.          this.CARTE.addEventListener(Event.ENTER_FRAME,this.CARTE.onEnterFrame);
  341.       }
  342.       
  343.       public function G2D(value:int) : String
  344.       {
  345.          return GlobalesFunctions.gimme2digits(value);
  346.       }
  347.       
  348.       public function GCI(lettre:String) : int
  349.       {
  350.          return GlobalesFunctions.getCharIndex(lettre);
  351.       }
  352.       
  353.       public function GC(value:int) : String
  354.       {
  355.          return GlobalesFunctions.getChar(value);
  356.       }
  357.       
  358.       public function endMODULE() : void
  359.       {
  360.          trace("fin du module");
  361.          this._engine.host.changeModule({"numMod":4});
  362.       }
  363.       
  364.       public function sleep() : void
  365.       {
  366.          this._pauseManager = new PauseManager(this._engine,this._timelineManager);
  367.          this._pauseManager.sleepMovie(this.mainTimeline);
  368.       }
  369.       
  370.       public function wake() : void
  371.       {
  372.          if(this._pauseManager != null)
  373.          {
  374.             this._pauseManager.wakeMovie(this.mainTimeline);
  375.          }
  376.       }
  377.       
  378.       public function destroy() : void
  379.       {
  380.          this._engine.stopAllSounds();
  381.          this._timeline_.kilListeners();
  382.       }
  383.    }
  384. }
  385.