home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 148 / MOBICLIC148.ISO / mac / DATA / DSS148 / DSS148_00 / DSS148_00.swf / scripts / dss148 / Commun.as next >
Text File  |  2012-10-16  |  18KB  |  435 lines

  1. package dss148
  2. {
  3.    import com.milanpresse.engine.Engine;
  4.    import com.milanpresse.engine.timelines.TimelineLinear;
  5.    import com.milanpresse.engineaddons.facades.EngineExt;
  6.    import com.milanpresse.engineaddons.initdisplayobject.ExtendedClip;
  7.    import com.milanpresse.engineaddons.labelstypes.Attente2;
  8.    import com.milanpresse.tools.GlobalesFunctions;
  9.    import flash.display.MovieClip;
  10.    import flash.text.TextField;
  11.    
  12.    public class Commun
  13.    {
  14.        
  15.       
  16.       private var _engine:Engine;
  17.       
  18.       private var _e:EngineExt;
  19.       
  20.       private var _w;
  21.       
  22.       public var memo:Memo;
  23.       
  24.       private var codesTriches:Array;
  25.       
  26.       public var trichCodeCallback:Function = null;
  27.       
  28.       private var ecranChoix:ExtendedClip;
  29.       
  30.       private var ecranCode:ExtendedClip;
  31.       
  32.       private var ecranInterface:ExtendedClip;
  33.       
  34.       private var pouvoirOuvre:ExtendedClip;
  35.       
  36.       public var trichCodeVisible:Boolean = false;
  37.       
  38.       private var numFails:int = 0;
  39.       
  40.       public function Commun(param1:Engine)
  41.       {
  42.          this.codesTriches = ["TITANIC","SOLEIL","RASCAR","POSEIDON"];
  43.          super();
  44.          this._engine = param1;
  45.          this.memo = new Memo(this._engine);
  46.       }
  47.       
  48.       public function init(param1:*) : void
  49.       {
  50.          var world:* = param1;
  51.          this._w = world;
  52.          this._e = new EngineExt(this._engine,this._w._timelineManager);
  53.          var interfaceCommune:MovieClip = this._engine.showSwf({
  54.             "id":"_INTERFACE_COMMUNE_",
  55.             "parent":this._engine.config.layers["menu"]
  56.          }).swfContent;
  57.          interfaceCommune.CADRE.visible = false;
  58.          this.ecranInterface = new ExtendedClip(interfaceCommune,this._e);
  59.          this.ecranInterface.movie.mouseChildren = true;
  60.          this.ecranInterface.movie.useHandCursor = false;
  61.          this.ecranInterface.visible = false;
  62.          this.ecranInterface.attente = new Attente2(this._e);
  63.          this._e.instanceToDestroyAdd(this.ecranInterface.attente);
  64.          this.ecranInterface.attente.buttons = [];
  65.          var buttons:Array = [];
  66.          buttons.push({
  67.             "clip":this.ecranInterface.getChildByName("BT_SOS") as MovieClip,
  68.             "onRollOverState":{
  69.                "label":"E2",
  70.                "noiseCode":"B_SOS"
  71.             }
  72.          });
  73.          this.ecranInterface.attente.buttons = buttons;
  74.          this.ecranInterface.attente.getButton("BT_SOS").onRollOver = function():void
  75.          {
  76.             trichCodeVisible = true;
  77.             _w.sleep();
  78.          };
  79.          this.ecranInterface.attente.getButton("BT_SOS").onRollOut = function():void
  80.          {
  81.             trichCodeVisible = false;
  82.             _w.wake();
  83.          };
  84.          this.ecranInterface.attente.onClick = function(param1:String, param2:* = null):void
  85.          {
  86.             switch(param1)
  87.             {
  88.                case "BT_SOS":
  89.                   ecranInterface.attente.getButton("BT_SOS").enabled = false;
  90.                   ecranInterface.attente.getButton("BT_SOS").visible = false;
  91.                   ecranCode.visible = true;
  92.                   trichCodeVisible = true;
  93.                   _e.soundPlay({
  94.                      "id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01",
  95.                      "autoDetectType":false
  96.                   });
  97.             }
  98.          };
  99.          var ecran_code:MovieClip = this._engine.showSwf({
  100.             "id":"_FENETRE_CODE_",
  101.             "parent":this._engine.config.layers["menu"]
  102.          }).swfContent;
  103.          this.ecranCode = new ExtendedClip(ecran_code,this._e);
  104.          this.ecranCode.gotoAndStop("ATTENTE");
  105.          this.ecranCode.movie.mouseChildren = true;
  106.          this.ecranCode.movie.useHandCursor = false;
  107.          this.ecranCode.visible = false;
  108.          this.ecranCode.movie.CADRE.visible = false;
  109.          this.ecranCode.attente = new Attente2(this._e);
  110.          this._e.instanceToDestroyAdd(this.ecranCode.attente);
  111.          this.ecranCode.attente.buttons = [];
  112.          buttons = [];
  113.          buttons.push({
  114.             "clip":this.ecranCode.getChildByName("BT_CROIX") as MovieClip,
  115.             "onRollOverState":{
  116.                "label":"E2",
  117.                "noiseCode":"B_SOS"
  118.             }
  119.          });
  120.          buttons.push({
  121.             "clip":this.ecranCode.getChildByName("BT_VALIDE") as MovieClip,
  122.             "onRollOverState":{
  123.                "label":"E2",
  124.                "noiseCode":"B_SOS"
  125.             }
  126.          });
  127.          buttons.push({
  128.             "clip":this.ecranCode.getChildByName("LM_TITRE_02") as MovieClip,
  129.             "onRollOverState":{
  130.                "label":"E2",
  131.                "noiseCode":"B_SOS"
  132.             }
  133.          });
  134.          this.ecranCode.attente.buttons = buttons;
  135.          this.ecranCode.attente.onClick = function(param1:String, param2:* = null):void
  136.          {
  137.             var name:String = param1;
  138.             var data:* = param2;
  139.             switch(name)
  140.             {
  141.                case "BT_CROIX":
  142.                   ecranCode.visible = false;
  143.                   trichCodeVisible = false;
  144.                   _w.wake();
  145.                   _engine.stopSound({"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01"});
  146.                   ecranInterface.attente.getButton("BT_SOS").enabled = true;
  147.                   ecranInterface.attente.getButton("BT_SOS").visible = true;
  148.                   break;
  149.                case "BT_VALIDE":
  150.                   if((ecranCode.movie.CODE_TEXT as TextField).text.toUpperCase() == codesTriches[_e.config.moduleNum - 1])
  151.                   {
  152.                      _engine.stopSound({"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01"});
  153.                      _e.noisePlay({
  154.                         "code":"B_VALIDE",
  155.                         "callback":function():void
  156.                         {
  157.                            ecranCode.visible = false;
  158.                            _w.wake();
  159.                            trichCodeVisible = false;
  160.                            trichCodeCallback();
  161.                         }
  162.                      });
  163.                      ecranInterface.visible = false;
  164.                   }
  165.                   else
  166.                   {
  167.                      _e.noisePlay({
  168.                         "code":"B_NO",
  169.                         "callback":function():void
  170.                         {
  171.                            ecranCode.movie.CODE_TEXT.text = "";
  172.                         }
  173.                      });
  174.                   }
  175.                   break;
  176.                case "LM_TITRE_02":
  177.                   _engine.stopSound({"id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_TRI_01"});
  178.                   _e.openUrl("http://www.mobiclic.com/4-super-pouvoirs-nature/?tc=" + _e.config.moduleNum);
  179.             }
  180.          };
  181.          var ecran:MovieClip = this._engine.showSwf({
  182.             "id":"_FENETRE_CHOIX_",
  183.             "parent":this._engine.config.layers["menu"]
  184.          }).swfContent;
  185.          this.ecranChoix = new ExtendedClip(ecran,this._e);
  186.          this.ecranChoix.movie.mouseChildren = true;
  187.          this.ecranChoix.movie.useHandCursor = false;
  188.          this.ecranChoix.timeline = new TimelineLinear(ecran,this._engine,this,this._w._timelineManager,{});
  189.          this.ecranChoix.timeline.GotoAndPlayUntil({"labelStop":"ATTENTE"});
  190.          this.ecranChoix.visible = false;
  191.          var animClip:ExtendedClip = new ExtendedClip(ecran.getChildByName("ROBOT_P") as MovieClip,this._e);
  192.          animClip.gotoAndStop(1);
  193.          animClip.visible = false;
  194.          this.ecranChoix.ROBOT_P = animClip;
  195.          animClip = new ExtendedClip(ecran.getChildByName("ZONES_POUV") as MovieClip,this._e);
  196.          animClip.gotoAndStop(1);
  197.          animClip.visible = false;
  198.          animClip.movie.mouseChildren = true;
  199.          animClip.movie.useHandCursor = false;
  200.          this.ecranChoix.ZONES_POUV = animClip;
  201.          animClip = new ExtendedClip(ecran.getChildByName("LOGI_P") as MovieClip,this._e);
  202.          animClip.gotoAndStop(1);
  203.          animClip.visible = false;
  204.          this.ecranChoix.LOGI_P = animClip;
  205.          animClip = new ExtendedClip(ecran.getChildByName("LOGI_ROB_AT") as MovieClip,this._e);
  206.          animClip.gotoAndStop(1);
  207.          animClip.visible = false;
  208.          this.ecranChoix.LOGI_ROB_AT = animClip;
  209.          animClip = new ExtendedClip(ecran.getChildByName("LOGI_MONTRE") as MovieClip,this._e);
  210.          animClip.gotoAndStop(1);
  211.          animClip.visible = false;
  212.          this.ecranChoix.LOGI_MONTRE = animClip;
  213.          animClip = new ExtendedClip(ecran.getChildByName("DECORS") as MovieClip,this._e);
  214.          animClip.gotoAndStop(1);
  215.          animClip.visible = false;
  216.          this.ecranChoix.DECORS = animClip;
  217.          animClip = new ExtendedClip(ecran.getChildByName("LOGI_SUCCES") as MovieClip,this._e);
  218.          animClip.gotoAndStop(1);
  219.          animClip.visible = false;
  220.          this.ecranChoix.LOGI_SUCCES = animClip;
  221.          this.pouvoirOuvre = new ExtendedClip(ecran.getChildByName("POUVOIR_OUVRE") as MovieClip,this._e);
  222.          this.pouvoirOuvre.gotoAndStop(1);
  223.          this.pouvoirOuvre.movie.mouseChildren = true;
  224.          this.pouvoirOuvre.movie.useHandCursor = false;
  225.          this.pouvoirOuvre.visible = false;
  226.          this.ecranChoix.LOGI_ROB_AT.visible = true;
  227.          this.ecranChoix.ZONES_POUV.visible = true;
  228.          this.ecranChoix.DECORS.visible = true;
  229.          this.ecranChoix.attente = new Attente2(this._e);
  230.          this._e.instanceToDestroyAdd(this.ecranChoix.attente);
  231.          this.ecranChoix.attente.buttons = [];
  232.          buttons = [];
  233.          var i:int = 1;
  234.          while(i <= 4)
  235.          {
  236.             buttons.push({
  237.                "clip":this.ecranChoix.ZONES_POUV.getChildByName("POUV_" + GlobalesFunctions.gimme2digits(i)),
  238.                "data":i,
  239.                "onRollOverState":{
  240.                   "label":"E2",
  241.                   "noiseCode":"B_0" + i,
  242.                   "ibId":"IB_0" + i
  243.                }
  244.             });
  245.             i++;
  246.          }
  247.          this.ecranChoix.attente.buttons = buttons;
  248.          this.ecranChoix.attente.onClick = function(param1:String, param2:* = null):void
  249.          {
  250.             var name:String = param1;
  251.             var data:* = param2;
  252.             ecranChoix.attente.enabled = false;
  253.             ecranChoix.LOGI_ROB_AT.visible = false;
  254.             ecranChoix.ROBOT_P.visible = true;
  255.             ecranChoix.ROBOT_P.gotoAndPlay(1);
  256.             _e.soundPlay({
  257.                "id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_DEST_0" + data,
  258.                "callback":function():void
  259.                {
  260.                   ecranChoix.ROBOT_P.gotoAndStop(1);
  261.                   ecranChoix.ROBOT_P.visible = false;
  262.                   ecranChoix.attente.visible = false;
  263.                   ecranChoix.LOGI_MONTRE.gotoAndPlay(1,function():void
  264.                   {
  265.                      ecranChoix.LOGI_MONTRE.stop();
  266.                      _engine.host.changeModule({"numMod":data});
  267.                   });
  268.                   ecranChoix.LOGI_MONTRE.visible = true;
  269.                }
  270.             });
  271.          };
  272.       }
  273.       
  274.       public function ecranChoixShow(param1:Boolean = false) : void
  275.       {
  276.          var succes:Boolean = param1;
  277.          this.ecranChoix.DECORS.gotoAndStop("D0" + this.memo.savePoint.moduleNum);
  278.          this.ecranChoix.attente.enabled = false;
  279.          this.refresh();
  280.          this.ecranChoix.visible = true;
  281.          this.pouvoirOuvre.gotoAndPlay(1,function():void
  282.          {
  283.             pouvoirOuvre.visible = false;
  284.             pouvoirOuvre.gotoAndStop(1);
  285.             if(succes)
  286.             {
  287.                succesRetour();
  288.             }
  289.          });
  290.          this.pouvoirOuvre.visible = true;
  291.       }
  292.       
  293.       public function ecranInterfaceShow() : void
  294.       {
  295.          ++this.numFails;
  296.          if(this.numFails >= 3)
  297.          {
  298.             this.ecranInterface.visible = true;
  299.          }
  300.       }
  301.       
  302.       public function ecranCodeHide() : void
  303.       {
  304.          this.ecranCode.visible = false;
  305.          this.trichCodeVisible = false;
  306.          this._engine.stopSound({"id":"S_" + this._e.config.lang + "_" + this._e.config.rubriqueName + "_TRI_01"});
  307.          this.ecranInterface.attente.getButton("BT_SOS").enabled = true;
  308.          this.ecranInterface.attente.getButton("BT_SOS").visible = true;
  309.       }
  310.       
  311.       private function refresh() : void
  312.       {
  313.          var _loc1_:ExtendedClip = null;
  314.          var _loc2_:int = 1;
  315.          while(_loc2_ <= 4)
  316.          {
  317.             _loc1_ = this.ecranChoix.attente.buttons[_loc2_ - 1].btn as ExtendedClip;
  318.             if(this.memo.modules[_loc2_].vu)
  319.             {
  320.                _loc1_.enabled = false;
  321.                _loc1_.gotoAndStop("E4_FIXE");
  322.             }
  323.             else
  324.             {
  325.                _loc1_.gotoAndStop("E1");
  326.                _loc1_.enabled = true;
  327.             }
  328.             _loc2_++;
  329.          }
  330.       }
  331.       
  332.       private function succesRetour() : void
  333.       {
  334.          this.ecranChoix.attente.buttons[this.memo.module.no - 1].btn.enabled = false;
  335.          this.ecranChoix.attente.buttons[this.memo.module.no - 1].btn.gotoAndStop("E3");
  336.          this._e.noisePlay({
  337.             "code":"B_VALIDE",
  338.             "callback":function():void
  339.             {
  340.                if(getNbFounded() < 4)
  341.                {
  342.                   ecranChoix.LOGI_ROB_AT.visible = false;
  343.                   ecranChoix.LOGI_P.visible = true;
  344.                   ecranChoix.LOGI_P.gotoAndPlay(1);
  345.                   ecranChoix.attente.buttons[memo.module.no - 1].btn.gotoAndStop("E4");
  346.                   _e.soundPlay({
  347.                      "id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_POUV_0" + memo.module.no,
  348.                      "callback":function():void
  349.                      {
  350.                         ecranChoix.attente.buttons[memo.module.no - 1].btn.gotoAndStop("E4_FIXE");
  351.                         ecranChoix.LOGI_ROB_AT.visible = true;
  352.                         ecranChoix.LOGI_P.visible = false;
  353.                         ecranChoix.LOGI_P.gotoAndStop(1);
  354.                         _e.soundPlay({
  355.                            "id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_CHOIX_0" + getNbFounded(),
  356.                            "callback":function():void
  357.                            {
  358.                               refresh();
  359.                            }
  360.                         });
  361.                      }
  362.                   });
  363.                }
  364.                else
  365.                {
  366.                   ecranChoix.attente.buttons[memo.module.no - 1].btn.gotoAndStop("E4");
  367.                   _e.noisePlay({
  368.                      "code":"B_OK",
  369.                      "callback":function():void
  370.                      {
  371.                         ecranChoix.LOGI_P.visible = false;
  372.                         var i:* = 0;
  373.                         while(i < ecranChoix.attente.buttons.length)
  374.                         {
  375.                            ecranChoix.attente.buttons[i].btn.gotoAndStop("E5");
  376.                            i++;
  377.                         }
  378.                         _e.noisePlay({
  379.                            "code":"B_GAGNE",
  380.                            "callback":function():void
  381.                            {
  382.                               ecranChoix.LOGI_SUCCES.visible = true;
  383.                               ecranChoix.LOGI_ROB_AT.visible = false;
  384.                               var i:* = 0;
  385.                               while(i < ecranChoix.attente.buttons.length)
  386.                               {
  387.                                  ecranChoix.attente.buttons[i].btn.gotoAndStop("E5_FIXE");
  388.                                  ecranChoix.attente.buttons[i].btn.visible = false;
  389.                                  i++;
  390.                               }
  391.                               ecranChoix.LOGI_SUCCES.gotoAndPlay(1,function():void
  392.                               {
  393.                                  ecranChoix.LOGI_SUCCES.gotoAndStop(1);
  394.                               });
  395.                               _e.soundPlay({
  396.                                  "id":"S_" + _e.config.lang + "_" + _e.config.rubriqueName + "_GAGNE",
  397.                                  "callback":function():void
  398.                                  {
  399.                                     ecranChoix.LOGI_SUCCES.visible = false;
  400.                                     ecranChoix.LOGI_ROB_AT.visible = true;
  401.                                     var _loc1_:* = 0;
  402.                                     while(_loc1_ < ecranChoix.attente.buttons.length)
  403.                                     {
  404.                                        ecranChoix.attente.buttons[_loc1_].btn.visible = true;
  405.                                        _loc1_++;
  406.                                     }
  407.                                     _engine.host.changeModule({"numMod":5});
  408.                                  }
  409.                               });
  410.                            }
  411.                         });
  412.                      }
  413.                   });
  414.                }
  415.             }
  416.          });
  417.       }
  418.       
  419.       private function getNbFounded() : int
  420.       {
  421.          var _loc1_:int = 0;
  422.          var _loc2_:int = 1;
  423.          while(_loc2_ <= 4)
  424.          {
  425.             if(this.memo.modules[_loc2_].vu)
  426.             {
  427.                _loc1_++;
  428.             }
  429.             _loc2_++;
  430.          }
  431.          return _loc1_;
  432.       }
  433.    }
  434. }
  435.