home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Demo / elearn / Geografie / interfata.swf / scripts / frame_1 / DoAction.as < prev   
Text File  |  2004-05-12  |  2KB  |  58 lines

  1. Object.component = new Object();
  2. Object.component.behaviour = 0;
  3. Object.Preloader = function()
  4. {
  5.    this.master = arguments.shift();
  6.    this.master.stop();
  7.    this.master.createMc("bar",0,0);
  8.    var x = this.master._width / 2 - 10;
  9.    var y = this.master._height / 2;
  10.    this.master.bar.createTextField("perc",this.master.bar.nextDepth(),x,y,20,12);
  11.    this.mytext = this.master.bar.perc;
  12.    with(this)
  13.    {
  14.       mytext.multiline = true;
  15.       mytext.wordWrap = true;
  16.       mytext.border = true;
  17.       mytext.autoSize = true;
  18.       myformat = new TextFormat();
  19.       myformat.color = 0;
  20.       myformat.bullet = false;
  21.       mytext.text = "0";
  22.       mytext.setTextFormat(myformat);
  23.    }
  24.    this.ins = arguments;
  25.    this.interval = setInterval(this,"check",120,this);
  26. };
  27. Object.Preloader.prototype.check = function()
  28. {
  29.    var part = 0;
  30.    var total = 0;
  31.    var i = 0;
  32.    while(i < this.ins.length)
  33.    {
  34.       total += this.ins[i].getBytesTotal();
  35.       part += this.ins[i].getBytesLoaded();
  36.       if(this.ins[i].getBytesLoaded() == 0)
  37.       {
  38.          return undefined;
  39.       }
  40.       i++;
  41.    }
  42.    percent = Math.ceil(part / total * 100);
  43.    this.mytext.text = part + " / " + total;
  44.    if(percent == 100)
  45.    {
  46.       removeMovieClip(this.master.bar);
  47.       clearInterval(this.interval);
  48.       this.master.play();
  49.       this.master.loadComplete(this.ins);
  50.    }
  51. };
  52. if(this.loaded == undefined)
  53. {
  54.    lib_loader.loadMovie("lib/lib_interf.swf");
  55.    var prel = new Object.Preloader(this,this,lib_loader);
  56.    this.loaded = true;
  57. }
  58.