Tutorials Navigation

Tutorials :: New :: Popular :: Top Rated

Tutorials: 18,326 Categories: 12

Total Tutorial Views: 41,272,984

How to Make a Loading Screen in Flash

Tutorial Name: How to Make a Loading Screen in Flash  

Category: PC Tutorials

Submitted By: Ry-Nasty

Date Added:

Comments: 0

Views: 2,687

Related Forum: PC Building Forum

Share:

1
Create a new ActionScript 2.x file and change the fps to 50.

2
Create the movieclips required for your loading animation. We're going to create a very simple screen to start with.


Select the Rectangle tool from the Tools bar. Draw a rectangle about 10px high and 100px long and make it a movieclip (F8). This will be the bar that represents the amount of your movie that has loaded. In the Properties tab of the object, give this movieclip the instance name "progressBar".

Draw a textarea on the stage that will hold the percentage of the movie that has loaded.When creating the textarea, make sure that the Type dropdown (near the top of the Properties tab ) is set to Dynamic Text. Also in the Properties tab, click Character Embedding and select both "Numerals" and "Punctuation". (Tip: Hold down Ctrl while clicking to select multiple menu items.)Once created, give this textarea the instance name "percentageLoaded". Note: Do not make the textarea a symbol.
3
Write the ActionScript required to check how much of your movie is loaded. If you've used the Actions window before, it may already be visible to you. If not, press F9 or use the menu Window>Actions.


Create a new layer in the timeline for only your ActionScript. You can use the New Layer icon below the timeline or the menu Insert>Timeline>Layer. This will keep your ActionScript separate and clear of movieclips and makes life much easier when you have hundreds of layers or movieclips.
Add the following code to the Actions frame. Read the comments in the code (marked with //) to see what each part does.

// Stops the playhead from moving down the timeline until you have finished loading your movie
stop();
// onEnterFrame starts a loop at the same speed that your movie fps is set to.
// it will continue indefinitely until you stop it.
_root.onEnterFrame = function(){
// Calculate the percentage of the movie that has loaded.
percentage = Math.round((this.getBytesLoaded()/this.getBytesTotal())*100);
// Set the x-axis or horizontal scale of the progressBar to visually
// represent the percentage. Note: To make this more visually
// effective, you will probably want to add a border.
progressBar._xscale = percentage;
// Put the percentage loaded into the textarea, e.g. "47%"
percentageLoaded.text = percentage + "%";
// Check if the percentage variable is equal to 100
if(percentage==100){
// remove the onEnterFrame loop we started above
delete _root.onEnterFrame;
// go and start your movie
gotoAndPlay("MovieStart");
}
}



Test your movie by pressing Ctrl+Enter or use the menu Control>Test Movie

Hope this helps.
Nasty

Ratings

Current rating: 2.00 by 2 users
Please take one second and rate this tutorial...

Not a Chance
1
2
3
4
5
6
7
8
9
10
Absolutely

Comments

"How to Make a Loading Screen in Flash" :: Login/Create an Account :: 0 comments

If you would like to post a comment please signin to your account or register for an account.