# Having trouble instantiating a class from another swf file

**URL:** <https://forum.kirupa.com/t/having-trouble-instantiating-a-class-from-another-swf-file/239748>\
**Category:** flash\
**Created:** [September 25, 2007, 3:48pm UTC](https://forum.kirupa.com/t/having-trouble-instantiating-a-class-from-another-swf-file/239748 "2007-09-25T15:48:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![OzzieGT](https://avatars.discourse-cdn.com/v4/letter/o/7993a0/32.png) [@OzzieGT](https://forum.kirupa.com/u/OzzieGT)\
**Post date:** [September 25, 2007, 3:48pm UTC](https://forum.kirupa.com/t/having-trouble-instantiating-a-class-from-another-swf-file/239748/1 "2007-09-25T15:48:43Z")

</div>

I have two SWF files.

DynamicModules.swf loads in CustomModules.swf

CustomModules.swf has a class “MyModule” defined in it.

```auto

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Script>
		<![CDATA[
			private var m:MyModule = new MyModule;
		]]>
	</mx:Script>
</mx:Application>

```

MyModule is a pretty simple class

```auto

package
{
	import flash.display.Sprite;
	public class MyModule extends Sprite
	{
		public function MyModule()
		{
			super();
		}
	}
}

```

In my DynamicModules.swf, this is the loaded handler for the Loader.

```auto

private function moduleLoadedHandler(e:Event) : void{
	var moduleClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("MyModule") as Class;
}

```

This is returning a “variable is not defined” error. Any suggestions on what I might be doing wrong? I have a feeling it is something in CustomModule.swf but I don’t know what.

If I get the “Wrapper.swf” from [this adobe site](http://blogs.adobe.com/kiwi/2006/07/loading_flex_skins_at_runtime.html), which is suppposed to be the same thing, it loads fine. Unfortunately they didn’t include the source code for Wrapper.swf.
