home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Swf / linux.swf / scripts / __Packages / com / rightactionscript / fcb / components / Loader.as next >
Text File  |  2010-02-24  |  5KB  |  185 lines

  1. class com.rightactionscript.fcb.components.Loader extends com.rightactionscript.fcb.components.UIBasicComponent
  2. {
  3.    var _bDoFade = false;
  4.    var _bDrawFrame = false;
  5.    var _oDimensions = null;
  6.    var _nRoundCorners = 0;
  7.    var _bLoaded = false;
  8.    function Loader()
  9.    {
  10.       super();
  11.       this._bAutoLoad = true;
  12.    }
  13.    function set scaleContent(bScaleContent)
  14.    {
  15.       this._bScaleContent = bScaleContent;
  16.    }
  17.    function get scaleContent()
  18.    {
  19.       return this._bScaleContent;
  20.    }
  21.    function set autoLoad(bAutoLoad)
  22.    {
  23.       this._bAutoLoad = bAutoLoad;
  24.    }
  25.    function get autoLoad()
  26.    {
  27.       return this._bAutoLoad;
  28.    }
  29.    function set contentPath(sURL)
  30.    {
  31.       this._sURL = sURL;
  32.       if(this._bAutoLoad)
  33.       {
  34.          this.load();
  35.       }
  36.    }
  37.    function get bytesLoaded()
  38.    {
  39.       return this._nBytesLoaded;
  40.    }
  41.    function get bytesTotal()
  42.    {
  43.       return this._nBytesTotal;
  44.    }
  45.    function get percentLoaded()
  46.    {
  47.       var _loc2_ = Math.round(this.__get__bytesLoaded() / this.__get__bytesTotal() * 100);
  48.       _loc2_ = !isNaN(_loc2_) ? _loc2_ : 0;
  49.       return _loc2_;
  50.    }
  51.    function get content()
  52.    {
  53.       return this._mcHolder.mcContent;
  54.    }
  55.    function init()
  56.    {
  57.       super.init();
  58.       if(this._bScaleContent == undefined)
  59.       {
  60.          this._bScaleContent = true;
  61.       }
  62.       this._bInited = true;
  63.       this._nBytesLoaded = 0;
  64.       this._nBytesTotal = 0;
  65.    }
  66.    function createChildren()
  67.    {
  68.       this.createEmptyMovieClip("_mcHolder",this.getNextHighestDepth());
  69.       this.createEmptyMovieClip("_mcFrame",this.getNextHighestDepth());
  70.       this.createEmptyMovieClip("_mcMask",this.getNextHighestDepth());
  71.       if(this._bAutoLoad && this._sURL != undefined)
  72.       {
  73.          this.load();
  74.       }
  75.    }
  76.    function size()
  77.    {
  78.       this._xscale = 100;
  79.       this._yscale = 100;
  80.       if(this._bScaleContent)
  81.       {
  82.          var _loc5_ = this._mcHolder.mcContent._width;
  83.          var _loc4_ = this._mcHolder.mcContent._height;
  84.          var _loc2_ = _loc5_ / _loc4_;
  85.          var _loc3_ = this.__width / this.__height;
  86.          if(_loc2_ == _loc3_)
  87.          {
  88.             this._mcHolder._width = this.__width;
  89.             this._mcHolder._height = this.__height;
  90.          }
  91.          else if(_loc2_ > _loc3_)
  92.          {
  93.             this._mcHolder._width = this.__width;
  94.             this._mcHolder._height = this.__width / _loc2_;
  95.          }
  96.          else
  97.          {
  98.             this._mcHolder._width = this.__height * _loc2_;
  99.             this._mcHolder._height = this.__height;
  100.          }
  101.       }
  102.       else if(this._mcHolder.mcContent._width != undefined)
  103.       {
  104.          this._mcHolder._width = this._mcHolder.mcContent._width;
  105.          this._mcHolder._height = this._mcHolder.mcContent._height;
  106.       }
  107.    }
  108.    function load()
  109.    {
  110.       if(this._bLoading && this._sPrevURL == this._sURL || this._sURL == undefined || this._sURL == "" || this._mcHolder == undefined)
  111.       {
  112.          return undefined;
  113.       }
  114.       this._visible = false;
  115.       this._bLoaded = false;
  116.       this._bLoading = true;
  117.       this._sPrevURL = this._sURL;
  118.       this._mcHolder.mcContent.removeMovieClip();
  119.       this._mcFrame.clear();
  120.       this._mcMask.clear();
  121.       this._mcHolder.attachMovie(this._sURL,"mcContent",1);
  122.       if(this._mcHolder.mcContent == undefined)
  123.       {
  124.          this._mcHolder.mcContent.removeMovieClip();
  125.          this._mcHolder.createEmptyMovieClip("mcContent",1);
  126.          this._mcHolder.mcContent.loadMovie(this._sURL);
  127.          this._nPrevLoaded = 0;
  128.          this._nInterval = setInterval(this,"checkLoadProgress",50);
  129.       }
  130.       else
  131.       {
  132.          this.onLoadInit();
  133.       }
  134.    }
  135.    function onLoadProgress(mc, bl, bt)
  136.    {
  137.       this._nBytesLoaded = bl;
  138.       this._nBytesTotal = bt;
  139.       this.dispatchEvent({type:"progress",target:this});
  140.    }
  141.    function onLoadInit()
  142.    {
  143.       this._bLoaded = true;
  144.       this._bLoading = false;
  145.       this.size();
  146.       this._visible = true;
  147.       this.dispatchEvent({type:"complete",target:this});
  148.    }
  149.    function checkLoadProgress()
  150.    {
  151.       var _loc2_ = this._mcHolder.mcContent.getBytesLoaded();
  152.       var _loc3_ = this._mcHolder.mcContent.getBytesTotal();
  153.       if(_loc2_ > this._nPrevLoaded)
  154.       {
  155.          this.onLoadProgress(this._mcHolder.mcContent,_loc2_,_loc3_);
  156.          this._nPrevLoaded = _loc2_;
  157.       }
  158.       if(_loc2_ / _loc3_ == 1 && this._mcHolder.mcContent._width != 0)
  159.       {
  160.          this.onLoadInit();
  161.          clearInterval(this._nInterval);
  162.       }
  163.    }
  164.    function get loaded()
  165.    {
  166.       return this._bLoaded;
  167.    }
  168.    function set dimensions(oDimensions)
  169.    {
  170.       this._oDimensions = oDimensions;
  171.    }
  172.    function set drawFrame(bDrawFrame)
  173.    {
  174.       this._bDrawFrame = bDrawFrame;
  175.    }
  176.    function set doFade(bDoFade)
  177.    {
  178.       this._bDoFade = bDoFade;
  179.    }
  180.    function set roundcorners(nRoundCorners)
  181.    {
  182.       this._nRoundCorners = nRoundCorners;
  183.    }
  184. }
  185.