home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 136 / MOBICLIC136.ISO / pc / DATA / BLA136 / BLA136_00 / BLA136_00.swf / scripts / __Packages / prod / moteur_v1_0 / V002_ChargementMedias.as < prev    next >
Text File  |  2011-07-20  |  11KB  |  266 lines

  1. class prod.moteur_v1_0.V002_ChargementMedias
  2. {
  3.    function V002_ChargementMedias(movieRoot, moduleInfo, moduleOnline)
  4.    {
  5.       this.movieRoot = movieRoot;
  6.       this.moduleInfo = moduleInfo;
  7.       if(_global.gModulePath == undefined)
  8.       {
  9.          _global.gModulePath = "";
  10.       }
  11.       if(moduleOnline == true)
  12.       {
  13.          this.movieRoot.createEmptyMovieClip("chargement",90000);
  14.          var _loc3_ = new MovieClipLoader();
  15.          _loc3_.loadClip(_global.gModulePath + this.moduleInfo.getResourceById("C_SWF_" + this.movieRoot.gModuleName).firstChild.attributes.src,this.movieRoot.chargement);
  16.          _loc3_.onLoadInit = mx.utils.Delegate.create(this,this.initChargement);
  17.       }
  18.       else
  19.       {
  20.          this.lancerPrechargement();
  21.       }
  22.    }
  23.    function initChargement()
  24.    {
  25.       this.movieRoot.debugger.text += "initChargement";
  26.       this.movieRoot.chargement._x = 0;
  27.       Stage.width / 2 - this.movieRoot.chargement._width / 2;
  28.       this.movieRoot.chargement._y = 0;
  29.       Stage.height / 2 - this.movieRoot.chargement._height / 2;
  30.       this.lancerPrechargement();
  31.    }
  32.    function lancerPrechargement()
  33.    {
  34.       this.movieRoot.createEmptyMovieClip("photoStocker",100);
  35.       this.movieRoot.createEmptyMovieClip("swfStocker",150);
  36.       this.MediaAChargeNode = this.moduleInfo.filterNode(this.moduleInfo.returnNodeByPath("Resources.ResourcesZip"),"preload","true");
  37.       var _loc4_ = new Array();
  38.       this.photoMovies = new Array();
  39.       this.swfMovies = new Array();
  40.       this.soundObjectList = new Array();
  41.       this.soundObjects = new Object();
  42.       this.swfChargeant = false;
  43.       this.jpgChargeant = false;
  44.       this.pngChargeant = false;
  45.       this.soundChargeant = false;
  46.       this.tempBytesLoaded = 0;
  47.       this.totalBytesToLoad = 0;
  48.       this.positionChargeur = 10;
  49.       this.mediaTypes.push("Avant type test");
  50.       var _loc3_ = 0;
  51.       while(_loc3_ < this.MediaAChargeNode.childNodes.length)
  52.       {
  53.          switch(this.MediaAChargeNode.childNodes[_loc3_].attributes.type)
  54.          {
  55.             case "png":
  56.                this.pngChargeant = true;
  57.                this.photoMovies.push(this.movieRoot.photoStocker.createEmptyMovieClip(this.MediaAChargeNode.childNodes[_loc3_].attributes.id,_loc3_));
  58.                this.movieRoot.photoStocker[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]._visible = false;
  59.                _loc4_[_loc3_] = new MovieClipLoader();
  60.                _loc4_[_loc3_].onLoadInit = mx.utils.Delegate.create(this,this.onPngLoaded);
  61.                this.totalBytesToLoad += 1;
  62.                break;
  63.             case "jpg":
  64.                this.jpgChargeant = true;
  65.                this.photoMovies.push(this.movieRoot.photoStocker.createEmptyMovieClip(this.MediaAChargeNode.childNodes[_loc3_].attributes.id,_loc3_));
  66.                this.movieRoot.photoStocker[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]._visible = false;
  67.                _loc4_[_loc3_] = new MovieClipLoader();
  68.                _loc4_[_loc3_].onLoadInit = mx.utils.Delegate.create(this,this.onJpgLoaded);
  69.                this.totalBytesToLoad += 1;
  70.                break;
  71.             case "swf":
  72.                this.swfChargeant = true;
  73.                this.swfMovies.push(this.movieRoot.swfStocker.createEmptyMovieClip(this.MediaAChargeNode.childNodes[_loc3_].attributes.id,_loc3_));
  74.                this.movieRoot.swfStocker[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]._x = 0;
  75.                _loc4_[_loc3_] = new MovieClipLoader();
  76.                _loc4_[_loc3_].onLoadInit = mx.utils.Delegate.create(this,this.onSwfLoaded);
  77.                this.totalBytesToLoad += 1;
  78.                break;
  79.             case "mp3":
  80.                this.soundChargeant = true;
  81.                this.soundObjects[this.MediaAChargeNode.childNodes[_loc3_].attributes.id] = new Sound();
  82.                this.soundObjectList.push(this.soundObjects[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]);
  83.                _global.GERETEXTE = this;
  84.                this.soundObjects[this.MediaAChargeNode.childNodes[_loc3_].attributes.id].NOM = this.MediaAChargeNode.childNodes[_loc3_].attributes.id;
  85.                this.soundObjects[this.MediaAChargeNode.childNodes[_loc3_].attributes.id].onLoad = function(success)
  86.                {
  87.                   _global.GERETEXTE.onSoundLoaded(this,success);
  88.                };
  89.                this.totalBytesToLoad += 1;
  90.                break;
  91.             case "interface":
  92.                this.swfChargeant = true;
  93.                this.movieRoot.createEmptyMovieClip("Interface",15600);
  94.                this.swfMovies.push(this.movieRoot.Interface.createEmptyMovieClip(this.MediaAChargeNode.childNodes[_loc3_].attributes.id,_loc3_));
  95.                this.movieRoot.Interface[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]._x = 0;
  96.                _loc4_[_loc3_] = new MovieClipLoader();
  97.                _loc4_[_loc3_].onLoadInit = mx.utils.Delegate.create(this,this.onSwfLoaded);
  98.                this.totalBytesToLoad += 1;
  99.          }
  100.          _loc3_ = _loc3_ + 1;
  101.       }
  102.       this.mediaTypes = new Array();
  103.       if(this.swfChargeant)
  104.       {
  105.          this.mediaTypes.push("swfChargeant");
  106.       }
  107.       if(this.soundChargeant)
  108.       {
  109.          this.mediaTypes.push("soundChargeant");
  110.       }
  111.       if(this.jpgChargeant)
  112.       {
  113.          this.mediaTypes.push("jpgChargeant");
  114.       }
  115.       if(this.pngChargeant)
  116.       {
  117.          this.mediaTypes.push("pngChargeant");
  118.       }
  119.       _loc3_ = 0;
  120.       while(_loc3_ < this.MediaAChargeNode.childNodes.length)
  121.       {
  122.          switch(this.MediaAChargeNode.childNodes[_loc3_].attributes.type)
  123.          {
  124.             case "png":
  125.                _loc4_[_loc3_].loadClip(_global.gModulePath + this.MediaAChargeNode.childNodes[_loc3_].attributes.src,this.movieRoot.photoStocker[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]);
  126.                break;
  127.             case "jpg":
  128.                _loc4_[_loc3_].loadClip(_global.gModulePath + this.MediaAChargeNode.childNodes[_loc3_].attributes.src,this.movieRoot.photoStocker[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]);
  129.                break;
  130.             case "swf":
  131.                _loc4_[_loc3_].loadClip(_global.gModulePath + this.MediaAChargeNode.childNodes[_loc3_].attributes.src,this.movieRoot.swfStocker[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]);
  132.                break;
  133.             case "mp3":
  134.                this.soundObjects[this.MediaAChargeNode.childNodes[_loc3_].attributes.id].loadSound(_global.gModulePath + this.MediaAChargeNode.childNodes[_loc3_].attributes.src,false);
  135.                this.movieRoot.debugger.text += "mp3 deuxieme boucle : " + this.MediaAChargeNode.childNodes[_loc3_].attributes.src + "\n";
  136.                break;
  137.             case "interface":
  138.                _loc4_[_loc3_].loadClip(_global.gModulePath + this.MediaAChargeNode.childNodes[_loc3_].attributes.src,this.movieRoot.Interface[this.MediaAChargeNode.childNodes[_loc3_].attributes.id]);
  139.                break;
  140.             default:
  141.                _global.xtrace("ChargementMedias.lancerPrechargement : " + this.MediaAChargeNode.childNodes[_loc3_].attributes.type + " invalide!!!");
  142.          }
  143.          _loc3_ = _loc3_ + 1;
  144.       }
  145.    }
  146.    function onPngLoaded(mc)
  147.    {
  148.       mc._visible = false;
  149.       this.tempBytesLoaded += 1;
  150.       var _loc4_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  151.       if(_loc4_ > 0 && _loc4_ !== this.positionChargeur)
  152.       {
  153.          this.positionChargeur = _loc4_;
  154.          this.movieRoot.chargement.gotoAndPlay("pCent" + _loc4_);
  155.       }
  156.       var _loc2_ = 0;
  157.       while(_loc2_ < this.photoMovies.length)
  158.       {
  159.          this.movieRoot.debugger.text += this.photoMovies[_loc2_] + "\n";
  160.          if(this.photoMovies[_loc2_] == mc)
  161.          {
  162.             this.photoMovies.splice(_loc2_,1);
  163.          }
  164.          _loc2_ = _loc2_ + 1;
  165.       }
  166.       if(this.photoMovies.length == 0)
  167.       {
  168.          this.movieRoot.debugger.text += "allphotos png Loaded\n";
  169.          this.onAllLoaded("allphotos png have been Loaded");
  170.       }
  171.    }
  172.    function onJpgLoaded(mc)
  173.    {
  174.       mc._visible = false;
  175.       this.tempBytesLoaded += 1;
  176.       var _loc4_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  177.       if(_loc4_ > 0 && _loc4_ !== this.positionChargeur)
  178.       {
  179.          this.positionChargeur = _loc4_;
  180.          this.movieRoot.chargement.gotoAndPlay("pCent" + _loc4_);
  181.       }
  182.       var _loc2_ = 0;
  183.       while(_loc2_ < this.photoMovies.length)
  184.       {
  185.          this.movieRoot.debugger.text += this.photoMovies[_loc2_] + "\n";
  186.          if(this.photoMovies[_loc2_] == mc)
  187.          {
  188.             this.photoMovies.splice(_loc2_,1);
  189.          }
  190.          _loc2_ = _loc2_ + 1;
  191.       }
  192.       if(this.photoMovies.length == 0)
  193.       {
  194.          this.movieRoot.debugger.text += "allphotos jpg Loaded\n";
  195.          this.onAllLoaded("allphotos jpg have been Loaded");
  196.       }
  197.    }
  198.    function onSwfLoaded(mc)
  199.    {
  200.       mc._visible = false;
  201.       _global.stopIt(mc);
  202.       this.tempBytesLoaded += 1;
  203.       var _loc5_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  204.       if(_loc5_ > 0 && _loc5_ !== this.positionChargeur)
  205.       {
  206.          this.positionChargeur = _loc5_;
  207.          this.movieRoot.chargement.gotoAndPlay("pCent" + _loc5_);
  208.       }
  209.       this.movieRoot.text_test.text = String(_loc5_);
  210.       var _loc3_ = 0;
  211.       while(_loc3_ < this.swfMovies.length)
  212.       {
  213.          if(this.swfMovies[_loc3_] == mc)
  214.          {
  215.             this.swfMovies.splice(_loc3_,1);
  216.          }
  217.          _loc3_ = _loc3_ + 1;
  218.       }
  219.       if(this.swfMovies.length == 0)
  220.       {
  221.          this.movieRoot.debugger.text += "allSwfsLoaded\n";
  222.          this.onAllLoaded("allSwfs have been Loaded");
  223.       }
  224.    }
  225.    function onSoundLoaded(mc_son, success)
  226.    {
  227.       if(success)
  228.       {
  229.          this.tempBytesLoaded += 1;
  230.          var _loc3_ = Math.floor(10 - this.tempBytesLoaded / this.totalBytesToLoad * 100 / 10);
  231.          if(_loc3_ > 0 && _loc3_ !== this.positionChargeur)
  232.          {
  233.             this.positionChargeur = _loc3_;
  234.             this.movieRoot.chargement.gotoAndPlay("pCent" + _loc3_);
  235.          }
  236.          this.soundObjectList.splice(0,1);
  237.       }
  238.       else
  239.       {
  240.          _global.xtrace("Problem avec chargement le Son " + mc_son.NOM);
  241.       }
  242.       if(this.soundObjectList.length == 0)
  243.       {
  244.          this.movieRoot.debugger.text += "allsoundsLoaded\n";
  245.          this.onAllLoaded("allsounds have been Loaded");
  246.       }
  247.    }
  248.    function onAllLoaded(msg)
  249.    {
  250.       _global.xtrace(msg);
  251.       this.movieRoot.debugger.text += "onAllLoaded" + msg + "\n";
  252.       this.mediaTypes.splice(0,1);
  253.       if(this.mediaTypes.length == 0)
  254.       {
  255.          this.movieRoot.chargement._visible = false;
  256.          this.movieRoot.debugger.text += "allLoaded\n";
  257.          _global.xtrace("allMediaLoaded");
  258.          this.movieRoot.mediaLoaded();
  259.       }
  260.    }
  261.    function returnSoundObject()
  262.    {
  263.       return this.soundObjects;
  264.    }
  265. }
  266.