Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting/Basic

Categories Percentage Preloader
Author: Chris Berry | Website: http://www.bezzanet.zzn.com |

 
Page 1
1

Preloader Tutorial

Introduction

In this tutorial you will learn how to create a preloader that will return a percentage. This percentage can then be used for things such as a preloader bar. Preloaders that work out percentages are important because they give the users of your site feedback of how much of your flash content is loaded. For this tutorial I expect you to have a basic knowledge of flash and can navigate around freely within the flash interface. I also expect you to have a basic actionscripting knowledge and be able to understand the basic scripts in this tutorial. This tutorial has been writen for use in Flash MX, it takes advantage of some of the added features including text box instance names. If you don't have mx, remember to use the textVariable property instead of the instance name.

Tutorial

1) we'll start off by creating a new movie and adding three keyframes. To do this you can select the first frame and press the F6 key twice. On the first frame make a dynamic text box (text tool>properties> dropdown menu> "dynamic"). Give this text box the instance name of "myOutput". Now copy this text box and paste it in the second frame of the movie. In the third frame put an image or sound file so we will be able to test this preloader latter.

2) Select the first frame and open the actionscript window. If your Actionscript window is set to "Beginner" then click the button in the top right corner of the window and select "Advanced" from the menu, this allows you to freely type and edit code. Now we will write the following code under the first frame

percent = Math.floor(getBytesLoaded()/getBytesTotal()*100);
myOutput.text = percent + "% is loaded";

percent is a variable that we will store how much of the movie is loaded in. getBytesLoaded() retrives the amount of bytes loaded, getBytesTotal() retrives the total size of the movie. when you put these two things over each other and times by 100, you will get the percentage of the movie loaded. The Math.floor() rounds the number to the nearst whole number.

3) In the second frame of the movie clip enter the following code in the actionscript window.

if (percent == 100){
gotoAndStop(3);
}else{
gotoAndPlay(1);
}

This checks to see if "percent" is equal to 100, if it is, go to the third frame, if its not, goto the first frame.

4) On the fourth frame put a "stop();", this ensures that the movie stops at the last frame and doesn't keep going.

I hope you were able to learn something from this tutorial, if theres any questions please feel free to contact me through the source guru message boards at www.sourceguru.eu.org, or by email to buds_a_bird@hotmail.com. If you want to you can check out my site www.bezzanet.zzn.com and view some of my flash experiments.

1

» Level Basic

Added: : 2002-12-18
Rating: 7.94 Votes: 247
Hits: 1969
» Author
Flash and website designer
» Download
Download the files used in this tutorial.
Download (29 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments