Some people have been facing the problem with Flash AS3 preloader. Loading Infinity% seems to be caused by a division by zero error. Below is a little change to the preloader codes which fixed the error. If you are using one of the flash files from flashmo.com, you may update your codes at the preloader scene (Shift + F2, or Main menu bar > Window > Other Panels > Scene). This is located on “actions” layer. You can edit through the actions panel (press F9). You may download 188 chrome black to see the real working example.
Actionscript:
If you have any question, you may drop a comment below. Thanks!- stop();
-
- var loaded_bytes:Number;
- var total_bytes:Number;
- var percent:Number;
-
- fm_bar.addEventListener( Event.ENTER_FRAME, load_progress );
-
- function load_progress(e:Event):void
- {
- loaded_bytes = stage.loaderInfo.bytesLoaded;
- total_bytes = stage.loaderInfo.bytesTotal;
-
- if( total_bytes == 0 ) total_bytes = 1;
-
- percent = Math.round(loaded_bytes / total_bytes * 100);
- fm_bar.scaleX = percent * 0.01;
- loader_info.text = “Loading… “ + percent + “%”;
-
- if( percent == 100 )
- {
- fm_bar.removeEventListener( Event.ENTER_FRAME, load_progress );
- play();
- }
- }
UPDATES [22 September 2009]: I have found out that a few number of people got a preloader with incorrect loading percent while some people have infinity value problem. Below is the screenshot from David Kennedy’s GFX site while preloader is loading. I guess these 2 different problems seem to be because of different hosting platforms.
0 comments:
Post a Comment