home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 160 / MOBICLIC160.ISO / pc / DATA / DSS160 / DSS160_02 / DSS160_02.swf / scripts / dss160_02 / CapsuleAlgo.as
Encoding:
Text File  |  2013-12-16  |  17.5 KB  |  517 lines

  1. package dss160_02
  2. {
  3.    import com.milanpresse.engine.*;
  4.    import com.milanpresse.engine.initmovieclip.*;
  5.    import com.milanpresse.engine.managers.*;
  6.    import com.milanpresse.engine.medias.*;
  7.    import com.milanpresse.engine.timelines.*;
  8.    import com.milanpresse.engine.typeargument.*;
  9.    import com.milanpresse.tools.GlobalesFunctions;
  10.    import flash.display.*;
  11.    import flash.geom.Point;
  12.    import flash.geom.Rectangle;
  13.    import flash.net.*;
  14.    
  15.    public class CapsuleAlgo
  16.    {
  17.       private var menu:MediaSwf;
  18.       
  19.       private var menuTimeline:MovieClip;
  20.       
  21.       private var menuTL:Timeline;
  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 _timeline_:TimelineLinear;
  32.       
  33.       private var _timelineManager:TimelineManager;
  34.       
  35.       private var _pauseManager:PauseManager;
  36.       
  37.       private var labelsCallback:Object;
  38.       
  39.       private var firstLabel:String;
  40.       
  41.       private var so:SharedObject;
  42.       
  43.       private var myMc:MovieClip;
  44.       
  45.       private var myIm:InteractiveMovie;
  46.       
  47.       private var recipientMc:MovieClip;
  48.       
  49.       private var recipientIm:InteractiveMovie;
  50.       
  51.       private var btHelpMc:MovieClip;
  52.       
  53.       private var btHelpIm:InteractiveMovie;
  54.       
  55.       private var echecIdrassMc:MovieClip;
  56.       
  57.       private var echecIdrassIm:InteractiveMovie;
  58.       
  59.       private var help1Mc:MovieClip;
  60.       
  61.       private var help1Im:InteractiveMovie;
  62.       
  63.       private var help2Mc:MovieClip;
  64.       
  65.       private var help2Im:InteractiveMovie;
  66.       
  67.       private var trappeFermeeMc:MovieClip;
  68.       
  69.       private var trappeFermeeIm:InteractiveMovie;
  70.       
  71.       private var succesMc:MovieClip;
  72.       
  73.       private var succesIm:InteractiveMovie;
  74.       
  75.       private var bloqueMc:MovieClip;
  76.       
  77.       private var activeFiole:MovieClip;
  78.       
  79.       private var countBon:int;
  80.       
  81.       private var countHelp:int;
  82.       
  83.       private var gDrag:MovieClip = null;
  84.       
  85.       public function CapsuleAlgo(engine:Engine)
  86.       {
  87.          this.labelsCallback = {};
  88.          super();
  89.          this._engine = engine;
  90.          this._engine.playMusic({"code":"MU"});
  91.          this._engine.setSubtitles(this._engine.host.subtitlesOn);
  92.          this._engine.setFrameRate(12);
  93.          this.mainClip = this._engine.showSwf({
  94.             "code":"A_" + this._engine.config.moduleName,
  95.             "parent":this._engine.config.layers["content"]
  96.          });
  97.          this.mainTimeline = this.mainClip.swfContent;
  98.          this._timelineManager = new TimelineManager();
  99.          this._timeline_ = new TimelineLinear(this.mainTimeline,this._engine,this,this._timelineManager,this.labelsCallback);
  100.          this._engine.levelCZ = this._engine.config.layers["content"];
  101.          this.so = SharedObject.getLocal(this._engine.config.rubriqueName,"/");
  102.          this.firstLabel = "WAIT_zanim00";
  103.          if(this.so.size !== 0)
  104.          {
  105.             switch(this.so.data.etatJeux[2])
  106.             {
  107.                case 0:
  108.                   this._timeline_.GotoAndPlayUntil({"labelStop":this.firstLabel});
  109.                   break;
  110.                case 1:
  111.                   this._timeline_.GotoAndPlayUntil({"labelStop":"ATTENTE_JEU_INTRO_1"});
  112.                   break;
  113.                case 2:
  114.                   this._timeline_.GotoAndPlayUntil({"labelStop":"_23"});
  115.             }
  116.          }
  117.          else
  118.          {
  119.             this._timeline_.GotoAndPlayUntil({"labelStop":this.firstLabel});
  120.          }
  121.       }
  122.       
  123.       public function labelATTENTE_JEU_INTRO_1() : void
  124.       {
  125.          this.so.data.etatJeux[2] = 1;
  126.          this.so.flush();
  127.          this._engine.showLM({
  128.             "id":"LM_TITRE",
  129.             "findModelIn":this.mainTimeline
  130.          });
  131.          this.initBTZap();
  132.          this._engine.playComment(new CommentObject({
  133.             "code":"JEU_INTRO_1",
  134.             "callback":this._timeline_.nextLabel
  135.          }));
  136.       }
  137.       
  138.       public function labelATTENTE_16() : void
  139.       {
  140.          this._engine.playComment(new CommentObject({
  141.             "code":"16",
  142.             "callback":this.stopCleo
  143.          }));
  144.          this.myMc = this.mainTimeline.anim;
  145.          this.myIm = new InteractiveMovie(this.myMc,this._timelineManager);
  146.          this.myIm.gotoAndPlayUntilTheEnd(1,this._timeline_.nextLabel);
  147.       }
  148.       
  149.       private function stopCleo() : void
  150.       {
  151.          this.myMc = this.mainTimeline.anim.TETE.BOUCHE;
  152.          this.myIm = new InteractiveMovie(this.myMc,this._timelineManager);
  153.          this.myIm.gotoAndStop(1);
  154.       }
  155.       
  156.       public function labelATTENTE() : void
  157.       {
  158.          var i:int;
  159.          this.countBon = 0;
  160.          this.bloqueMc = this.mainTimeline.BLOQUE_FIOLES;
  161.          this.bloqueMc.visible = false;
  162.          this.countHelp = 1;
  163.          for(i = 1; i <= 10; i++)
  164.          {
  165.             this.myMc = this.mainTimeline.DRAGNDROP["FIOLE_" + this.G2D(i)];
  166.             this.myIm = new InteractiveMovie(this.myMc,this._timelineManager);
  167.             this.myIm.gotoAndStop(1);
  168.             this.myIm.mc.fiole = i;
  169.             this.myIm.mc.onRollOver = function(p:Object):void
  170.             {
  171.                if(gDrag == null)
  172.                {
  173.                   _engine.changeCursor("mainO");
  174.                   _engine.showIB({
  175.                      "id":"IB_FIOLE_" + G2D(this.fiole),
  176.                      "x":this.x + 115,
  177.                      "y":this.y + 160 + 40
  178.                   });
  179.                   _engine.playNoise(new NoiseObject({"code":"B_FIOLE_ROLL"}));
  180.                }
  181.                else
  182.                {
  183.                   this.gotoAndStop("E1");
  184.                }
  185.             };
  186.             this.myIm.mc.onRollOut = function(p:Object):void
  187.             {
  188.                if(gDrag == null)
  189.                {
  190.                   _engine.changeCursor("auto");
  191.                   _engine.hideIB();
  192.                   _engine.stopNoise(new NoiseObject({"code":"B_FIOLE_ROLL"}));
  193.                }
  194.             };
  195.             this.myIm.mc.onMouseDown = function(p:Object):void
  196.             {
  197.                if(gDrag == null)
  198.                {
  199.                   gDrag = this;
  200.                   this.onCible = undefined;
  201.                   this.diffX = this.stage.mouseX - this.x;
  202.                   this.diffY = this.stage.mouseY - this.y;
  203.                   _engine.hideIB();
  204.                   _engine.stopNoise(new NoiseObject({"code":"B_FIOLE_ROLL"}));
  205.                   _engine.playNoise(new NoiseObject({"code":"B_FIOLE_CLIC"}));
  206.                   _engine.changeCursor("mainF");
  207.                }
  208.             };
  209.             this.myIm.mc.onMouseUp = function(p:Object):void
  210.             {
  211.                if(gDrag == this)
  212.                {
  213.                   bloqueMc.visible = true;
  214.                   if(Boolean(this.hitTestPoint(this.stage.mouseX,this.stage.mouseY,false)))
  215.                   {
  216.                      _engine.changeCursor("mainO");
  217.                   }
  218.                   else
  219.                   {
  220.                      _engine.changeCursor("auto");
  221.                   }
  222.                   if(this.onCible == undefined)
  223.                   {
  224.                      this.returnOrigPoint();
  225.                      _engine.playNoise(new NoiseObject({"code":"B_BACK"}));
  226.                      bloqueMc.visible = false;
  227.                      gDrag = null;
  228.                   }
  229.                   else
  230.                   {
  231.                      _engine.changeCursor("auto");
  232.                      activeFiole = this;
  233.                      this.enabled = false;
  234.                      this.BTN.visible = false;
  235.                      this.returnOrigPoint();
  236.                      this.gotoAndStop("E3");
  237.                      myMc = this.anim;
  238.                      myIm = new InteractiveMovie(myMc,_timelineManager);
  239.                      myIm.gotoAndPlayUntilTheEnd(1,suiteFiole);
  240.                   }
  241.                }
  242.             };
  243.             this.myIm.mc.onEnterFrame = function(p:Object):void
  244.             {
  245.                var tpoint:Point = null;
  246.                var myRect:Rectangle = null;
  247.                var diff:Number = NaN;
  248.                if(gDrag == this)
  249.                {
  250.                   tpoint = new Point(this.stage.mouseX,this.stage.mouseY);
  251.                   this.x = this.stage.mouseX - this.diffX;
  252.                   this.y = this.stage.mouseY - this.diffY;
  253.                   myRect = this.getBounds(_engine.config.layers["content"]);
  254.                   this.onCible = undefined;
  255.                   if(myRect.x < 0)
  256.                   {
  257.                      diff = 0 - myRect.x;
  258.                      this.x += diff;
  259.                   }
  260.                   else if(myRect.x + myRect.width > 800)
  261.                   {
  262.                      diff = myRect.x + myRect.width - 800;
  263.                      this.x -= diff;
  264.                   }
  265.                   if(myRect.y < 0)
  266.                   {
  267.                      diff = 0 - myRect.y;
  268.                      this.y += diff;
  269.                   }
  270.                   else if(myRect.y + myRect.height > 600)
  271.                   {
  272.                      diff = myRect.y + myRect.height - 600;
  273.                      this.y -= diff;
  274.                   }
  275.                   if(Boolean(mainTimeline.ZONE_DROP.hitTestPoint(tpoint.x,tpoint.y,true)))
  276.                   {
  277.                      this.onCible = true;
  278.                   }
  279.                }
  280.             };
  281.             this.myIm.activeDragAndDropMC();
  282.          }
  283.          this.recipientMc = this.mainTimeline.RECIPIENT;
  284.          this.recipientIm = new InteractiveMovie(this.recipientMc,this._timelineManager);
  285.          this.recipientIm.gotoAndStop(1);
  286.          this.btHelpMc = this.mainTimeline.BT_HELP;
  287.          this.btHelpIm = new InteractiveMovie(this.btHelpMc,this._timelineManager);
  288.          this.btHelpIm.gotoAndStop(1);
  289.          this.btHelpIm.mc.onRollOver = function(p:Object):void
  290.          {
  291.             _engine.showIB({
  292.                "id":"IB_HELP",
  293.                "x":this.x,
  294.                "y":this.y + 40
  295.             });
  296.             _engine.playNoise(new NoiseObject({"code":"B_HELP"}));
  297.          };
  298.          this.btHelpIm.mc.onRollOut = function(p:Object):void
  299.          {
  300.             _engine.hideIB();
  301.             _engine.stopNoise(new NoiseObject({"code":"B_HELP"}));
  302.          };
  303.          this.btHelpIm.mc.onPress = function(p:Object):void
  304.          {
  305.             _engine.hideIB();
  306.             _engine.stopNoise(new NoiseObject({"code":"B_HELP"}));
  307.             gereHelp();
  308.          };
  309.          this.btHelpIm.activeMC();
  310.          this.echecIdrassMc = this.mainTimeline.ECHEC_IRASS;
  311.          this.echecIdrassIm = new InteractiveMovie(this.echecIdrassMc,this._timelineManager);
  312.          this.echecIdrassIm.gotoAndStop(1);
  313.          this.echecIdrassMc.visible = false;
  314.          this.trappeFermeeMc = this.mainTimeline.TRAPPE_FERMEE;
  315.          this.trappeFermeeIm = new InteractiveMovie(this.trappeFermeeMc,this._timelineManager);
  316.          this.trappeFermeeIm.gotoAndStop(1);
  317.          this.help1Mc = this.mainTimeline.HELP_1;
  318.          this.help1Im = new InteractiveMovie(this.help1Mc,this._timelineManager);
  319.          this.help1Im.gotoAndStop(1);
  320.          this.help1Mc.visible = false;
  321.          this.help2Mc = this.mainTimeline.HELP_2;
  322.          this.help2Im = new InteractiveMovie(this.help2Mc,this._timelineManager);
  323.          this.help2Im.gotoAndStop(1);
  324.          this.help2Mc.visible = false;
  325.          this.succesMc = this.mainTimeline.SUCCES_JEU;
  326.          this.succesIm = new InteractiveMovie(this.succesMc,this._timelineManager);
  327.          this.succesIm.gotoAndStop(1);
  328.          this.succesMc.visible = false;
  329.       }
  330.       
  331.       private function suiteFiole() : void
  332.       {
  333.          this.gDrag = null;
  334.          this.activeFiole.visible = false;
  335.          if(this.activeFiole.fiole <= 3)
  336.          {
  337.             this.countBon += 1;
  338.             this.recipientIm.gotoAndStop("E2");
  339.             this._engine.playNoise(new NoiseObject({
  340.                "code":"B_RECIPIENT_E2",
  341.                "callback":this.suiteBon
  342.             }));
  343.          }
  344.          else
  345.          {
  346.             this.recipientIm.gotoAndStop("E3");
  347.             this._engine.playNoise(new NoiseObject({
  348.                "code":"B_RECIPIENT_E3",
  349.                "callback":this.suitePasBon
  350.             }));
  351.          }
  352.       }
  353.       
  354.       private function suiteBon() : void
  355.       {
  356.          if(this.countBon == 3)
  357.          {
  358.             this.so.data.etatJeux[2] = 2;
  359.             this.so.flush();
  360.             this._engine.playNoise(new NoiseObject({"code":"B_SUCCES_JEU"}));
  361.             this.trappeFermeeMc.visible = false;
  362.             this.succesMc.visible = true;
  363.             this.succesIm.gotoAndPlayUntilTheEnd(1);
  364.             this._engine.playComment(new CommentObject({
  365.                "code":"JEU_SUCCESS_IRASS",
  366.                "callback":this.suiteSucces
  367.             }));
  368.          }
  369.          else
  370.          {
  371.             this.bloqueMc.visible = false;
  372.          }
  373.          this.recipientIm.gotoAndStop("E1");
  374.       }
  375.       
  376.       private function suitePasBon() : void
  377.       {
  378.          this._timeline_.GotoAndPlayUntil({"labelStop":"_JEU_ECHEC_JEU_1"});
  379.       }
  380.       
  381.       private function suiteSucces() : void
  382.       {
  383.          this._timeline_.GotoAndPlayUntil({"labelStop":"WAIT_transition_ouvre"});
  384.       }
  385.       
  386.       private function gereHelp() : void
  387.       {
  388.          this.trappeFermeeMc.visible = false;
  389.          switch(this.countHelp)
  390.          {
  391.             case 1:
  392.                this.help1Mc.visible = true;
  393.                this.help1Im.gotoAndPlayUntilTheEnd(1);
  394.                this._engine.playComment(new CommentObject({
  395.                   "code":"JEU_HELP_1",
  396.                   "callback":this.suiteHelp
  397.                }));
  398.                break;
  399.             case 2:
  400.                this.help2Mc.visible = true;
  401.                this.help2Im.gotoAndPlayUntilTheEnd(1);
  402.                this._engine.playComment(new CommentObject({
  403.                   "code":"JEU_HELP_2",
  404.                   "callback":this.suiteHelp
  405.                }));
  406.                break;
  407.             case 3:
  408.                this.echecIdrassMc.visible = true;
  409.                this.echecIdrassIm.gotoAndPlayUntilTheEnd(1);
  410.                this._engine.playComment(new CommentObject({
  411.                   "code":"JEU_ECHEC_IRASS",
  412.                   "callback":this.suiteHelp
  413.                }));
  414.          }
  415.       }
  416.       
  417.       private function suiteHelp() : void
  418.       {
  419.          switch(this.countHelp)
  420.          {
  421.             case 1:
  422.                this.help1Mc.visible = false;
  423.                this.trappeFermeeMc.visible = true;
  424.                this.countHelp += 1;
  425.                break;
  426.             case 2:
  427.                this.help2Mc.visible = false;
  428.                this.trappeFermeeMc.visible = true;
  429.                this.countHelp += 1;
  430.                break;
  431.             case 3:
  432.                this.echecIdrassMc.visible = false;
  433.                this.trappeFermeeMc.visible = true;
  434.                this._timeline_.GotoAndPlayUntil({"labelStop":"WAIT_transition_ouvre"});
  435.          }
  436.       }
  437.       
  438.       private function initBTZap() : void
  439.       {
  440.          this.myMc = this.mainTimeline.BT_ZAP;
  441.          this.myIm = new InteractiveMovie(this.myMc,this._timelineManager);
  442.          this.myIm.gotoAndStop(1);
  443.          this.myIm.mc.onRollOver = function(p:Object):void
  444.          {
  445.             _engine.playNoise(new NoiseObject({"code":"B_ZAP"}));
  446.             _engine.showIB({
  447.                "id":"IB_ZAP",
  448.                "x":this.x,
  449.                "y":this.y + 25
  450.             });
  451.          };
  452.          this.myIm.mc.onRollOut = function(p:Object):void
  453.          {
  454.             _engine.stopNoise(new NoiseObject({"code":"B_ZAP"}));
  455.             _engine.hideIB();
  456.          };
  457.          this.myIm.mc.onPress = function(p:Object):void
  458.          {
  459.             so.data.etatJeux[2] = 2;
  460.             so.flush();
  461.             _engine.hideIB();
  462.             _engine.stopNoise(new NoiseObject({"code":"B_ZAP"}));
  463.             trappeFermeeMc.visible = false;
  464.             echecIdrassMc.visible = true;
  465.             echecIdrassIm.gotoAndPlayUntilTheEnd(1);
  466.             _engine.playComment(new CommentObject({
  467.                "code":"JEU_ECHEC_IRASS",
  468.                "callback":suiteZap
  469.             }));
  470.          };
  471.          this.myIm.activeMC();
  472.       }
  473.       
  474.       public function suiteZap() : void
  475.       {
  476.          this._timeline_.GotoAndPlayUntil({"labelStop":"WAIT_transition_ouvre"});
  477.       }
  478.       
  479.       public function G2D(value:int) : String
  480.       {
  481.          return GlobalesFunctions.gimme2digits(value);
  482.       }
  483.       
  484.       private function goNextModule() : void
  485.       {
  486.       }
  487.       
  488.       public function endMODULE() : void
  489.       {
  490.          trace("fin du module");
  491.          this.so.data.ecranEnCours = 3;
  492.          this._engine.host.changeModule({"numMod":this.so.data.ecranEnCours});
  493.       }
  494.       
  495.       public function sleep() : void
  496.       {
  497.          this._pauseManager = new PauseManager(this._engine,this._timelineManager);
  498.          this._pauseManager.sleepMovie(this.mainTimeline);
  499.       }
  500.       
  501.       public function wake() : void
  502.       {
  503.          if(this._pauseManager != null)
  504.          {
  505.             this._pauseManager.wakeMovie(this.mainTimeline);
  506.          }
  507.       }
  508.       
  509.       public function destroy() : void
  510.       {
  511.          this._engine.stopAllSounds();
  512.          this._timeline_.kilListeners();
  513.       }
  514.    }
  515. }
  516.  
  517.