NOTICE: ActionScipt No Longer Supported

These blog posts are for ActionScript, which is a programming language for Adobe Flash Player. Unfortunately, Adobe Flash is no longer supported for web applications, so this information is likely not very useful to most developers. We are keeping it for those who still enjoy ActionScript and for posterity. We named our company after it, after all.

ActionScript

ActionScript – Loading Screen – Part 2

1 Comment

The second part of this ActionScript Loading Bar Tutorial will be discussing that ratio between the bytes loaded so far and the total size of the movie in bytes.

*Click Here for Part 1 of the ActionScript Loading Screen*

ActionScript Theory

The theory behind this is very simple: If you take the amount of bytes that has already been loaded in your move, and divide it by the total size of your movie, you will end up with the percent of your move that is loaded.

ActionScript Code

We will be using two ActionScript Commands:

//How many Bytes have been loaded so far.
_root.getBytesLoaded();

//And the total bytes in the movie
_root.getBytesTotal();

Using the formula above, we come out with

(_root.getBytesLoaded()/_root.getBytesTotal())

This will give us a decimal like .4, which means 40%. so we are going to multiply it by 100 to get the correct number:

(_root.getBytesLoaded()/_root.getBytesTotal())*100;

Great, now lets apply this to what we discussed in Action Script – Loading Bar – Part 1. We are going to assign this percentage to the _xscale (or width) of the loading bar (_root.loader).

_root.loader._xscale =
(_root.getBytesLoaded()/_root.getBytesTotal())*100;

Great! Now we have the function for setting the width of the load bar. When the movie first starts loading, and there is only 1 byte loaded out of 4,000 bytes, the loading bar will be almost completely invisible, then as the number of bytes increases, the width of the bar will increase until 4,000 out of 4,000 bytes have been loaded and the loading bar is back to its normal width.

Last Step

We only have one step left to finish our loading bar, which you can view in Part 3 of this ActionScript Loading bar Tutorial.

Click to view all of the ActionScript Loading bar Tutorials on one page.

-Continue to ActionScript Tutorial Part 3
-Ashton Sanders

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *