First time here? First time here? Newsletter Signup Newsletter
651326 Members and growing! | Flash Jobs
Search tutorials
Author: Kenton Hamaluik

Actionscript

Actionscipt can seem really daunting to some, so I will try to make it as easy as possible. It greatly helps if you know dot syntax, but you won't suffer if you don't. Actionscipt is always easier to find and work with, etc when its on it's own layer.

Create a new layer on the main timeline, and call it "Actions". The layer should be blank. Create three keyframes in it. Now on the first layer with all your content on it, select frame 3 and press F5.

On the actions layer, we will detect the total size of the flash movie, and detect the total amount of it that is loaded. We will then get a percent from these two values, then control what the textbox says, and what the bar does. You will notice i use

 _root. 
a lot. That is so that all these variables are placed for sure at the base of the movie.

In the first frame of the actions layer, add these actions:

_root.bytesLoaded = _root.getBytesLoaded();
_root.bytesTotal = _root.getBytesTotal();
_root.percentLoaded = Math.round(100*(_root.bytesLoaded/_root.bytesTotal));
_root.percentLoadedText = _root.percentLoaded+"%";
_root.bar.gotoAndStop(percentLoaded);

I will explain this code on the next page, but for now just add the actions. Now in frame 2 of the "Actions" layer, as this code:

if (_root.percentLoaded==100){
	gotoAndPlay(3);
}else{
	gotoAndPlay(1);
}

This checks to see if its all loaded, if it is go to the third frame, or your intro animation. If not, go back and refresh yourself on the new amount loaded.

You are now finished your preloader - well, mostly anyways. For details on how this works, and things you may wish to do, continue reading.

» Level Intermediate

Added: 2003-07-15
Rating: 6 Votes: 38
(10 being the highest)
» Author
Just 14 years old, I play with flash and wish to get good at it. :)
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • 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: doc_chin7
» Description:

The flash's horizontal road drive was done in CS4 and was upgraded to CS6. The car responds to right/ left key and flash will auto-generate the movement of roads from left-right or right-left based on random number. Have fun driving in this virtual environment and avoid other cars... :) If you are creative, a road driving game can be created from it.

Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.