# Library class to stage via Loader

**URL:** <https://forum.kirupa.com/t/library-class-to-stage-via-loader/240716>\
**Category:** flash\
**Created:** [October 5, 2007, 10:09am UTC](https://forum.kirupa.com/t/library-class-to-stage-via-loader/240716 "2007-10-05T10:09:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)\
**Post date:** [October 5, 2007, 10:09am UTC](https://forum.kirupa.com/t/library-class-to-stage-via-loader/240716/1 "2007-10-05T10:09:44Z")

</div>

I have one swf(loaded.swf) file that contains a class called “GraphicQ”  
I load this file to another swf file(Test.swf) and then try to instantiate the GraphicQ class but in this Test.swf  
I manage to get the class definition but when I try to add the child to the stage I get this error:

TypeError: Error #2007: Parameter child must be non-null.  
at flash.display::DisplayObjectContainer/addChild()

And here is the code:

```auto

private var ldr:Loader = new Loader();

//constructor
public function Test()
		{
			var url:String = "loader.swf";
			var urlReq:URLRequest = new URLRequest(url);
			ldr.load(urlReq);
			ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

		}
		
		private function onComplete(event:Event):void {
			var tst:MovieClip = event.target.applicationDomain.getDefinition("GraphicQ") as MovieClip;
			addChild(tst);
		}
}

```
