Copy link to clipboard
Copied
Hi all,
I made preloader code by myself, put into my hp's Main.swf.
It works perfectly in IE, shows the background image then shows progress, counter is smoothly rise up and when reach to 100%, goes to main contents.
But in Chrome and Firefox, shows background image, but counter does not appear until the contents are fully loaded, and then suddenly go up to 100%, then goes to main contents.
This is my url,
http://bootlegbaby.web.fc2.com/
And this is the code I made for preloader
---------------------------------------------------------------------------------------------------
stage.showDefaultContextMenu = false;
Security.allowDomain("*");
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var rx = Capabilities.screenResolutionX;
var ry = Capabilities.screenResolutionY;
//----------------------- Preloader Setup ------------------------------
PreloaderHolder_mc.x = stage.stageWidth/2;
PreloaderHolder_mc.y = stage.stageHeight/2 - 50;
PreloaderBG_mc.width = stage.stageWidth;
PreloaderBG_mc.height = stage.stageHeight;
stage.addEventListener(Event.RESIZE,PLresizeHandler);
function PLresizeHandler(event:Event):void {
PreloaderHolder_mc.x = stage.stageWidth/2;
PreloaderHolder_mc.y = stage.stageHeight/2 - 50;
PreloaderBG_mc.width = stage.stageWidth;
PreloaderBG_mc.height = stage.stageHeight;
}
var loader = new Loader();
loader.load(new URLRequest("Main.swf"));
loader.visible = false;
addChild(loader);
import flash.utils.Timer;
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onProgress(e:ProgressEvent):void {
var loadedBytes:int = Math.round(e.target.bytesLoaded / 1024);
var totalBytes:int = Math.round(e.target.bytesTotal / 1024);
var percent:int = (e.target.bytesLoaded / e.target.bytesTotal) * 100;
PreloaderHolder_mc.status_txt.text = String(loadedBytes + " of " + totalBytes + "KB Loaded\n" + percent + "% Complete");
}
function onComplete(e:Event):void {
stop();
var waitTime:Timer = new Timer(1000, 1);
waitTime.start();
waitTime.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
function onTimerComplete(event:TimerEvent):void{
removeChild(loader);
stage.removeEventListener(Event.RESIZE,PLresizeHandler);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
waitTime.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
removeChild(PreloaderBG_mc);
removeChild(PreloaderHolder_mc);
gotoAndPlay("Home");
}
}
stop();
---------------------------------------------------------------------------------------------------
I am putting this code at 1st frame of Main.swf, then put contents after 2nd frame.
Those movie clips called in this code are directly put into the scene at 1st frame.
PreloaderHolder_mc
PreloaderBG_mc
Anyone have any idea to solve this issue?
Message was edited by: jurneys
add a stop to your timeline in main and add a play to your loader's content cast as a movieclip after loading is complete.
Copy link to clipboard
Copied
here are some of the errors on your site:
Copy link to clipboard
Copied
I have separated preloader and main, now preloader's counter runs up smoothly in Chrome and Firefox too.
But another problem happens, it doesn't shows opening animation that I set into the timeline of main, maybe because it is already played while preloader is loading main.
Any way to suspend loader content's animation until loading complete?
Copy link to clipboard
Copied
add a stop to your timeline in main and add a play to your loader's content cast as a movieclip after loading is complete.
Copy link to clipboard
Copied
Works perfectly in all browsers now. Thanks for help!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now