Monday 21 July 2014

as3-preloader classes

import flash.events.ProgressEvent;
stop();

// progress event
loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadingProgress);
loaderInfo.addEventListener( Event.COMPLETE , finishedLoading );

// simple preloader;
function loadingProgress(e:ProgressEvent):void
{
preloaderBar.scaleX = loaderInfo.bytesLoaded / loaderInfo.bytesTotal;
}
function finishedLoading( evt:Event ):void
{
loaderInfo.removeEventListener( Event.COMPLETE , finishedLoading );
gotoAndStop(2);
}


// if you are using classes code you can use ProgressEvent in timeline and use  Event.COMPLETE in classes ( Main.as )
But you have to remember several thing .....

1. you should load your pre-loader animation in frame 1
2. Should change Advanced ActionScript Settings => Export Classes in frames 2 ( frame 2)

Check below fig. for more info.......




















No comments:

Post a Comment