home *** CD-ROM | disk | FTP | other *** search
/ T-Online 6 / T-Online.iso / Animation / content / intro / intro.swf / scripts / __Packages / application / ui / PicLoader.as < prev   
Encoding:
Text File  |  2005-10-20  |  1.7 KB  |  58 lines

  1. class application.ui.PicLoader extends MovieClip
  2. {
  3.    var instCounter;
  4.    var align;
  5.    var height;
  6.    var width;
  7.    var pic;
  8.    var onEnterFrame;
  9.    function PicLoader()
  10.    {
  11.       super();
  12.       this.instCounter = 1;
  13.    }
  14.    function loadPic(picture, width, height, align)
  15.    {
  16.       this.align = align;
  17.       this.height = height;
  18.       this.width = width;
  19.       this.pic = this.createEmptyMovieClip("pic",this.instCounter++);
  20.       if(picture != null)
  21.       {
  22.          this.pic.loadMovie(picture);
  23.          this.onEnterFrame = function()
  24.          {
  25.             if(this.pic.getBytesLoaded() > 10 && this.pic.getBytesLoaded() >= this.pic.getBytesTotal() && this.pic._currentframe >= 1)
  26.             {
  27.                if(this.pic._width > this.width)
  28.                {
  29.                   this.pic._width = this.width;
  30.                   this.pic._yscale = this.pic._xscale;
  31.                }
  32.                if(this.pic._height > this.height)
  33.                {
  34.                   this.pic._height = this.height;
  35.                   this.pic._xscale = this.pic._yscale;
  36.                }
  37.                switch(this.align)
  38.                {
  39.                   case "right":
  40.                      this.pic._x = int(this.width - this.pic._width);
  41.                      break;
  42.                   case "center":
  43.                      this.pic._x = int((this.width - this.pic._width) / 2);
  44.                }
  45.                if(this.pic._width <= this.width && this.pic._height <= this.height)
  46.                {
  47.                   this.onEnterFrame = null;
  48.                }
  49.             }
  50.          };
  51.       }
  52.       else
  53.       {
  54.          this.pic.unloadMovie();
  55.       }
  56.    }
  57. }
  58.