home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 August / Chip_2004-08_cd2.bin / avid_dvfree / prezentace / XpressStudioNAB2004.swf / scripts / frame_1 / DoAction.as
Text File  |  2004-06-29  |  15KB  |  439 lines

  1. this.numFIS = new Array(755,725,728,2);
  2. this.baseName = "Avid Xpress Studio_";
  3. this.numSlices = 4;
  4. this.numFPS = 15;
  5. smartLoader_c = function()
  6. {
  7. };
  8. smartLoader_c.prototype = new Object();
  9. Object.registerClass("smartLoader_c",smartLoader_c);
  10. smartLoader_c.prototype.playNextMovie = function()
  11. {
  12.    if(this.playBuff.length > 0)
  13.    {
  14.       this.waitingToPlay = false;
  15.       this.lastPlayObj = this.playObj;
  16.       this.playObj = this.playBuff.shift();
  17.       if(this.playObj.sliceNum == this.numSlices - 1)
  18.       {
  19.          if(this.playObj.movieClip._totalframes <= this.targetPlayFrame)
  20.          {
  21.             this.targetPlayFrame = this.playObj.movieClip._totalframes - 1;
  22.          }
  23.       }
  24.       if(this.playObj.movieClip._framesloaded >= this.targetPlayFrame)
  25.       {
  26.          if(this.lastPlayObj != undefined)
  27.          {
  28.             this.loadBuff.push(this.lastPlayObj);
  29.          }
  30.          this.lastplayObj.movieClip._visible = false;
  31.          this.playObj.movieClip._visible = true;
  32.          this.parentThis.smMovieClip._alpha = 100;
  33.          if(this.hasSetPosition == false)
  34.          {
  35.             this.xPos = - this.parentThis.smMovieClip._width / 2;
  36.             this.yPos = - this.parentThis.smMovieClip._height / 2;
  37.             this.hasSetPosition = true;
  38.          }
  39.          this.playObj.movieClip.gotoAndStop(this.targetPlayFrame);
  40.          this.playObj.movieClip._x = this.xPos;
  41.          this.playObj.movieClip._y = this.yPos;
  42.          if(this.playing)
  43.          {
  44.             this.playObj.movieClip.play();
  45.          }
  46.          this.targetPlayFrame = 2;
  47.       }
  48.       else if(this.playObj.movieClip._totalframes > this.targetPlayFrame)
  49.       {
  50.          this.playBuff.push(this.playObj);
  51.          this.playObj = this.lastPlayObj;
  52.          this.waitingToPlay = true;
  53.       }
  54.       else
  55.       {
  56.          this.targetPlayFrame = this.targetPlayFrame - this.playObj.movieClip._totalframes + 2;
  57.          this.loadBuff.push(this.playObj);
  58.          this.playObj = this.lastPlayObj;
  59.          this.waitingToPlay = true;
  60.       }
  61.    }
  62.    else if(this.playObj.sliceNum == this.numSlices - 1)
  63.    {
  64.       if(this.playObj.movieClip._currentframe == 2)
  65.       {
  66.          this.waitingToPlay = true;
  67.       }
  68.       else
  69.       {
  70.          this.playObj.movieClip.gotoAndStop(this.playObj.movieClip._totalframes - 1);
  71.          this.waitingToPlay = false;
  72.       }
  73.    }
  74.    else
  75.    {
  76.       this.waitingToPlay = true;
  77.    }
  78. };
  79. smartLoader_c.prototype.preloadMovie = function()
  80. {
  81.    if(!this.settingLoadParameters)
  82.    {
  83.       if(!this.loading)
  84.       {
  85.          if(this.loadBuff.length > 0 && this.sliceToLoad < this.numSlices)
  86.          {
  87.             this.loading = true;
  88.             this.parentThis.smMovieClip.loadMovieActive = false;
  89.             this.lastLoadReady = false;
  90.             this.loadedName = this.baseName + this.sliceToLoad + ".swf";
  91.             this.loadObj = this.loadBuff.pop();
  92.             this.movieName = this.loadObj.movieClip._name;
  93.             this.movieDepth = this.loadObj.movieClip.getDepth();
  94.             this.loadObj.movieClip.removeMovieClip();
  95.             this.parentThis.smMovieClip.createEmptyMovieClip(this.movieName,this.movieDepth);
  96.             delete this.loadObj.movieClip;
  97.             this.loadObj.movieClip = this.parentThis.smMovieClip[this.movieName];
  98.             this.loadObj.movieClip.loadMovie(this.loadedName);
  99.             this.loadObj.sliceNum = this.sliceToLoad;
  100.             this.startloadtime = getTimer();
  101.             this.sliceToLoad = this.sliceToLoad + 1;
  102.          }
  103.       }
  104.       if(this.loadObj.movieClip._framesloaded > 1 && this.parentThis.smMovieClip.loadMovieActive)
  105.       {
  106.          if(this.loadObj.movieClip.getBytesLoaded() != 0)
  107.          {
  108.             if(this.loadObj.movieClip.getBytesLoaded() < this.loadObj.movieClip.getBytesTotal())
  109.             {
  110.                if(this.loadObj.movieClip._currentframe > 0)
  111.                {
  112.                   if(this.loadObj.movieClip.getBytesLoaded() > 32768)
  113.                   {
  114.                      var timeTotal = this.loadObj.movieClip._totalframes / this.fps;
  115.                      var bytesPerSec = this.loadObj.movieClip.getBytesLoaded() * 1000 / (getTimer() - this.startloadtime);
  116.                      var timeToFinish = (this.loadObj.movieClip.getBytesTotal() - this.loadObj.movieClip.getBytesLoaded()) / bytesPerSec + 5;
  117.                      if(timeTotal >= timeToFinish)
  118.                      {
  119.                         if(this.lastLoadReady == false)
  120.                         {
  121.                            if(this.skipFrames < 0)
  122.                            {
  123.                               this.targetPlayFrame = this.loadObj.movieClip._totalframes + this.skipFrames - 1;
  124.                               if(this.targetPlayFrame > 1)
  125.                               {
  126.                                  this.skipFrames = 0;
  127.                                  this.loadObj.movieClip._visible = false;
  128.                                  this.playBuff.push(this.loadObj);
  129.                                  this.lastLoadReady = true;
  130.                               }
  131.                            }
  132.                            else
  133.                            {
  134.                               this.playBuff.push(this.loadObj);
  135.                               this.lastLoadReady = true;
  136.                            }
  137.                         }
  138.                      }
  139.                   }
  140.                }
  141.             }
  142.             else
  143.             {
  144.                if(this.lastLoadReady == false)
  145.                {
  146.                   if(this.skipFrames < 0)
  147.                   {
  148.                      this.targetPlayFrame = this.loadObj.movieClip._totalframes + this.skipFrames;
  149.                      if(this.targetPlayFrame > 1)
  150.                      {
  151.                         this.skipFrames = 0;
  152.                         this.playBuff.push(this.loadObj);
  153.                      }
  154.                      else
  155.                      {
  156.                         this.sliceToLoad = this.loadObj.sliceNum - 1;
  157.                         if(this.sliceToLoad < 0)
  158.                         {
  159.                            this.sliceToLoad = 0;
  160.                            this.skipFrames = 0;
  161.                            this.targetPlayFrame = 2;
  162.                            this.playBuff.push(this.loadObj);
  163.                         }
  164.                         else
  165.                         {
  166.                            this.skipFrames = this.targetPlayFrame - 2;
  167.                            this.loadBuff.push(this.loadObj);
  168.                         }
  169.                      }
  170.                   }
  171.                   else
  172.                   {
  173.                      this.loadObj.movieClip._visible = false;
  174.                      this.playBuff.push(this.loadObj);
  175.                   }
  176.                   this.lastLoadReady = true;
  177.                }
  178.                this.loading = false;
  179.             }
  180.          }
  181.       }
  182.       if(this.waitingToPlay && this.playBuff.length > 0)
  183.       {
  184.          this.playNextMovie();
  185.       }
  186.    }
  187. };
  188. smartLoader_c.prototype.gotoStart = function()
  189. {
  190.    this.settingLoadParameters = true;
  191.    if(this.playObj.sliceNum == 0)
  192.    {
  193.       this.playObj.movieClip.stop();
  194.       if(this.playing)
  195.       {
  196.          this.targetPlayFrame = 2;
  197.          this.playObj.movieClip.gotoAndPlay(2);
  198.       }
  199.       else
  200.       {
  201.          this.targetPlayFrame = 2;
  202.          this.playObj.movieClip.gotoAndStop(2);
  203.       }
  204.    }
  205.    else
  206.    {
  207.       if(this.playObj != undefined)
  208.       {
  209.          this.playObj.movieClip.stop();
  210.          this.loadBuff.push(this.playObj);
  211.          while(this.playBuff.length > 0)
  212.          {
  213.             this.playObj = this.playBuff.shift();
  214.             this.loadBuff.push(this.playObj);
  215.          }
  216.          this.playObj = undefined;
  217.       }
  218.       this.waitingToPlay = true;
  219.       this.sliceToLoad = 0;
  220.       if(this.loading)
  221.       {
  222.          this.loadBuff.push(this.loadObj);
  223.          this.loading = false;
  224.       }
  225.       this.targetPlayFrame = 2;
  226.    }
  227.    this.settingLoadParameters = false;
  228. };
  229. smartLoader_c.prototype.gotoEnd = function()
  230. {
  231.    this.settingLoadParameters = true;
  232.    if(this.playObj.sliceNum == this.numSlices - 1)
  233.    {
  234.       this.targetPlayFrame = 2;
  235.       this.playObj.movieClip.gotoAndStop(this.playObj.movieClip._totalframes - 1);
  236.    }
  237.    else
  238.    {
  239.       if(this.playObj != undefined)
  240.       {
  241.          this.playObj.movieClip.stop();
  242.          while(this.playBuff.length > 0)
  243.          {
  244.             nextObj = this.playBuff.shift();
  245.             if(nextObj.sliceNum == this.numSlices - 1)
  246.             {
  247.                this.playBuff.push(nextObj);
  248.                this.targetPlayFrame = nextObj.movieClip._totalframes - 1;
  249.                this.sliceToLoad = this.numSlices;
  250.                break;
  251.             }
  252.             this.loadBuff.push(nextObj);
  253.          }
  254.       }
  255.       this.waitingToPlay = true;
  256.       if(this.playBuff.length == 0)
  257.       {
  258.          this.sliceToLoad = this.numSlices - 1;
  259.          if(this.loading)
  260.          {
  261.             if(this.loadObj.sliceNum != this.numSlices - 1)
  262.             {
  263.                this.loadBuff.push(this.loadObj);
  264.                this.loading = false;
  265.             }
  266.          }
  267.          this.targetPlayFrame = 99999;
  268.       }
  269.    }
  270.    this.settingLoadParameters = false;
  271. };
  272. smartLoader_c.prototype.fastForward = function(numFrames)
  273. {
  274.    this.settingLoadParameters = true;
  275.    if(this.playObj != undefined)
  276.    {
  277.       this.playObj.movieClip.stop();
  278.       if(this.playObj.movieClip._totalframes - numFrames > this.playObj.movieClip._currentframe)
  279.       {
  280.          frameNumber = this.playObj.movieClip._currentframe + numFrames;
  281.          this.targetPlayFrame = 2;
  282.          if(this.playing)
  283.          {
  284.             this.playObj.movieClip.gotoAndPlay(this.playObj.movieClip._currentframe + numFrames);
  285.          }
  286.          else
  287.          {
  288.             this.playObj.movieClip.gotoAndStop(this.playObj.movieClip._currentframe + numFrames);
  289.          }
  290.       }
  291.       else if(this.playObj.sliceNum == this.numSlices - 1)
  292.       {
  293.          frameNumber = this.playObj.movieClip._totalframes - 1;
  294.          this.targetPlayFrame = 2;
  295.          this.playObj.movieClip.gotoAndStop(this.playObj.movieClip._totalframes - 1);
  296.       }
  297.       else
  298.       {
  299.          this.targetPlayFrame = this.playObj.movieClip._currentframe + numFrames - this.playObj.movieClip._totalframes + 2;
  300.          this.playNextMovie();
  301.       }
  302.    }
  303.    else
  304.    {
  305.       this.targetPlayFrame = numFrames + 1;
  306.    }
  307.    this.settingLoadParameters = false;
  308. };
  309. smartLoader_c.prototype.moviePlay = function()
  310. {
  311.    this.playing = true;
  312.    this.playObj.movieClip.play();
  313. };
  314. smartLoader_c.prototype.movieStop = function()
  315. {
  316.    this.playing = false;
  317.    this.playObj.movieClip.stop();
  318. };
  319. smartLoader_c.prototype.getTotalFrames = function()
  320. {
  321.    return this.totalFrames;
  322. };
  323. smartLoader_c.prototype.getCurrentFrame = function()
  324. {
  325.    var cFrame;
  326.    cFrame = this.playObj.movieClip._currentframe - 1;
  327.    cFrame += this.prevFrames[this.playObj.sliceNum];
  328.    if(cFrame < 0)
  329.    {
  330.       cFrame = 0;
  331.    }
  332.    return cFrame;
  333. };
  334. smartLoader_c.prototype.rewind = function(numFrames)
  335. {
  336.    this.settingLoadParameters = true;
  337.    if(this.playObj != undefined)
  338.    {
  339.       this.playObj.movieClip.stop();
  340.       if(this.playObj.movieClip._currentframe > numFrames + 1)
  341.       {
  342.          frameNumber = this.playObj.movieClip._currentframe - numFrames;
  343.          if(this.playing)
  344.          {
  345.             this.playObj.movieClip.gotoAndPlay(this.playObj.movieClip._currentframe - numFrames);
  346.          }
  347.          else
  348.          {
  349.             this.playObj.movieClip.gotoAndStop(this.playObj.movieClip._currentframe - numFrames);
  350.          }
  351.       }
  352.       else if(this.playObj.sliceNum == 0)
  353.       {
  354.          if(this.playing)
  355.          {
  356.             this.playObj.movieClip.gotoAndPlay(2);
  357.          }
  358.          else
  359.          {
  360.             this.playObj.movieClip.gotoAndStop(2);
  361.          }
  362.       }
  363.       else
  364.       {
  365.          this.targetPlayFrame = 2;
  366.          this.skipFrames = this.playObj.movieClip._currentframe - numFrames - 2;
  367.          this.sliceToLoad = this.playObj.sliceNum - 1;
  368.          while(this.playBuff.length > 0)
  369.          {
  370.             nextObj = this.playBuff.shift();
  371.             this.loadBuff.push(nextObj);
  372.          }
  373.          this.waitingToPlay = true;
  374.          if(this.loading)
  375.          {
  376.             this.loadBuff.push(this.loadObj);
  377.             this.loading = false;
  378.          }
  379.       }
  380.    }
  381.    else
  382.    {
  383.       this.targetPlayFrame = 2;
  384.    }
  385.    this.settingLoadParameters = false;
  386. };
  387. smartLoader_c.prototype.playMovie = function(parentThis)
  388. {
  389.    var lastIndex = parentThis.smMovieClip._url.lastIndexOf("/");
  390.    var lastBSIndex = parentThis.smMovieClip._url.lastIndexOf("\\");
  391.    if(lastIndex < lastBSIndex)
  392.    {
  393.       lastIndex = lastBSIndex;
  394.    }
  395.    lastIndex += 1;
  396.    this.baseName = parentThis.smMovieClip._url.slice(0,lastIndex);
  397.    this.baseName += parentThis.baseName;
  398.    this.loading = false;
  399.    this.fps = Number(parentThis.fps);
  400.    this.numSlices = parentThis.numSlices;
  401.    this.parentThis = parentThis;
  402.    this.loadBuff = new Array();
  403.    this.playBuff = new Array();
  404.    this.waitingToPlay = true;
  405.    this.playing = true;
  406.    this.sliceToLoad = 0;
  407.    this.targetPlayFrame = 2;
  408.    this.skipFrames = 0;
  409.    this.rewinding = false;
  410.    this.hasSetPosition = false;
  411.    i = 0;
  412.    while(i < 3)
  413.    {
  414.       parentThis.smMovieClip.createEmptyMovieClip("Movie_" + i,parentThis.smMovieClip.getDepth() + i + 1);
  415.       tmpObject = new Object();
  416.       tmpObject.movieClip = parentThis.smMovieClip["Movie_" + i];
  417.       tmpObject.sliceNum = -1;
  418.       tmpObject.depth = tmpObject.movieClip.getDepth();
  419.       this.loadBuff.push(tmpObject);
  420.       i++;
  421.    }
  422.    this.prevFrames = new array(this.numslices);
  423.    this.prevFrames[0] = 0;
  424.    i = 1;
  425.    while(i < this.numSlices)
  426.    {
  427.       this.prevFrames[i] = this.prevFrames[i - 1] + parentThis.numFIS[i - 1] - 2;
  428.       i++;
  429.    }
  430.    this.totalFrames = this.prevFrames[this.numSlices - 1] + parentThis.numFIS[this.numSlices - 1] - 2;
  431.    this.settingLoadParameters = false;
  432.    this.preloadMovie();
  433.    this.intervalref = setInterval(this,"preloadMovie",200);
  434. };
  435. delete this.smartLoader;
  436. this.smartLoader = new this.smartLoader_c();
  437. this.smartLoader.playMovie(this);
  438. stop();
  439.