views:

174

answers:

1

I am loading a swf into another swf using swfloader, I want to catch all the exceptions thrown by the inner swf, is it doable?

+1  A: 

Here are some basics that may help. In short, you cannot use try/catch here.

Errors in loading external content cannot be caught with try..catch..finally statements. Instead you have to create event handlers to handle and “catch” the error events. If you do not have an event listener assigned to an error event and that error occurs, the Flash player will inform you of the unhandled error event.

// creating listeners for error events handles
// asynchronous errors
target.addEventListener(ErrorEvent.TYPE, handler);
function handler(event:ErrorEvent):void {
// handle error
}

If you want to invoke your own asynchronous errors, all you need to do is dispatch an event using dispatchEvent that is of the type ErrorEvent. When an unhandled ErrorEvent reaches the Flash player when authoring in Flash, the output window will display the error.

target.dispatchEvent(new ErrorEvent(”type”));
Todd Moses