Actionscript 3 AS3-添加子错误#1009-IOErrorEvent.IO_错误
我一直收到一个错误#1009,因为我试图在ioErrorHandler函数中使用addChild显示一个警报框Actionscript 3 AS3-添加子错误#1009-IOErrorEvent.IO_错误,actionscript-3,error-handling,Actionscript 3,Error Handling,我一直收到一个错误#1009,因为我试图在ioErrorHandler函数中使用addChild显示一个警报框 跟踪(“IOErrorEvent:+事件)工作正常。但是我在警报框类中得到了错误#1009 ////---- Display Alert Box private function displayAlertBox():void { alertBoxContainer.x = stage.stageWidth - alertBoxBg.width >> 1;
跟踪(“IOErrorEvent:+事件)代码>工作正常。但是我在警报框类中得到了错误#1009
////---- Display Alert Box
private function displayAlertBox():void
{
alertBoxContainer.x = stage.stageWidth - alertBoxBg.width >> 1;
alertBoxContainer.y = stage.stageHeight - alertBoxBg.height >> 1;
addChild(alertBoxContainer);
}
这是我的密码。除了错误事件处理程序内部之外,Alert Box类在其他任何地方都可以正常工作。您能否在错误事件处理程序中实际使用addChild?我尝试从错误事件处理程序内部调用一个函数来显示Alert Box类,但仍然不起作用
//Display Alert Box
private var alert_Box:alertBox;
var _userIdRequest:URLLoader = new URLLoader();
_userIdRequest.load(new URLRequest("http://www.example.com/New_User_Id.php"));
_userIdRequest.addEventListener(flash.events.Event.COMPLETE, CompleteHandler);
_userIdRequest.addEventListener(flash.events.IOErrorEvent.IO_ERROR, ioErrorHandler);
////--- Error Handler;
function ioErrorHandler(event:flash.events.IOErrorEvent):void
{
// not able to connect to the server
trace("IOErrorEvent: " + event);
alert_Box = new alertBox();
addChild(alert_Box);
}
我尝试了一个新项目,一切进展顺利
我把这个代码放在第一帧中。我用的是Flash CC
import flash.events.Event;
//Display Alert Box
var alert_Box:alertBox;
var _userIdRequest:URLLoader = new URLLoader();
_userIdRequest.load(new URLRequest("http://www.example.com/New_User_Id.php"));
_userIdRequest.addEventListener(flash.events.Event.COMPLETE, CompleteHandler);
_userIdRequest.addEventListener(flash.events.IOErrorEvent.IO_ERROR, ioErrorHandler);
////--- Error Handler;
function ioErrorHandler(event:flash.events.IOErrorEvent):void {
// not able to connect to the server
trace("IOErrorEvent:");
alert_Box = new alertBox();
addChild(alert_Box);
alert_Box.x = stage.stageWidth/2;
alert_Box.y = stage.stageHeight/2;
}
function CompleteHandler (e:Event):void {
trace("complete!");
}
在我的例子中,alertBox是一个正方形
我想你的alertBox类有问题。你添加了两次child吗?我解决了我的问题。我一共有3节课:
飞溅屏幕类
消费阶层
AlertBox类
加载的主要类是splashScreen类。在splashScreen类内部,我调用consumerId类来创建id。如果连接到我的服务器的url有问题。IOErrorEvent错误被触发,AlertBox类应该从consumerId类内部显示。嗯,经过很多测试。我无法在consumerId类中加载AlertBox。这就是我得到#1009错误的原因。一旦我从consumerId类的IOErrorEvent错误处理程序内部将静态函数发送回slashScreen类。我可以从splashScreen类内部调用AlertBox类,AlertBox将显示 你的职能在哪里?是在项目的主类中还是在对象的类中?也许用MovieClip(root.addChild(alert\u-Box)这样的东西将alert\u-Box对象显式地添加到根目录就足够了;我没有添加上面的函数。我尝试了一个函数,但仍然不起作用。我目前正在使用Flash Builder 4.7。我使用的是一个子类。