home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / shell.swf / scripts / __Packages / com / util / PreLoader.as < prev   
Text File  |  2007-10-16  |  4KB  |  119 lines

  1. class com.util.PreLoader extends com.event.observable
  2. {
  3.    function PreLoader(_mcOwner)
  4.    {
  5.       var _loc1_ = this;
  6.       super();
  7.       _loc1_.mcLoaderChild = new MovieClip();
  8.       _loc1_.mcLoader = new MovieClip();
  9.       _loc1_.mcTargetDraw = _mcOwner;
  10.    }
  11.    function loadMovieClip(_mcTarget, _strText)
  12.    {
  13.       var _loc1_ = this;
  14.       _loc1_.objTarget = _mcTarget;
  15.       _loc1_.drawPreLoader(_strText);
  16.       _loc1_.mcTargetDraw.objRef = _loc1_;
  17.       _loc1_.mcTargetDraw.blnLoaded = false;
  18.       _loc1_.mcTargetDraw.onEnterFrame = function()
  19.       {
  20.          var _loc1_ = this;
  21.          if(_loc1_.blnLoaded == true)
  22.          {
  23.             trace(":::::");
  24.             _loc1_.blnLoaded = false;
  25.             delete _loc1_.onEnterFrame;
  26.             _loc1_.objRef.destroyPreLoader();
  27.             _loc1_.objRef.broadcastEvent("PreloaderUpdate");
  28.          }
  29.          else
  30.          {
  31.             _loc1_.objRef.checkProgress();
  32.          }
  33.       };
  34.    }
  35.    function checkProgress()
  36.    {
  37.       this.updatePreLoader();
  38.    }
  39.    function loadXML(_objXML)
  40.    {
  41.       var _loc1_ = this;
  42.       _loc1_.objTarget = _objXML;
  43.       _loc1_.mcTargetDraw.objRef = _loc1_;
  44.       _loc1_.mcTargetDraw.blnLoaded = false;
  45.       _loc1_.mcTargetDraw.onEnterFrame = function()
  46.       {
  47.          var _loc1_ = this;
  48.          if(_loc1_.blnLoaded == true)
  49.          {
  50.             trace(":::::");
  51.             _loc1_.objRef.broadcastEvent("PreloaderUpdate");
  52.             _loc1_.objRef.destroyPreLoader();
  53.             delete _loc1_.onEnterFrame;
  54.          }
  55.          else
  56.          {
  57.             _loc1_.objRef.checkProgress();
  58.          }
  59.       };
  60.    }
  61.    function drawPreLoader(_strTxt)
  62.    {
  63.       this.mcLoader = this.mcTargetDraw.createEmptyMovieClip("mcLoadBar",1000000);
  64.       this.mcLoader._x = Stage.width / 2 - 50;
  65.       this.mcLoader._y = Stage.height / 2 - 5;
  66.       with(this.mcLoader)
  67.       {
  68.          beginFill(16777215,0);
  69.          lineStyle(1,13421772,100);
  70.          moveTo(0,0);
  71.          lineTo(100,0);
  72.          lineTo(100,6);
  73.          lineTo(0,6);
  74.          endFill();
  75.       }
  76.       this.mcLoaderChild = this.mcLoader.createEmptyMovieClip("mcLine",0);
  77.       with(this.mcLoaderChild)
  78.       {
  79.          beginFill(16711680);
  80.          moveTo(0,2);
  81.          lineTo(3,2);
  82.          lineTo(3,5);
  83.          lineTo(0,5);
  84.          endFill();
  85.       }
  86.       this.mcTextLoader = this.mcTargetDraw.createEmptyMovieClip("mcLoadBar",1000005);
  87.       this.mcTextLoader.createTextField("txt_percent",4,this.mcLoader._x,this.mcLoader._y + 10,200,100);
  88.       var objTF = new TextFormat();
  89.       objTF.bold = false;
  90.       objTF.font = "Verdana";
  91.       objTF.size = 9;
  92.       objTF.color = 13421772;
  93.       this.mcTextLoader.txt_percent.setNewTextFormat(objTF);
  94.       this.mcTextLoader.txt_percent.text = _strTxt;
  95.    }
  96.    function setPreLoaderParent(mcParent)
  97.    {
  98.    }
  99.    function updatePreLoader()
  100.    {
  101.       var _loc1_ = this;
  102.       _loc1_.mcLoaderChild._width = _loc1_.loadedPercent();
  103.       if(_loc1_.loadedPercent() >= 100 && _loc1_.objTarget.getBytesTotal() > 0)
  104.       {
  105.          _loc1_.mcLoaderChild._width = 100;
  106.          _loc1_.mcTargetDraw.blnLoaded = true;
  107.       }
  108.    }
  109.    function loadedPercent()
  110.    {
  111.       return Number(this.objTarget.getBytesLoaded() / this.objTarget.getBytesTotal() * 100);
  112.    }
  113.    function destroyPreLoader()
  114.    {
  115.       removeMovieClip(this.mcLoader);
  116.       removeMovieClip(this.mcTextLoader);
  117.    }
  118. }
  119.