|
||||||
|
||||||
Tutorial - Preloading External Flash Movies

Free
Flash Tutorial
Step Four: Creating a Progress Bar
The progress bar is a visual representation of the percentage of the external Movie that is loading. It looks something like this:
Progress Bar.




Note: The Instance Name and Movie Clip Names are different. In the ActionScript it is always the Instance Name that is important. Remember that Instance Names are case sensitive and must not start with a number or contain spaces. The Movie Clips name can be anything you want (as long as each Movie Clip has it's own unique name). Instance Names do not need to be unique.
Cross Ref: For detailed information about how to name objects see the tutorial on: ActionScript Syntax
Progress Bar ActionScript
You now have to add some code to the Loading bar Movie Clip. What this does is control the width of the bar. So that as more of the object loads the wider bar becomes. The bars width will match the percentage. If 50% has loaded then the bar will be 50 pixels wide etc.
// When the Flash Movie loads do the following...
onClipEvent (load) {
// Call the following function
function follow(source, target, percent) {
/* Set the variable vector equal to the percentage of the content being loaded and minus current width of this Movie Clip. */
vector = (source-target);
// Set the desp variable equal to the vector variable times by the percent which is the percentage loaded
desp = (vector*percent);
// Return the amount loaded
return (source-desp);
// Reset the target value
dd.target = 0;
// Close the function
}
// Close the above Clip Event
}
// When this Movie Clip enters the frame (every 1/12th of a sec) do...
onClipEvent (enterFrame) {
// Call the function from above to reset this Movie Clip's width
this._width = follow(this._width, target, .2);
}
Note: The above code is attached directly to the outside of the Movie Clip not to the Timeline. In your Actions Panel it should say Actions - Movie Clip in the top left corner or the Actions Panel:
The Actions are attached to the Movie Clip not the Timeline.
Cross Reference: The comments in the ActionScript above are very brief and if you don't understand how the code works I suggest you look at one of the preloader tutorials where you will find a more in-depth explanation as to how preloaders work: Preloaders or Preloader Listings
|
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
50114 visitors to this page since
6 Oct 05 •
|
|
|
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|