Preloader complete event firing too early

Hello guys,

I am currently building a preloader for my movie and have the following code:

var websiteLoader:LoaderInfo = this.loaderInfo;

websiteLoader.addEventListener(ProgressEvent.PROGRESS, loaderProgressHandler);
websiteLoader.addEventListener(Event.COMPLETE, onLoaderComplete);

function loaderProgressHandler(event:ProgressEvent):void{
	//When loading
	var loaderBar:MovieClip = loaderbar_mc;
	var loaderMask:MovieClip = loadermask_mc;
	var loadedPercentage:int = (Math.ceil(event.bytesLoaded / event.bytesTotal));
	loaderBar.x = (loadedPercentage*loaderMask.width) + loaderMask.x;
function onLoaderComplete():void{
	//When loading completes;
	websiteLoader.removeEventListener(ProgressEvent.PROGRESS, loaderProgressHandler);
	websiteLoader.removeEventListener(Event.COMPLETE, onLoaderComplete);

On the first frame, I have the preloader assets. On the second frame, assets that are exported for actionscript but set to not export at first frame. On the third frame, I have the actual website.

Now the issue is this, people testing it over internet connections and me testing it flash with simulate download will see the following issue:

The movie will load, COMPLETE will fire causing the movie to play. But the movie hasn’t fully loaded yet, so it will play frame 2 when it should play frame 3. Various testing has shown that the movie has not fully loaded yet, but tracing bytesLoaded will show that it is equal to bytesTotal.

Any ideas appreciated :slight_smile: