First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: FlashGuru | Website: http://www.flashguru.co.uk

Now for the preloader:

Inside of your main movie, create a new movieclip and place it on the frame that you want your sound to start loading,from your library. Select the movieclip on the main timeline and right-click, choose actions, then copy and paste this script into the actions window:

 percentdisplay=percentloaded + "%"
 if(percentloaded == 100 && !initialized){ 

The above movieclip when loaded will now attempt to load the swf file named "sound.swf" into level one(_level1). The movieclip then loops everyframe(onclipEvent(enterFrame)) and checks to see if the sound movie has fully loaded, we do this by using two commands, the first is getBytesLoaded() which returns the number of bytes which have loaded for the specified movieclip and the second is getBytesTotal() which returns the total size of the specified movieclip. We then turn these values into a percentage and check to see if the percentage is equal to one hundered(100). If it is one hundred(100) then we call our function on the main timeline of level one (_level1 the level into which we loaded our movie) ashte movie is fully loaded. This function only wants to be called once when the movie is first found to be fully loaded so we use a simple boolean to determine whether we have already called the function, this is the code that says "!initialized" which basically means in english "if not initialized" then call the function, when the function is called we then set the value of initialized to be true therefore the function will not be called again from this movieclip:


Now inside of this movieclip if you want to display the precentage of the movie loaded simply create a new textfield, right-click choose panels>text options and check the dynamic text box, now in the variablename field enter "percentdisplay". If you dont want to display a petcentage then remove the line which says:

 percentdisplay=percentloaded + "%"

You can obviously display the number of bytes loaded etc.. by adding the correct code inside of the onClipEvent(enterFrame) parantheses. Also inside of this movieclip you should create your loading sound animation which will play only while the sound.swf file is loading, this is easily accomplished by setting the visiblity of the movieclip to zero when the sound.swf file has loaded:

So there it is the sound will now preload as and when you want it to and then play!

» Level Intermediate

Added: 2001-02-08
Rating: 8 Votes: 100
(10 being the highest)
» Author
No details available
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.