views:

201

answers:

1

When I try to access the uncaughtErrorEvents dispatcher when loaded directly, everything works well. But when I try the same code when loaded by another swf I get a reference error.

protected function onAddedToStage(e:Event):void {
    trace("Flash version: " + Capabilities.version);
    try {
      loaderInfo.uncaughtErrorEvents.addEventListener("uncaughtError", onUncaughtError);
      trace("YAY!");
    } catch (e:Error) {
      trace(e);
    }
}

Output when loaded directly (in browser):

Flash version: MAC 10,1,53,64
YAY!

Output when loaded by another "loader" SWF:

Flash version: MAC 10,1,53,64
ReferenceError: Error #1069: Property uncaughtErrorEvents not found on flash.display.LoaderInfo and there is no default value.

If others can replicate this I'd be appreciative.

EDIT: Also have tried this with stage.loaderInfo, instead of just loaderInfo. Same issue...

+1  A: 

the loaderInfo of a loaded object is different from that of an initialised object, and content through a Loader class is delt with differently. in the documentation is states that you have to add the listener to uncaughtErrorEvents on the loader, not the loaderInfo assosiated with it:

To detect uncaught errors that happen in a loaded SWF, use the Loader.uncaughtErrorEvents property, not the Loader.contentLoaderInfo.uncaughtErrorEvents property.

-livedocs link

so presumably you have to either add it to the loader rather than the loaded or detect if loaded and then add it to parent or something instead. inelegant i know, but all i can think of to get around it.

shortstick