# Runtime loaded asset seems to have no definition

**URL:** <https://forum.kirupa.com/t/runtime-loaded-asset-seems-to-have-no-definition/262373>\
**Category:** flash\
**Created:** [June 5, 2008, 2:07pm UTC](https://forum.kirupa.com/t/runtime-loaded-asset-seems-to-have-no-definition/262373 "2008-06-05T14:07:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blouze](https://avatars.discourse-cdn.com/v4/letter/b/90db22/32.png) [@Blouze](https://forum.kirupa.com/u/Blouze)\
**Post date:** [June 5, 2008, 2:07pm UTC](https://forum.kirupa.com/t/runtime-loaded-asset-seems-to-have-no-definition/262373/1 "2008-06-05T14:07:50Z")

</div>

Hi,

one of you forum readers might get the title for “AS-Guru of all time” pointing me the solution to THIS:

I’m publishing an SWF file on domainA and loading every graphical assets and included classes from another SWF located on domainB.  
It’s great.  
Locally.

I mean that when the two files are loaded locally side by side, everything rolls fine.  
As soon as I’m trying to load the assets library from domainB, I get a runtime error #1009 (null object reference).

The following “crossdomain.xml” is hosted on domainB :

```auto
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <allow-access-from domain="*" />
    <allow-access-from domain="localhost" />
    <allow-access-from domain="127.0.0.1" />
</cross-domain-policy>

```

but doesn’t seems to accept remote serving of an SWF from another.  
I worked my way around security issues by declaring in the first frame of the library SWF

```auto
Security.allowDomain("*");

```

(now that’s security…)  
and the library assets gets loaded fine from domainB, like this:

```auto
var path:URLRequest = new URLRequest(Config.SERVER_PATH + "assets/assets.swf");
var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onAssetsLoadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.load(path, context);

```

Or do they?

The classes associated with the linked library assets gets loaded fine too, as I can instantiate them.  
The thing is every time there’s a sub-clip inside one of them, it doesn’t seem to get defined at all.  
For instance, I have SimpleButton called “replay\_btn” inside a movieClip linked with “OptionsButtons” class.  
I have this

```auto
public var replay_btn:SimpleButton;

```

in the class definition.

I repeat : this is working fine when

```auto
Config.SERVER_PATH = ""

```

not anymore when

```auto
Config.SERVER_PATH = "domainB"

```

Winners might get recognition.  
A whole lot’of’it.

I know many chicks.  
Please help.

---

<div class="post-metadata">

**Author:** ![Blouze](https://avatars.discourse-cdn.com/v4/letter/b/90db22/32.png) [@Blouze](https://forum.kirupa.com/u/Blouze)\
**Post date:** [June 6, 2008, 5:49pm UTC](https://forum.kirupa.com/t/runtime-loaded-asset-seems-to-have-no-definition/262373/2 "2008-06-06T17:49:37Z")

</div>

Bump.

Still have no solution for that problem.  
I triple-checked Security allowance for children and parent, no luck.  
It just seems to be forbidden to manually add an MC to another one’s stage when this last one is linked to a class, and then load this to another swf and be able to use the classes without bumping in a null reference to children MCs.

Weird…

Any help would still be very appreciated.

---

<div class="post-metadata">

**Author:** ![Blouze](https://avatars.discourse-cdn.com/v4/letter/b/90db22/32.png) [@Blouze](https://forum.kirupa.com/u/Blouze)\
**Post date:** [June 11, 2008, 11:44am UTC](https://forum.kirupa.com/t/runtime-loaded-asset-seems-to-have-no-definition/262373/3 "2008-06-11T11:44:48Z")

</div>

Ok boys, hear this.  
If anyone would like to be able to access classes and sub-clips from a swf on another domain than the one accessing it, try this :

```auto
var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);

```

The third argument (securityDomain) set to SecurityDomain.currentDomain visibly changed the way assets gets added to application sandbox.  
Not sure about the voodoo behind it but that’s the way to go.

Hope this help someone.  
Cheers.
