Pre Loader / Loading

download AS3
http://www.mediafire.com/?41i2q688jr23p

stop();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
loaderInfo.addEventListener(Event.COMPLETE, completeListener);
function progressListener(e:ProgressEvent):void {
var loaded:Number = e.bytesLoaded / e.bytesTotal;
var percent:int = loaded * 100;

yload.loadN.text = "" + percent + "%";
//loadingBar.scaleX = loaded;
}
function completeListener(e:Event):void {
loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressListener);
loaderInfo.removeEventListener(Event.COMPLETE, completeListener);
//gotoAndPlay("menu", "Scene 1");
play();
}


------------


//AS2 code

percentageLoaded = Math.round(_root.getBytesLoaded() / _root.getBytesTotal() * 100);
per = int(percentageLoaded);
percentage = per+"%";

if (percentageLoaded == 100) {
gotoAndPlay("Start");
} else {
gotoAndPlay("LoadMore");
}

//Another //<------ AS3 Code ----->

var contentMc:MovieClip;

var myLoader:Loader = new Loader();

myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
myLoader.contentLoaderInfo.addEventListener(Event.INIT, initListener);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);

myLoader.load(new URLRequest("MovieToLoad.swf"));

// loading in progress
function progressListener(event:ProgressEvent):void {

// do something with the preloader
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
trace("loaded " + percentLoaded.toString()+"%");

// this test is necessary because the content may not be yet initialized
if(contentMc != null) {
trace("Loaded " + contentMc.framesLoaded + " frames of " + contentMc.totalFrames);
} else {
trace("Movie not yet initialized...");
}
}

// content initialized
function initListener (e:Event):void {
// from here I can use the loaded content
contentMc = MovieClip(myLoader.content);
addChild(contentMc);
contentMc.gotoAndStop(1);
trace("Total number of frames: " + contentMc.totalFrames);
}

// loading complete
function completeListener(event:Event):void {
// some code here...
}

0 comments:

Post a Comment