home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 136 / MOBICLIC136.ISO / pc / DATA / HOTE / prod_gen_JLM / moteur.swf / scripts / __Packages / prod / moteur / V007xb_ChargementMedias.as < prev    next >
Text File  |  2011-07-20  |  20KB  |  479 lines

  1. class prod.moteur.V007xb_ChargementMedias
  2. {
  3.    function V007xb_ChargementMedias(movieRoot, moduleInfo, moduleOnline)
  4.    {
  5.       trace("(!) ChargementMedias movieRoot: " + movieRoot + " , moduleInfo : " + moduleInfo + " , moduleOnline : " + moduleOnline + " , movieRoot.gModulePath : " + movieRoot.gModulePath);
  6.       this.movieRoot = movieRoot;
  7.       this.moduleInfo = moduleInfo;
  8.       if(movieRoot.gModulePath == undefined)
  9.       {
  10.          movieRoot.gModulePath = "";
  11.       }
  12.       if(moduleOnline == true)
  13.       {
  14.          this.movieRoot.createEmptyMovieClip("chargement",90000);
  15.          var _loc3_ = new MovieClipLoader();
  16.          _loc3_.loadClip(movieRoot.gModulePath + this.moduleInfo.getResourceById("C_SWF_" + this.movieRoot.gModuleName).firstChild.attributes.src,this.movieRoot.chargement);
  17.          _loc3_.onLoadInit = mx.utils.Delegate.create(this,this.initChargement);
  18.       }
  19.       else
  20.       {
  21.          this.lancerPrechargement();
  22.       }
  23.    }
  24.    function initChargement()
  25.    {
  26.       this.movieRoot.debugger.text += "initChargement";
  27.       this.movieRoot.chargement._x = 0;
  28.       Stage.width / 2 - this.movieRoot.chargement._width / 2;
  29.       this.movieRoot.chargement._y = 0;
  30.       Stage.height / 2 - this.movieRoot.chargement._height / 2;
  31.       this.lancerPrechargement();
  32.    }
  33.    function lancerPrechargement()
  34.    {
  35.       this.movieRoot.createEmptyMovieClip("photoStocker",100);
  36.       this.movieRoot.createEmptyMovieClip("swfStocker",150);
  37.       this.MediaAChargeNode = this.moduleInfo.filterNode(this.moduleInfo.returnNodeByPath("Resources.ResourcesZip"),"preload","true");
  38.       this.movieRoot.MediasExternes = {};
  39.       this.movieRoot.MASCOTTES_LISTE = [];
  40.       var _loc8_ = new Array();
  41.       this.photoJPGMovies = new Array();
  42.       this.photoPNGMovies = new Array();
  43.       this.swfMovies = new Array();
  44.       this.soundObjectList = new Array();
  45.       this.soundObjects = new Object();
  46.       this.swfChargeant = false;
  47.       this.jpgChargeant = false;
  48.       this.pngChargeant = false;
  49.       this.soundChargeant = false;
  50.       this.tempBytesLoaded = 0;
  51.       this.totalBytesToLoad = 0;
  52.       this.positionChargeur = 10;
  53.       this.mediaTypes.push("Avant type test");
  54.       var _loc3_ = undefined;
  55.       var _loc4_ = undefined;
  56.       var _loc6_ = undefined;
  57.       var _loc14_ = undefined;
  58.       var _loc15_ = this.MediaAChargeNode.childNodes.length;
  59.       var _loc7_ = 0;
  60.       while(_loc7_ < _loc15_)
  61.       {
  62.          _loc3_ = this.MediaAChargeNode.childNodes[_loc7_].attributes;
  63.          switch(_loc3_.type)
  64.          {
  65.             case "png":
  66.                this.pngChargeant = true;
  67.                if(_loc3_.groupe == undefined)
  68.                {
  69.                   this.photoPNGMovies.push(this.movieRoot.photoStocker.createEmptyMovieClip(_loc3_.id,this.movieRoot.chercheDepthPlus(this.movieRoot.photoStocker,0)));
  70.                   this.movieRoot.photoStocker[_loc3_.id]._visible = false;
  71.                }
  72.                else
  73.                {
  74.                   _loc4_ = this.movieRoot[_loc3_.groupe];
  75.                   if(_loc4_ == undefined)
  76.                   {
  77.                      _loc4_ = this.movieRoot.createEmptyMovieClip(_loc3_.groupe,this.movieRoot.chercheDepthPlus(this.movieRoot,200));
  78.                   }
  79.                   if(_loc4_.Medias == undefined)
  80.                   {
  81.                      _loc4_.Medias = [];
  82.                   }
  83.                   _loc6_ = _loc4_.createEmptyMovieClip(_loc3_.id,this.movieRoot.chercheDepthPlus(_loc4_,0));
  84.                   this.photoPNGMovies.push(_loc6_);
  85.                   this.movieRoot.photoStocker[_loc3_.id] = _loc6_;
  86.                   _loc6_._visible = false;
  87.                   _loc14_ = {};
  88.                   for(var _loc13_ in _loc3_)
  89.                   {
  90.                      _loc14_[_loc13_] = _loc3_[_loc13_];
  91.                   }
  92.                   _loc4_.Medias.push({mc:_loc6_,Params:_loc14_});
  93.                }
  94.                if(_loc3_.X !== undefined)
  95.                {
  96.                   this.movieRoot.photoStocker[_loc3_.id]._x = Number(_loc3_.X);
  97.                }
  98.                else
  99.                {
  100.                   this.movieRoot.photoStocker[_loc3_.id]._x = 0;
  101.                }
  102.                if(_loc3_.Y !== undefined)
  103.                {
  104.                   this.movieRoot.photoStocker[_loc3_.id]._y = Number(_loc3_.Y);
  105.                }
  106.                else
  107.                {
  108.                   this.movieRoot.photoStocker[_loc3_.id]._y = 0;
  109.                }
  110.                _loc8_[_loc7_] = new MovieClipLoader();
  111.                _loc8_[_loc7_].onLoadInit = mx.utils.Delegate.create(this,this.onPngLoaded);
  112.                this.totalBytesToLoad += 1;
  113.                break;
  114.             case "jpg":
  115.                this.jpgChargeant = true;
  116.                if(_loc3_.groupe == undefined)
  117.                {
  118.                   this.photoJPGMovies.push(this.movieRoot.photoStocker.createEmptyMovieClip(_loc3_.id,this.movieRoot.chercheDepthPlus(this.movieRoot.photoStocker,0)));
  119.                   this.movieRoot.photoStocker[_loc3_.id]._visible = false;
  120.                }
  121.                else
  122.                {
  123.                   _loc4_ = this.movieRoot[_loc3_.groupe];
  124.                   if(_loc4_ == undefined)
  125.                   {
  126.                      _loc4_ = this.movieRoot.createEmptyMovieClip(_loc3_.groupe,this.movieRoot.chercheDepthPlus(this.movieRoot,200));
  127.                   }
  128.                   if(_loc4_.Medias == undefined)
  129.                   {
  130.                      _loc4_.Medias = [];
  131.                   }
  132.                   _loc6_ = _loc4_.createEmptyMovieClip(_loc3_.id,this.movieRoot.chercheDepthPlus(_loc4_,0));
  133.                   this.photoJPGMovies.push(_loc6_);
  134.                   this.movieRoot.photoStocker[_loc3_.id] = _loc6_;
  135.                   _loc6_._visible = false;
  136.                   _loc14_ = {};
  137.                   for(_loc13_ in _loc3_)
  138.                   {
  139.                      _loc14_[_loc13_] = _loc3_[_loc13_];
  140.                   }
  141.                   _loc4_.Medias.push({mc:_loc6_,Params:_loc14_});
  142.                }
  143.                if(_loc3_.X !== undefined)
  144.                {
  145.                   this.movieRoot.photoStocker[_loc3_.id]._x = Number(_loc3_.X);
  146.                }
  147.                else
  148.                {
  149.                   this.movieRoot.photoStocker[_loc3_.id]._x = 0;
  150.                }
  151.                if(_loc3_.Y !== undefined)
  152.                {
  153.                   this.movieRoot.photoStocker[_loc3_.id]._y = Number(_loc3_.Y);
  154.                }
  155.                else
  156.                {
  157.                   this.movieRoot.photoStocker[_loc3_.id]._y = 0;
  158.                }
  159.                _loc8_[_loc7_] = new MovieClipLoader();
  160.                _loc8_[_loc7_].onLoadInit = mx.utils.Delegate.create(this,this.onJpgLoaded);
  161.                this.totalBytesToLoad += 1;
  162.                break;
  163.             case "swf":
  164.                var _loc5_ = _loc3_.id;
  165.                trace("lID : " + _loc5_);
  166.                this.swfChargeant = true;
  167.                trace("this.movieRoot.gModuleName : " + this.movieRoot.gModuleName);
  168.                if(_loc5_.indexOf("A_" + this.movieRoot.gModuleName + "_WIKI") == 0 || _loc5_.indexOf("A_" + this.movieRoot.gModuleName + "_SPAM") == 0 || _loc5_.indexOf("A_" + this.movieRoot.gModuleName + "_BUG") == 0 || _loc3_.groupe == "MASCOTTES")
  169.                {
  170.                   if(_loc5_.indexOf("A_" + this.movieRoot.gModuleName) != 0)
  171.                   {
  172.                      var _loc10_ = "MASC_" + _loc5_;
  173.                   }
  174.                   else
  175.                   {
  176.                      _loc10_ = "MASC" + _loc5_.substr(String("A_" + this.movieRoot.gModuleName).length);
  177.                   }
  178.                   _loc6_ = this.movieRoot.createEmptyMovieClip(_loc10_,this.movieRoot.chercheDepthPlus(this.movieRoot,200));
  179.                   this.movieRoot.MediasExternes[_loc10_] = {};
  180.                   this.movieRoot.MediasExternes[_loc10_].mc = _loc6_;
  181.                   this.movieRoot.MediasExternes[_loc10_].ParamsXml = {};
  182.                   for(_loc13_ in _loc3_)
  183.                   {
  184.                      this.movieRoot.MediasExternes[_loc10_].ParamsXml[_loc13_] = _loc3_[_loc13_];
  185.                   }
  186.                   _loc6_._x = 0;
  187.                   this.movieRoot.MASCOTTES_LISTE.push(_loc6_);
  188.                   this.swfMovies.push(_loc6_);
  189.                   this.movieRoot.swfStocker[_loc5_] = _loc6_;
  190.                   this.movieRoot.MediasExternes[_loc5_] = this.movieRoot.MediasExternes[_loc10_];
  191.                   if(this.movieRoot.MASCOTTES == undefined)
  192.                   {
  193.                      this.movieRoot.MASCOTTES = {};
  194.                   }
  195.                   this.movieRoot.MASCOTTES[_loc5_] = _loc6_;
  196.                   _loc4_ = this.movieRoot.swfStocker;
  197.                }
  198.                else
  199.                {
  200.                   if(_loc3_.groupe == undefined)
  201.                   {
  202.                      _loc4_ = this.movieRoot.swfStocker;
  203.                   }
  204.                   else if(this.movieRoot[_loc3_.groupe] == undefined)
  205.                   {
  206.                      _loc4_ = this.movieRoot.createEmptyMovieClip(_loc3_.groupe,this.movieRoot.chercheDepthPlus(this.movieRoot,200));
  207.                   }
  208.                   else
  209.                   {
  210.                      _loc4_ = this.movieRoot[_loc3_.groupe];
  211.                   }
  212.                   if(_loc4_.Medias == undefined)
  213.                   {
  214.                      _loc4_.Medias = [];
  215.                   }
  216.                   _loc6_ = _loc4_.createEmptyMovieClip(_loc5_,this.movieRoot.chercheDepthPlus(_loc4_,0));
  217.                   trace("!!groupe_mc : " + _loc4_);
  218.                   this.swfMovies.push(_loc6_);
  219.                   this.movieRoot.MediasExternes[_loc5_] = {};
  220.                   this.movieRoot.MediasExternes[_loc5_].mc = _loc6_;
  221.                   this.movieRoot.MediasExternes[_loc5_].ParamsXml = {};
  222.                   for(_loc13_ in _loc3_)
  223.                   {
  224.                      this.movieRoot.MediasExternes[_loc5_].ParamsXml[_loc13_] = _loc3_[_loc13_];
  225.                   }
  226.                }
  227.                if(_loc3_.groupe !== undefined)
  228.                {
  229.                   this.movieRoot.swfStocker[_loc5_] = _loc4_[_loc5_];
  230.                   trace("this.movieRoot[\"swfStocker\"][lID] : " + this.movieRoot.swfStocker[_loc5_]);
  231.                }
  232.                _loc4_.Medias.push(_loc4_[_loc5_]);
  233.                if(_loc3_.X !== undefined)
  234.                {
  235.                   this.movieRoot.swfStocker[_loc3_.id]._x = Number(_loc3_.X);
  236.                }
  237.                else
  238.                {
  239.                   this.movieRoot.swfStocker[_loc3_.id]._x = 0;
  240.                }
  241.                if(_loc3_.Y !== undefined)
  242.                {
  243.                   this.movieRoot.swfStocker[_loc3_.id]._y = Number(_loc3_.Y);
  244.                }
  245.                else
  246.                {
  247.                   this.movieRoot.swfStocker[_loc3_.id]._y = 0;
  248.                }
  249.                _loc8_[_loc7_] = new MovieClipLoader();
  250.                _loc8_[_loc7_].onLoadInit = mx.utils.Delegate.create(this,this.onSwfLoaded);
  251.                this.totalBytesToLoad += 1;
  252.                break;
  253.             case "mp3":
  254.                this.soundChargeant = true;
  255.                this.soundObjects[_loc3_.id] = new Sound();
  256.                this.soundObjectList.push(this.soundObjects[_loc3_.id]);
  257.                this.soundObjects[_loc3_.id].gereMedias = this;
  258.                this.soundObjects[_loc3_.id].NOM = _loc3_.id;
  259.                this.soundObjects[_loc3_.id].onLoad = function(success)
  260.                {
  261.                   this.gereMedias.onSoundLoaded(this,success);
  262.                };
  263.                this.totalBytesToLoad += 1;
  264.                break;
  265.             case "interface":
  266.                this.swfChargeant = true;
  267.                this.movieRoot.createEmptyMovieClip("Interface",15600);
  268.                this.swfMovies.push(this.movieRoot.Interface.createEmptyMovieClip(_loc3_.id,_loc7_));
  269.                this.movieRoot.Interface[_loc3_.id]._x = 0;
  270.                _loc8_[_loc7_] = new MovieClipLoader();
  271.                _loc8_[_loc7_].onLoadInit = mx.utils.Delegate.create(this,this.onSwfLoaded);
  272.                this.totalBytesToLoad += 1;
  273.          }
  274.          _loc7_ = _loc7_ + 1;
  275.       }
  276.       this.mediaTypes = new Array();
  277.       if(this.swfChargeant)
  278.       {
  279.          this.mediaTypes.push("swfChargeant");
  280.       }
  281.       if(this.soundChargeant)
  282.       {
  283.          this.mediaTypes.push("soundChargeant");
  284.       }
  285.       if(this.jpgChargeant)
  286.       {
  287.          this.mediaTypes.push("jpgChargeant");
  288.       }
  289.       if(this.pngChargeant)
  290.       {
  291.          this.mediaTypes.push("pngChargeant");
  292.       }
  293.       var _loc9_ = undefined;
  294.       var _loc11_ = undefined;
  295.       _loc7_ = 0;
  296.       while(_loc7_ < this.MediaAChargeNode.childNodes.length)
  297.       {
  298.          _loc9_ = this.MediaAChargeNode.childNodes[_loc7_].attributes.src;
  299.          _loc11_ = _loc9_.split("/");
  300.          var _loc0_ = null;
  301.          if((_loc0_ = _loc11_[0]) !== "DATA")
  302.          {
  303.             _loc9_ = this.movieRoot.gModulePath + _loc9_;
  304.          }
  305.          else
  306.          {
  307.             _loc9_ = _global.gDataPath + _loc11_.slice(1).join("/");
  308.          }
  309.          switch(this.MediaAChargeNode.childNodes[_loc7_].attributes.type)
  310.          {
  311.             case "png":
  312.                _loc8_[_loc7_].loadClip(_loc9_,this.movieRoot.photoStocker[this.MediaAChargeNode.childNodes[_loc7_].attributes.id]);
  313.                break;
  314.             case "jpg":
  315.                _loc8_[_loc7_].loadClip(_loc9_,this.movieRoot.photoStocker[this.MediaAChargeNode.childNodes[_loc7_].attributes.id]);
  316.                break;
  317.             case "swf":
  318.                trace("this.movieRoot[\"swfStocker\"][this.MediaAChargeNode.childNodes[i].attributes[\"id\"]] : " + this.movieRoot.swfStocker[this.MediaAChargeNode.childNodes[_loc7_].attributes.id]);
  319.                trace("this.movieRoot[\"swfStocker\"] : " + this.movieRoot.swfStocker);
  320.                trace("this.MediaAChargeNode.childNodes[i].attributes[\"id\"] : " + this.MediaAChargeNode.childNodes[_loc7_].attributes.id);
  321.                _loc8_[_loc7_].loadClip(_loc9_,this.movieRoot.swfStocker[this.MediaAChargeNode.childNodes[_loc7_].attributes.id]);
  322.                break;
  323.             case "mp3":
  324.                this.soundObjects[this.MediaAChargeNode.childNodes[_loc7_].attributes.id].loadSound(_loc9_,false);
  325.                this.movieRoot.debugger.text += "mp3 deuxieme boucle : " + this.MediaAChargeNode.childNodes[_loc7_].attributes.src + "\n";
  326.                break;
  327.             case "interface":
  328.                _loc8_[_loc7_].loadClip(_loc9_,this.movieRoot.Interface[this.MediaAChargeNode.childNodes[_loc7_].attributes.id]);
  329.                break;
  330.             default:
  331.                trace("/!\\ChargementMedias.lancerPrechargement : " + this.MediaAChargeNode.childNodes[_loc7_].attributes.type + " invalide!!!");
  332.          }
  333.          _loc7_ = _loc7_ + 1;
  334.       }
  335.    }
  336.    function onPngLoaded(mc)
  337.    {
  338.       mc._visible = false;
  339.       this.tempBytesLoaded += 1;
  340.       var _loc5_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  341.       if(_loc5_ > 0 && _loc5_ !== this.positionChargeur)
  342.       {
  343.          _global.HOTE.LoadingProgress(100 - _loc5_);
  344.          this.positionChargeur = _loc5_;
  345.          this.movieRoot.chargement.gotoAndPlay("pCent" + _loc5_);
  346.       }
  347.       var _loc3_ = 0;
  348.       while(_loc3_ < this.photoPNGMovies.length)
  349.       {
  350.          this.movieRoot.debugger.text += this.photoPNGMovies[_loc3_] + "\n";
  351.          if(this.photoPNGMovies[_loc3_] == mc)
  352.          {
  353.             this.photoPNGMovies.splice(_loc3_,1);
  354.          }
  355.          _loc3_ = _loc3_ + 1;
  356.       }
  357.       if(this.photoPNGMovies.length == 0)
  358.       {
  359.          this.movieRoot.debugger.text += "allphotos png Loaded\n";
  360.          this.onAllLoaded("allphotos png have been Loaded");
  361.       }
  362.    }
  363.    function onJpgLoaded(mc)
  364.    {
  365.       mc._visible = false;
  366.       this.tempBytesLoaded += 1;
  367.       var _loc5_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  368.       if(_loc5_ > 0 && _loc5_ !== this.positionChargeur)
  369.       {
  370.          _global.HOTE.LoadingProgress(100 - _loc5_);
  371.          this.positionChargeur = _loc5_;
  372.          this.movieRoot.chargement.gotoAndPlay("pCent" + _loc5_);
  373.       }
  374.       var _loc3_ = 0;
  375.       while(_loc3_ < this.photoJPGMovies.length)
  376.       {
  377.          this.movieRoot.debugger.text += this.photoJPGMovies[_loc3_] + "\n";
  378.          if(this.photoJPGMovies[_loc3_] == mc)
  379.          {
  380.             this.photoJPGMovies.splice(_loc3_,1);
  381.          }
  382.          _loc3_ = _loc3_ + 1;
  383.       }
  384.       if(this.photoJPGMovies.length == 0)
  385.       {
  386.          this.movieRoot.debugger.text += "allphotos jpg Loaded\n";
  387.          this.onAllLoaded("allphotos jpg have been Loaded");
  388.       }
  389.    }
  390.    function onSwfLoaded(mc)
  391.    {
  392.       mc._visible = false;
  393.       mc.ParamsXml = this.movieRoot.MediasExternes[mc._name].ParamsXml;
  394.       this.initialiseMC({mc:mc});
  395.       this.movieRoot.stopIt(mc);
  396.       this.tempBytesLoaded += 1;
  397.       var _loc5_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  398.       if(_loc5_ > 0 && _loc5_ !== this.positionChargeur)
  399.       {
  400.          _global.HOTE.LoadingProgress(100 - _loc5_);
  401.          this.positionChargeur = _loc5_;
  402.          this.movieRoot.chargement.gotoAndPlay("pCent" + _loc5_);
  403.       }
  404.       this.movieRoot.text_test.text = String(_loc5_);
  405.       var _loc3_ = 0;
  406.       while(_loc3_ < this.swfMovies.length)
  407.       {
  408.          if(this.swfMovies[_loc3_] == mc)
  409.          {
  410.             this.swfMovies.splice(_loc3_,1);
  411.          }
  412.          _loc3_ = _loc3_ + 1;
  413.       }
  414.       if(this.swfMovies.length == 0)
  415.       {
  416.          this.movieRoot.debugger.text += "allSwfsLoaded\n";
  417.          this.onAllLoaded("allSwfs have been Loaded");
  418.       }
  419.    }
  420.    function onSoundLoaded(mc_son, success)
  421.    {
  422.       if(success)
  423.       {
  424.          this.tempBytesLoaded += 1;
  425.          var _loc3_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  426.          if(_loc3_ > 0 && _loc3_ !== this.positionChargeur)
  427.          {
  428.             _global.HOTE.LoadingProgress(100 - _loc3_);
  429.             this.positionChargeur = _loc3_;
  430.             this.movieRoot.chargement.gotoAndPlay("pCent" + _loc3_);
  431.          }
  432.          this.soundObjectList.splice(0,1);
  433.       }
  434.       else
  435.       {
  436.          trace("/!\\Problem avec chargement le Son " + mc_son.NOM);
  437.       }
  438.       if(this.soundObjectList.length == 0)
  439.       {
  440.          this.movieRoot.debugger.text += "allsoundsLoaded\n";
  441.          this.onAllLoaded("allsounds have been Loaded");
  442.       }
  443.    }
  444.    function onAllLoaded(msg)
  445.    {
  446.       this.movieRoot.debugger.text += "onAllLoaded" + msg + "\n";
  447.       this.mediaTypes.splice(0,1);
  448.       if(this.mediaTypes.length == 0)
  449.       {
  450.          this.movieRoot.chargement._visible = false;
  451.          this.movieRoot.debugger.text += "allLoaded\n";
  452.          trace("(!) allMediaLoaded");
  453.          this.movieRoot.mediaLoaded();
  454.       }
  455.    }
  456.    function returnSoundObject()
  457.    {
  458.       return this.soundObjects;
  459.    }
  460.    function initialiseMC(p)
  461.    {
  462.       var _loc1_ = p.mc;
  463.       for(var _loc2_ in _loc1_.ParamsXml)
  464.       {
  465.          switch(_loc2_)
  466.          {
  467.             case "X":
  468.             case "x":
  469.                _loc1_._x = Number(_loc1_.ParamsXml[_loc2_]);
  470.                break;
  471.             case "Y":
  472.             case "y":
  473.                _loc1_._y = Number(_loc1_.ParamsXml[_loc2_]);
  474.                break;
  475.          }
  476.       }
  477.    }
  478. }
  479.