preloading multiple swfs on one frame.

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

Is this even possible on flash?

I would like to preload multiple swf files (even wavs if possible) before even playing the clip.

A simple "loading" text would do it as an experiment.

At the moment i do a:

Code: [ Select ]
if (_framesload) {
  gotoAndplay (2);
else {
gotoAndplay (1);
  1. if (_framesload) {
  2.   gotoAndplay (2);
  3. else {
  4. gotoAndplay (1);



Not sure if thats correct but i typed in quickly.

And in the second frame are lots of blank movie clips which i use to load the external swf files in;

ie)

Code: [ Select ]
loadmovie(moviename,instancename)


When i try this on a 56k, I have the loading screen but then after i have the other parts come in at different times because its "LOADING" again when it was meant to load in first place?

ie) first comes navigation, then background , then so on.... when they are meant to be on at same time.

I have tried on broadband too and same thing happens.

All suggestions and help would be grateful. Thank you to anyone who replies.
  • stinger
  • Graduate
  • Graduate
  • stinger
  • Posts: 157
  • Loc: San Jose, CA

Post 3+ Months Ago

What I would do:

I would have a simple "loading. . . . " movie clip.

In frames 1-5 I would use this clip to display in Nav bar.
then when loaded, move to frame 6.
frames 6-10 will have "Loading. . . " for your second swf.
when loaded move to frame 11. Then
frames 11-15 will show "loading . . . "
When this is loaded, I would move to a scene/frame and play whole intro.
You will have to tell each target to play, and position them correctly.
  • emile
  • Newbie
  • Newbie
  • emile
  • Posts: 5
  • Loc: london

Post 3+ Months Ago

Code: [ Select ]

swflist = new Array("bg.swf","nav.swf","content.swf")
loadingswfNum = -1
checkLoad = false
this.createEmptyMovieClip("loadertest_mc",100)
this.createEmptyMovieClip("targetClip_mc",101)

function loadClip(){
  
    var swfNum++
   if (swfNum < swflist.length){
     var cliptoload = swflist[loadingswfNum]
     targetClip_mc.loadMovie(cliptoload )
     loadertest_mc.hasLoaded = false
     loadertest_mc.onEnterFrame = checkloadfunc
   }else{
      loadertest_mc.removeMovieClip()
      targetClip_mc.removeMovieClip()
      _root.gotoAndPlay("allclipsLoaded")
   }

}

checkloadfunc (){
    var bl = this._parent.targetClip_mc.getBytesLoaded()
    var bt = this._parent.targetClip_mc.getBytesTotal()
    var bp = int((100/bt)*bl)
    if (bp>=100 && this._parent.targetClip._width >0 && bl > 4 && hasLoaded == false ){
      hasLoaded = true
      this._parent.loadClip()
     
    }

}

loadClip()

stop()
  1. swflist = new Array("bg.swf","nav.swf","content.swf")
  2. loadingswfNum = -1
  3. checkLoad = false
  4. this.createEmptyMovieClip("loadertest_mc",100)
  5. this.createEmptyMovieClip("targetClip_mc",101)
  6. function loadClip(){
  7.   
  8.     var swfNum++
  9.    if (swfNum < swflist.length){
  10.      var cliptoload = swflist[loadingswfNum]
  11.      targetClip_mc.loadMovie(cliptoload )
  12.      loadertest_mc.hasLoaded = false
  13.      loadertest_mc.onEnterFrame = checkloadfunc
  14.    }else{
  15.       loadertest_mc.removeMovieClip()
  16.       targetClip_mc.removeMovieClip()
  17.       _root.gotoAndPlay("allclipsLoaded")
  18.    }
  19. }
  20. checkloadfunc (){
  21.     var bl = this._parent.targetClip_mc.getBytesLoaded()
  22.     var bt = this._parent.targetClip_mc.getBytesTotal()
  23.     var bp = int((100/bt)*bl)
  24.     if (bp>=100 && this._parent.targetClip._width >0 && bl > 4 && hasLoaded == false ){
  25.       hasLoaded = true
  26.       this._parent.loadClip()
  27.      
  28.     }
  29. }
  30. loadClip()
  31. stop()


put this on a say first frame.
If you want a loading animation add a movieclip with a looping anim.
if you dont want to see the content loading in then position the target_mc off stage or invisible.

loadclip will load the swfs in the array.
i create 2 empty clips. one to load the clip into and the other to check its loaded amount.

the onEnterframe function has a "if" condition that makes sure at least some of the content is loaded, that it has loaded it and also theres a check to make sure the clip has appear on stage (the _width > 0). You only really need this for jpgs if you want them 100% visible before you say mask them in or something. All you really need is

Code: [ Select ]
bp>=100 && bl > 4 && hasLoaded == false



i have the bl (bytes loaded) because sometimes bl and bt might register as 0 or undefined which can cause problems.
the hasloaded is to stop you from calling loadclip multiple times.


When all clips are loaded it will tidy up the created clips and goto whatever lable you require

Code: [ Select ]
      loadertest_mc.removeMovieClip()
      targetClip_mc.removeMovieClip()
      _root.gotoAndPlay("allclipsLoaded")
  1.       loadertest_mc.removeMovieClip()
  2.       targetClip_mc.removeMovieClip()
  3.       _root.gotoAndPlay("allclipsLoaded")




probably will need a little refining as i haven't tested it.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 5 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.