Hi,
I have a preloader that loads up an external swf and then adds it to the stage. It works fine, but as you go to the site again you will see the preloader again and the animation goes really really fast, which is kind of annoying. I want to skip the preloader animation once the external swf is loaded.
Basically, I write a function “onCheck” to see if the external swf is already loaded, but I don’t think that’s working. I must have done something wrong but I can’t figure out what it is. The following is my code, please kindly look at it and offer me help if you could. Thanks, and much appreciated.
stop();
import caurina.transitions.;
import caurina.transitions.Tweener;
import caurina.transitions.properties.;
var holder_mc:MovieClip=new MovieClip();
var loader:Loader = new Loader();
var OriginX:Number = panel_loading.ferry_animation.mcFerry.x;
loader.load(new URLRequest(“myMovie.swf”));
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onCheck);
function onCheck(evt:ProgressEvent):void {
var percent:Number = Math.floor( (evt.bytesLoaded*100)/evt.bytesTotal );
trace(percent);
panel_loading.percent_txt.text = percent.toString() + “%”;
if (percent == 100) {
Enter_Scene();
} else {
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onCheck);
showLoader();
}
}
function showLoader():void {
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
}
function loop(evt:ProgressEvent):void {
var percent:Number = Math.floor( (evt.bytesLoaded*100)/evt.bytesTotal );
if (panel_loading is MovieClip) {
panel_loading.ferry_animation.mcFerry.gotoAndStop(percent);
panel_loading.percent_txt.text = percent.toString() + “%”;
}
if (percent == 100) {
done();
}
}
function done():void {
Tweener.addTween(panel_loading.percent_txt,{alpha:0, time:1});
Tweener.addTween(panel_loading.ferry_animation,{alpha:0, time:1, onComplete:Enter_Scene});
}
function Enter_Scene():void {
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onCheck);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loop);
addChild(loader);
MovieClip(loader.content).gotoAndPlay(2);
removeChild(getChildByName (“logo”));
removeChild(getChildByName (“panel_loading”));
}