The following example shows how you can detect if content loaded successfully in a UILoader container by listening for the ioError event (using the static IOErrorEvent.IO_ERROR constant).
Full code after the jump.
// ActionScript 3.0 /* Requires: * - UILoader component in Flash library */ import fl.containers.UILoader; var uiLoader:UILoader = new UILoader(); uiLoader.addEventListener(IOErrorEvent.IO_ERROR, uiLoader_ioError); uiLoader.source = "http://www.helpexamples.com/flash/images/404.jpg"; addChild(uiLoader); function uiLoader_ioError(evt:IOErrorEvent):void { var tf:TextField = new TextField(); tf.text = evt.text; tf.autoSize = TextFieldAutoSize.LEFT; tf.width = 300; tf.wordWrap = true; tf.x = 10; tf.y = 10; addChild(tf); }
{ 1 comment… read it below or add one }
The event raised tells if an error occurs and the function it calls is executed outside the function containing the event after this function ends. Unlike a try catch block it offers no ability to handle success.