Put this code into ur first frame of the animation.
-------------------------------------------------------------------------
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("img1.jpg"));
function loop(e:ProgressEvent):void {
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}
function done(e:Event):void {
var mytween:Tween = new Tween(l, "scaleX",Strong.easeOut,0,1,3,true);
var mytween2:Tween = new Tween(l,
"scaleY",Elastic.easeOut,0,1,3,true);
removeChildAt(0);
percent = null;
addChild(l);
}
Wednesday, August 26, 2009
AS3 Normal Preloader
You just need to put this code into ur first frame of flash animation and start the animation on 2nd frame.That's all.
------------------------------------------------------------------------------------
stop();
addEventListener(Event.ENTER_FRAME, loadProgress);
function loadProgress(event:Event):void {
var bytes_loaded:int = this.root.loaderInfo.bytesLoaded;
var bytes_total:int = this.root.loaderInfo.bytesTotal;
var bytes_percent:int = Math.round((bytes_loaded/bytes_total)*100);
per.text = bytes_percent + " %";
trace((bytes_loaded/bytes_total)*100);
if (bytes_loaded >= bytes_total) {
trace("This movie is loaded");
removeEventListener(Event.ENTER_FRAME, loadProgress);
gotoAndPlay(1);
per.text = "";
gotoAndPlay(2)
//where ur animation starts
}
}
------------------------------------------------------------------------------------
stop();
addEventListener(Event.ENTER_FRAME, loadProgress);
function loadProgress(event:Event):void {
var bytes_loaded:int = this.root.loaderInfo.bytesLoaded;
var bytes_total:int = this.root.loaderInfo.bytesTotal;
var bytes_percent:int = Math.round((bytes_loaded/bytes_total)*100);
per.text = bytes_percent + " %";
trace((bytes_loaded/bytes_total)*100);
if (bytes_loaded >= bytes_total) {
trace("This movie is loaded");
removeEventListener(Event.ENTER_FRAME, loadProgress);
gotoAndPlay(1);
per.text = "";
gotoAndPlay(2)
//where ur animation starts
}
}
Subscribe to:
Posts (Atom)