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 3

1 Comment

The third part of this ActionScript Loading Bar Tutorial will be putting together everything we have learned so far in this tutorial and making it work.

At the end of the ActionScript – Loading Screen – Part 2, we had put together a simple piece of code that will shrink the size of our loading bar to the same percentage that our movie has been loaded so far. (ie. If the movie is 45% loaded, the loading bar will be 45% wide.)

Now if you plug that into a movie, it will check our piece of code once, but not again, here is what you would do to have it check the code every frame.

On the first frame, of our movie, we put this code:

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

On the second frame of our movie we put this code:

if(percent < 100){
gotoAndPlay(1); //go to frame one again
}else {
play();
}

To summarize that if statement: If the movie isn’t done loading, go back to frame one and start over. This will run the code we placed on frame one, and update the width of our loading bar. Otherwise (else), the movie has completed loading, and it is time to play! (Yes, the play(); is redundant, because that’s what the movie would do automatically.

Then all you have to do is set up your movie to play in the next scene, and WALA! you have one beautiful Loading Bar!

-Let me know if this helped you,
-Ashton Sanders

1 Comment

Leave a Reply to ActionScript - Loading Screen - Part 2 | Website Designers and Webmasters Cancel reply

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