How do I prevent a pause in my preloader as a result of scripted sounds from the library?
For the longest time I had problems in Flash when I was using sounds. Like I discussed in an earlier topic here on the blog, I prefer to dynamically call all sounds from the library because that gives me the most control in timing in my movies. If you don’t know how to make a sound available to be called, check out this article from August.
The problem with calling those sounds is how they are loaded. When you go into the library, right click a sound instance and choose “Linkage” > “Export for Actionscript” by default, the dialog box also checks the “Export in first frame” option. So what this means is when you are writing your preloading script that is returning all of the byte information when it gets loaded, there will a long delay and then it will show up on screen with a good portion of the movie loaded. The desired effect would be for the user to see the preloader load from the beginning, from 1% loaded as it were.

Because we are checking this “Export in first frame” option, the sound actually loads before the first frame, and loads before anything else can happen. This is true with any object, from images to other symbols, that are set up for actionscript. That can potentially be a ton of information that needs to load before you can start “loading” the rest of the movie.
Well, this is how you prevent that.
Usually the preloaders that I create are movie clips that tell the main timeline to stop playing, and this movie clip is located on frame 1 of the timeline.

When the whole movie has loaded, I then tell the preloader “gotoAndPlay(”start”)” which usually also happens to be frame “2″ where the movie starts. If we want to use linkage on sounds, but don’t want to check the “Export in first frame” option, the sound has to be on the timline somewhere. This can become confusing when it comes to movie clips if you are going to drag them off of the viewable area, but with sounds it is really easy.
Look at the image above. I actually have a layer called Sound. You will also notice there is a music note looking thing in the second frame. If I extended that empty keyframe out farther you would be able to see that this is the sound I want to use located directly on the timeline.
“But the sound will start playing when the playhead rolls over it” you say. Not if you set the “sync event” to “none”. In order to do this;

1. Click the sound on the timeline.
2. Look down in your property inspector for the sync drop down box.
3. Set the sync box to stop.
4. At any time call on your sound in the movie and it will work just like you had exported it in the first frame.
The beauty of this is that when you are using your preloader, the sound size will be included in the total movie size since it is on the stage, even though it is set to “stop” and will be loaded with the rest of the movie.
I hope this fixes any problems you may have with delays in the start of your preloaders, and the preloaders starting up half way through the process. Use my contact page if you have any additional questions.
Here are some similar arcade posts
- Tutorial for how to use the “attachSound” method in Flash
- What is a pin script in Flash MX 2004?
- How do I validate my .html for xhtml when it has Flash in it? What is the Satay method?
- How do I change the symbol timeline from a movie clip to a button?
- 12th December 2004
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.











Comments
No comments yet.
Leave a comment