APPLE LIKE PRELOADER                                                         as3


    This tutorial shows how to create a simple apple (the company) look like preloader in actionscript 3.0. The result should look like the example below. This example is for demonstration purposes only to show how the actuall loading part looks like. The real preloader will jump to the real content after it loads the entire file.



     The graphic part of the project (apple like spinning thing) is included in the source file you can download at the bottom of this page so I wont cover that part of the project. We start by opening new actionscript 3.0 document. Create one, two blocks long frame on the layer 1. Insert the graphic part and two dynamic text fields. Name them progress and vysledok_txt. Size, color , font etc. is all your choice. Now create new layer on timeline, select it and insert new blank keyframe. Select second frame of the top layer and insert the following actionscript code.


var loading:Number=0;
var loaded:Number=stage.loaderInfo.bytesLoaded;
var total:Number=stage.loaderInfo.bytesTotal; 

loading = Math.round((loaded/total)*100);
progress.text=String(loading +"% Completed");

vysledok_txt.text=String(Math.round(loaded/1024)+
											" of "+Math.round(total/1024)+" Kb Loaded");

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


     First three lines are definition of variables used in this script. Loaded stores loaded bytes while total stores total size of the file in bytes. Line five then counts the % of total size already loaded and on line 6 its send to progress textfield. Line 8 counts loaded part in Kb out of total Kb and send it to the vysledok_txt textfield. Lines 11-15 checks if loaded equals 100% and then either returns to frame 1 if that is not the case or continues to the actuall content if its true.


DOWNLOAD SOURCE FILE