I have a Flash game which holds all of its content in a single keyframe on the stage. I have one keyframe before this which contains the preloader using the following script:
stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onProgress(e:ProgressEvent):void
{
var loaded:Number = e.target.bytesLoaded;
var total:Number = e.target.bytesTotal;
var pct:Number = loaded/total;
loader_mc.scaleX = pct;
loaded_txt.text = "Loading... " + (Math.round(pct * 100)) + "%";
}
function onComplete(e:Event):void
{
nextFrame();
}
The preloader seems to be coded correctly. The problem is that when I upload the file to the web there is a long delay before even the preloader appears. It eventually does appear at about 90%. It continues to load up to 100% then the game starts as required.
I obviously want the preloader to start playing from 1%, its like the swf is trying to load all of the graphic before the preloader loads. I have multiple classes, would this cause the problem?