help with my preloader

  • yessir
  • Born
  • Born
  • yessir
  • Posts: 1

Post 3+ Months Ago

I have a project where we have about 6 swf files (each about 500KB-3.32MB) needed to play one after another and to avoid any loading time.

My questions is, is there a way to load a swf in the background while one is playing?

Here's an example.

files: intro.swf, ny.swf, dc.swf, retail.swf, mart.swf, development.swf

What I would like to happen is only load intro.swf initially, and play that file,
then while that files is playing, load ny.swf in the background so it will be ready to smoothly play after intro.swf is done.

then while ny.swf is playing, we have dc.swf load in the background, and play after ny.swf is done playing.

Is there a way to accomplish this?

Thank You for any assistance.

Code: [ Select ]
// preloader script
var allBytesTotal:Number;
var allBytesLoaded:Number;
_global.whichClip = 0;
_global.clipsCompleted = false;

top_layer._visible = false;
var ClipFlag:Array = Array(6);

// number of clips were loading to keep the flags ..
//used to make sure we just load up the bytes once

this.createEmptyMovieClip("img_mc1", 999);
this.createEmptyMovieClip("img_mc2", this.getNextHighestDepth());
this.createEmptyMovieClip("img_mc3", this.getNextHighestDepth());
this.createEmptyMovieClip("img_mc4", this.getNextHighestDepth());
this.createEmptyMovieClip("img_mc5", this.getNextHighestDepth());
this.createEmptyMovieClip("img_mc6", this.getNextHighestDepth());

var my_mcl:MovieClipLoader = new MovieClipLoader();
var my_mc2:MovieClipLoader = new MovieClipLoader();
var my_mc3:MovieClipLoader = new MovieClipLoader();
var my_mc4:MovieClipLoader = new MovieClipLoader();
var my_mc5:MovieClipLoader = new MovieClipLoader();
var my_mc6:MovieClipLoader = new MovieClipLoader();

_global.numOfClips = 6;

// Create listener object:
var mclListener:Object = new Object();
mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String, status:Number) {
 trace("Error loading image: " + errorCode + " [" + status + "]");
};

mclListener.onLoadStart = function(target_mc:MovieClip):Void { 
target_mc._visible = false;
};


mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
  var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
    target_mc._visible = false;

};

mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void {
trace("onLoadComplete: " + target_mc);
_global.whichClip++;
  
      if (target_mc == img_mc1) {
         _root.loadMovie("intro.swf");
        }

    if (_global.whichClip == _global.numOfClips) {
        trace("ok..");
        target_mc._visible = false;
        trace("ok..");
        _global.clipsCompleted = true;
    }
};

my_mcl.addListener(mclListener);
my_mc2.addListener(mclListener);
my_mc3.addListener(mclListener);
my_mc4.addListener(mclListener);
my_mc5.addListener(mclListener);
my_mc6.addListener(mclListener);

my_mcl.loadClip("intro.swf", img_mc1);
my_mc2.loadClip("ny.swf", img_mc2);
my_mc3.loadClip("dc.swf", img_mc3);
my_mc4.loadClip("retail.swf", img_mc4);
my_mc5.loadClip("mart.swf", img_mc5);
my_mc6.loadClip("development.swf", img_mc6);

onEnterFrame = function(){
    if(_global.clipsCompleted) {
    trace ("ok");
    }
}


this.stop();
stop();
  1. // preloader script
  2. var allBytesTotal:Number;
  3. var allBytesLoaded:Number;
  4. _global.whichClip = 0;
  5. _global.clipsCompleted = false;
  6. top_layer._visible = false;
  7. var ClipFlag:Array = Array(6);
  8. // number of clips were loading to keep the flags ..
  9. //used to make sure we just load up the bytes once
  10. this.createEmptyMovieClip("img_mc1", 999);
  11. this.createEmptyMovieClip("img_mc2", this.getNextHighestDepth());
  12. this.createEmptyMovieClip("img_mc3", this.getNextHighestDepth());
  13. this.createEmptyMovieClip("img_mc4", this.getNextHighestDepth());
  14. this.createEmptyMovieClip("img_mc5", this.getNextHighestDepth());
  15. this.createEmptyMovieClip("img_mc6", this.getNextHighestDepth());
  16. var my_mcl:MovieClipLoader = new MovieClipLoader();
  17. var my_mc2:MovieClipLoader = new MovieClipLoader();
  18. var my_mc3:MovieClipLoader = new MovieClipLoader();
  19. var my_mc4:MovieClipLoader = new MovieClipLoader();
  20. var my_mc5:MovieClipLoader = new MovieClipLoader();
  21. var my_mc6:MovieClipLoader = new MovieClipLoader();
  22. _global.numOfClips = 6;
  23. // Create listener object:
  24. var mclListener:Object = new Object();
  25. mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String, status:Number) {
  26.  trace("Error loading image: " + errorCode + " [" + status + "]");
  27. };
  28. mclListener.onLoadStart = function(target_mc:MovieClip):Void { 
  29. target_mc._visible = false;
  30. };
  31. mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
  32.   var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
  33.     target_mc._visible = false;
  34. };
  35. mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void {
  36. trace("onLoadComplete: " + target_mc);
  37. _global.whichClip++;
  38.   
  39.       if (target_mc == img_mc1) {
  40.          _root.loadMovie("intro.swf");
  41.         }
  42.     if (_global.whichClip == _global.numOfClips) {
  43.         trace("ok..");
  44.         target_mc._visible = false;
  45.         trace("ok..");
  46.         _global.clipsCompleted = true;
  47.     }
  48. };
  49. my_mcl.addListener(mclListener);
  50. my_mc2.addListener(mclListener);
  51. my_mc3.addListener(mclListener);
  52. my_mc4.addListener(mclListener);
  53. my_mc5.addListener(mclListener);
  54. my_mc6.addListener(mclListener);
  55. my_mcl.loadClip("intro.swf", img_mc1);
  56. my_mc2.loadClip("ny.swf", img_mc2);
  57. my_mc3.loadClip("dc.swf", img_mc3);
  58. my_mc4.loadClip("retail.swf", img_mc4);
  59. my_mc5.loadClip("mart.swf", img_mc5);
  60. my_mc6.loadClip("development.swf", img_mc6);
  61. onEnterFrame = function(){
  62.     if(_global.clipsCompleted) {
  63.     trace ("ok");
  64.     }
  65. }
  66. this.stop();
  67. stop();
[/code]
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

as soon as you load a swf it is cached even if it doesn't display on the stage. The easy way to do what you want is simply have a container off the stage that you load the next clip into. You won't see it on the stage while the other clip loads but you'll be able to access it quickly because its in the cache for when you need it.

I seem to remember another caching trick that didn't actually load the content to the stage but I can't seem to find it right now. It was sort of a loadMovie hack. Maybe someone else knows what I'm talking about.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.