# Preloader does not addChild on event

**URL:** https://forum.kirupa.com/t/preloader-does-not-addchild-on-event/322752
**Category:** flash
**Created:** [June 1, 2011, 8:15pm UTC](https://forum.kirupa.com/t/preloader-does-not-addchild-on-event/322752 "2011-06-01T20:15:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tolgainam](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tolgainam](https://forum.kirupa.com/u/tolgainam)
#### Post date: [June 1, 2011, 8:15pm UTC](https://forum.kirupa.com/t/preloader-does-not-addchild-on-event/322752/1 "2011-06-01T20:15:07Z")

</div>

Hello I have a website file that I am preloading with an another swf preloader file.  
The code is on the first frame of preloader.swf and as follows:

```auto

import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;

var contentLoader:Loader = new Loader(); 
 

contentLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading, false, 0, true); 
contentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentLoaded, false, 0, true); 

contentLoader.load(new URLRequest("content.swf")); 
	
  
function contentLoaded(evt:Event):void {
	//Optionally change to a clip holder and set progressbar visibility.
	
	removeChildAt(0);
	
	addChild(contentLoader.content); 
	
	contentLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loading);
	contentLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, contentLoaded);
	contentLoader = null;
} 
  
function loading(evt:ProgressEvent):void { 
	var loaded:Number = evt.bytesLoaded / evt.bytesTotal; 
	setBarProgress(loaded); 
} 

function setBarProgress(value:Number) { 
	trace('Progress'+ value);
	loadtext.text = "Loading %"+ Math.floor(value * 100);
}

```

The problem is when I use this without simulate download option I see it is loaded via trace() and content.swf loads BUT when I use simulate download or upload files to Web and try it there it just counts to 100% percent and stops there.

Any ideas ?

Thanks
