home *** CD-ROM | disk | FTP | other *** search
/ Champak 108 / jogo-disk-108.iso / Games / blob_wars.swf / scripts / DefineSprite_13 / frame_2 / DoAction.as
Text File  |  2010-05-15  |  3KB  |  96 lines

  1. if(gLoading)
  2. {
  3.    loadedBytes = _parent.getBytesLoaded();
  4.    loadedSize = formatBytes(loadedBytes);
  5.    loadedFrames = _parent._framesLoaded;
  6.    gCurrentTime = getTimer();
  7.    var elapsedMinutes = Math.floor((gCurrentTime - gStartTime) / 1000 / 60);
  8.    var elapsedSeconds = Math.floor((gCurrentTime - gStartTime) / 1000 % 60);
  9.    if(String(elapsedSeconds).length == 1)
  10.    {
  11.       elapsedSeconds = "0" + elapsedSeconds;
  12.    }
  13.    elapsedTime = elapsedMinutes + ":" + elapsedSeconds;
  14.    frameCounter++;
  15.    if(gCurrentTime - gStartTime >= gSampleTimer + 1000)
  16.    {
  17.       framesPerSecond = frameCounter;
  18.       frameCounter = 0;
  19.       bytesPerSecond = loadedBytes - gSizeSample;
  20.       sizePerSecond = formatBytes(bytesPerSecond);
  21.       if(STREAM && PLAY_TYPE == "auto")
  22.       {
  23.          if(loadedFrames / framesPerSecond > (totalBytes - loadedBytes) / bytesPerSecond)
  24.          {
  25.             _parent.play();
  26.          }
  27.       }
  28.       var estimatedMinutes = Math.floor(totalBytes / bytesPerSecond / 60);
  29.       var estimatedSeconds = Math.floor(totalBytes / bytesPerSecond % 60);
  30.       if(String(estimatedSeconds).length == 1)
  31.       {
  32.          estimatedSeconds = "0" + estimatedSeconds;
  33.       }
  34.       estimatedTime = estimatedMinutes + ":" + estimatedSeconds;
  35.       var estimatedMinutesLeft = Math.floor((totalBytes - loadedBytes) / bytesPerSecond / 60);
  36.       var estimatedSecondsLeft = Math.floor((totalBytes - loadedBytes) / bytesPerSecond % 60);
  37.       if(String(estimatedSecondsLeft).length == 1)
  38.       {
  39.          estimatedSecondsLeft = "0" + estimatedSecondsLeft;
  40.       }
  41.       estimatedTimeLeft = estimatedMinutesLeft + ":" + estimatedSecondsLeft;
  42.       gSizeSample = loadedBytes;
  43.       gSampleTimer = gCurrentTime - gStartTime;
  44.    }
  45.    fractionLoaded = loadedBytes / totalBytes;
  46.    percentLoaded = Math.floor(fractionLoaded * 100) + "%";
  47.    if(STREAM)
  48.    {
  49.       switch(PLAY_TYPE)
  50.       {
  51.          case "bytes":
  52.             if(loadedBytes >= PLAY_BYTES)
  53.             {
  54.                if(!gPlaying)
  55.                {
  56.                   _parent.play();
  57.                   gPlaying = true;
  58.                }
  59.             }
  60.             break;
  61.          case "frames":
  62.             if(loadedFrames >= PLAY_FRAMES)
  63.             {
  64.                if(!gPlaying)
  65.                {
  66.                   _parent.play();
  67.                   gPlaying = true;
  68.                }
  69.             }
  70.             break;
  71.          case "percent":
  72.             if(fractionLoaded * 100 >= PLAY_PERCENT)
  73.             {
  74.                if(!gPlaying)
  75.                {
  76.                   _parent.play();
  77.                   gPlaying = true;
  78.                }
  79.             }
  80.       }
  81.    }
  82.    if(loadedBytes == totalBytes)
  83.    {
  84.       isLoaded = true;
  85.    }
  86.    if(isLoaded)
  87.    {
  88.       if(!STREAM)
  89.       {
  90.          _parent.play();
  91.       }
  92.       gLoading = false;
  93.       stop();
  94.    }
  95. }
  96.