How to stop swf when an error occur
I have a project where I am loading in an external swf and when it error loading I want it to show the error on screen which I have accomplished and t开发者_如何学Pythonhen I want to provent it from going any further . i.e no more frames entered no more axtionscript run
I tried this and got nothing
function ioError(e:IOErrorEvent):void {
error_txt.text = e.text;
trace(e.target.loaderURL);
stop();
}
You need to register the ioError function as an event handler on the LoaderInfo object. I assume somewhere you've created a Loader to load your external SWF. Here's the example from Adobe (http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html) edited slightly to remove classes.
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
var request:URLRequest = new URLRequest("some.swf");
loader.load(request);
addChild(loader);
function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
精彩评论