# Custom Preloader

**URL:** <https://forum.kirupa.com/t/custom-preloader/254535>\
**Category:** Uncategorized\
**Created:** [March 12, 2008, 11:06pm UTC](https://forum.kirupa.com/t/custom-preloader/254535 "2008-03-12T23:06:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![msantos](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@msantos](https://forum.kirupa.com/u/msantos)\
**Post date:** [March 12, 2008, 11:06pm UTC](https://forum.kirupa.com/t/custom-preloader/254535/1 "2008-03-12T23:06:07Z")

</div>

Hi guys/gals,

Here’s my dilemma:

I’m trying to make a simple custom preloader in flash 9 and I’m very new to as3. The basic thing i need is a MC that has 100 frames and a dynamic text box that displays the percentage.

here’s my code:

//–Event Handler–\  
addEventListener(Event.ENTER\_FRAME, loading);

//-- My Function–\  
function loading(e:Event) {  
var bytestotal = stage.loaderInfo.bytesTotal;  
var bytesloaded = stage.loaderInfo.bytesLoaded;  
var percent = Math.round(bytesloaded \* 100/bytestotal);

//–loader\_mc is my movie clip that has 100 frames–\  
loader\_mc.gotoAndPlay(percent);

//–percent\_txt is the text box name of the percent i want to display–\  
percent\_txt.text=int(percent)+"%";

```
if (bytesloaded &gt;= bytestotal) {

	gotoAndStop(2);
	removeEventListener(Event.ENTER_FRAME, loading);
	removeChild(loader_mc);
}

```

}  
stop();

* * *

for some reason it’s not working and i get an error:  
TypeError: Error #2007: Parameter child must be non-null.  
at flash.display: displayObjectContainer/removeChild()  
at PreloaderTest\_fla::MainTimeline/loading()

Any help would be much appreciated!

Thanks again,  
mrmeir
