-
[RESOLVED] CS4 preloader issue
I have this code on the first frame of the main timeline.
PHP Code:
//preloader loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader); function updatePreloader(evtObj: ProgressEvent):void { //container for the site download progress var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal); preloader_txt.text=percent+"%"; if (percent>=100) { loaderInfo.removeEventListener(ProgressEvent.PROGRESS, updatePreloader); gotoAndPlay("letsStart"); } }
When I test the code in flash CS4 I get no errors and the file opens correctly. When I load the file to a server, it loads but then goes to the 'letsStart' frame and won't advance from that frame. It's as if I said gotoAndStop. If I refresh the page I get 0% loaded and the file does nothing. What is wrong with my code? I appreciate any help. The letsStart frame is a blank frame with some soundfiles in a mc. I would expect it to just advance through the frame to the next frame like it does when played in the flash program.
-
Anyone have any advice? Thanks
-
The ProgressEvent.PROGRESS is unreliable, if the file is already cached it may not fire. You should add a separate listener for Event.COMPLETE.
-
Originally Posted by v5000
The ProgressEvent.PROGRESS is unreliable, if the file is already cached it may not fire. You should add a separate listener for Event.COMPLETE.
Your advice was hugely helpful. I came up with this and now every issue is solved and everything is working great. THANKS!!
PHP Code:
//preloader
loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
function updatePreloader(evtObj: ProgressEvent):void {
//container for the site download progress
var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
preloader_txt.text=percent+"%";
}
loaderInfo.addEventListener(Event.COMPLETE, moveOn);
function moveOn(e:Event):void {
loaderInfo.removeEventListener(ProgressEvent.PROGRESS, updatePreloader);
loaderInfo.removeEventListener(Event.COMPLETE, moveOn);
gotoAndPlay("letsStart");
}
stop();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|