A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How to load multiple video files at once ?

  1. #1
    Junior Member
    Join Date
    Jul 2003
    Location
    India
    Posts
    3

    How to load multiple video files at once ?

    I' m building a flash based quiz game. Choosing a right or wrong answer plays a flash video file. There are a total of 9 such video files - each 20 secs long.

    Can I load all these video files right at the start, before the game loads ? It is very frustrating to click on an answer and wait for a few seconds while the video plays.

    /Thanks for your time
    Life is Fun !

  2. #2
    Senior Member layerburn's Avatar
    Join Date
    Jul 2006
    Location
    USA
    Posts
    542
    I came across this code once, but have never gotten it to work right, maybe you can get it to work.

    Code:
    Multiple Preloader with x movies loaded to targets
    Simply put all your movies to load and the corresponding 
    targets in the array moviearray. Remember: If you don\'t 
    want the loaded clips to start immediatly after beeing 
    loaded, you have to place a stop action in the first 
    frame of the movie.
    
    frame 1: 
    //provide a list with all your movies to load and the targets to load into
    moviearray = new Array("movie1.swf","target1","movie2.swf","target2","movie3.swf","target3");
    //set the index of the first movie to load
    actMovieIdx = 0;
    
    frame 2:
    // get the next moviename and level
    moviename = moviearray[actMovieIdx++];
    movietarget = moviearray[actMovieIdx++];
    // load the given movie
    loadMovie(moviename, movietarget);
    
    frame 3:
    // nothing in here
    
    frame 4:
    //get the actual loaded bytes
    actBytes = eval(movietarget).getBytesLoaded() || 0;
    // get the total bytes to load
    totBytes = eval(movietarget).getBytesTotal() || 100;
    // calculate the percentage loaded
    percent  = Math.round(actBytes * 100 / totBytes);
    
    if( totBytes - actBytes > 10){//more bytes available, keep on loading
    	gotoAndPlay(3);
    } else if(actMovieIdx < moviearray.length){//if we got more movies to load	
    	gotoAndPlay(2);	
    } // else go to frame 5
    
    frame 5:
    // ready, go - here starts your movie
    OR

    I preload my videos as external flvs, this seems to loads very quickly. Look up "playing back flv externally" and "preloading flv" in the flash help files to see how to do it. I think this works very well. So use the code from the "preloading flv" help file and put individually for each movie on the corresponding frames and u should have no problem.
    This is your brain. This is your brain on script.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center