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

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