Preloading is quite simple in as3.
The best way to explain it is just to comment the code (see below).
Warning
INIFINTE, error message
This one took me all day to figure out.
If you get the INFINITE message, it would mean you are dividing by zero ( totalBytes is set to zero).
Normally this should NOT happen, if it does happen then the cause would most likely be gzip compression on the apache server. it was for my error.
The compression on the web server seems to cause problems to the flash player and it is unable to determine the file size, hence totalBytes is set to zero. The work around is to add in the .htaccess file a rewrite rule to turn off gzip module. Just place the .htaccess file in your swf directory so it the rest of the site will remain gziped.
Paste the code below into your ‘actions’ window, Window -> Actions. To execute, Control -> Test Movie
// stop the frames from moving.
stop();
addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event)
{
var loaded:Number = loaderInfo.bytesLoaded;
var total:Number = loaderInfo.bytesTotal;
// This text field would reside on your stage, and you already assigned the instance name of 'progress_string'
// Note: Make sure you first turn to symbol, and check off the box 'Export for Actionscript'
progress_string.text = Math.floor(loaded / total * 100)+"%";
if (loaded == total)
{
// We are done, continue to play the movie
play();
}
}




Trackbacks/Pingbacks
[...] is the original post: Simple PreLoader in as3 | Flash tutorials | Flash video | Flash … tags: capcom, cause-problems, determine-the-file, flash, hence-total, mega, nintendo, [...]
[...] original post here: Simple PreLoader in as3 | Flash tutorials | Flash video | Flash … [...]
[...] the original post: Simple PreLoader in as3 | Flash tutorials | Flash video | Flash … Share and [...]
[...] Simple PreLoader in as3 | Flash tutorials | Flash video | Flash … [...]