11 Replies Latest reply on Sep 28, 2006 9:16 AM by kglad

    Preloader that changes external swfs every 5 seconds


      I've done an web banner in flash that loads an external swf and changes for another external swf after 5 seconds. The banner have a preloader, but the problem becomes when it loads the first time. As the swfs aren't cached in the browser's cache yet, the time for 5 seconds starts to count from the preloader, and when the external swf finally shows, only rest 1 second and it is changed to another. There is a way to "freeze" the time for each external swf until it totally loads?

      The code that loads the swfs every 5 seconds (this code is placed into an action layer):

      begin of code:

      var intervalId:Number;
      var count:Number = 0;
      var maxCount:Number = 23;
      var duration:Number = 0;
      var banners:Array = new Array(

      function executeCallback(param:String) {
      var duration:Number = 5000;

      if(count < maxCount) {
      count++ ;
      intervalId = setInterval(this, "executeCallback", duration, banners[count]);
      else {
      intervalId = setInterval(this, "executeCallback", duration, banners[count]);

      if(intervalId != null) {

      intervalId = setInterval(this, "executeCallback", duration, banners[count]);

      //end of code

      And the code for the preloader (this code I place into the movieclip that loads the external swfs):

      //begin of code:

      onClipEvent(enterFrame) {
      var gtT:Number = this.getBytesTotal();
      var gtL:Number = this.getBytesLoaded();
      var gtP:Number = int((gtL/gtT)*100);
      if ( gtT > gtL ) {
      this._alpha = 0;
      _root.loader._alpha = 100;
      _root.loader.bar._width = gtP;
      } else {
      this._alpha = 100;
      _root.loader._alpha = 0;
      intervalId = setInterval(this, "executeCallback", duration, banners[count]);
      delete onEnterFrame;

      //end of code

      Note that I tryed to freeze the time using a clearInterval in the second code, but it simply don't works...

      Any Ideas? Thanks