# addChild from custom class

**URL:** <https://forum.kirupa.com/t/addchild-from-custom-class/271150>\
**Category:** flash\
**Created:** [September 19, 2008, 4:11am UTC](https://forum.kirupa.com/t/addchild-from-custom-class/271150 "2008-09-19T04:11:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neilness](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@neilness](https://forum.kirupa.com/u/neilness)\
**Post date:** [September 19, 2008, 4:11am UTC](https://forum.kirupa.com/t/addchild-from-custom-class/271150/1 "2008-09-19T04:11:24Z")

</div>

I’m trying to write a custom class that will take a progress bar movieclip from the library, add it to the stage, update it with information from my loader event listener, and then remove it from the stage when everything is loaded. I’ve been messing around with it for so long, and i just can’t get it to work!

i call the constructor from a frame action, like this:

```auto
var progBar:loaderBar = new loaderBar(100, 200);

```

and the class file:

```auto
public class loaderBar extends MovieClip {
		public function loaderBar(xloc:Number, yloc:Number) {
			stage.addChild(this);
			this.x = xloc;
			this.y = yloc;
			this.progressbar.progressbarmask.width = 0;
			this.loadStatus.text = "Loading";
			this.perc.text = "0%";
		}
		public function updateLoaderBar(statusMessage:String, bLoaded:Number, bTotal:Number) {
			this.perc.text=Math.ceil((bLoaded/bTotal)*100)+"%";
			this.loadStatus.text=statusMessage;
		}

```

am i going about this the wrong way? essentially, there’s only one progress bar active at any given time, so it always needs to be on top, and i guess it could theoretically always have the same instance name… so i might be able to add it directly to a layer in flash?
