# Preloader complete event firing too early

**URL:** <https://forum.kirupa.com/t/preloader-complete-event-firing-too-early/248063>\
**Category:** flash\
**Created:** [January 3, 2008, 12:16pm UTC](https://forum.kirupa.com/t/preloader-complete-event-firing-too-early/248063 "2008-01-03T12:16:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon4341189](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@anon4341189](https://forum.kirupa.com/u/anon4341189)\
**Post date:** [January 3, 2008, 12:16pm UTC](https://forum.kirupa.com/t/preloader-complete-event-firing-too-early/248063/1 "2008-01-03T12:16:07Z")

</div>

Hello guys,

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

```auto

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{
	trace("completed");
	//When loading completes
	websiteloader_mc.play();
					
	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 🙂
