gpt4 book ai didi

actionscript-3 - AS3-addChild错误#1009-IOErrorEvent.IO_ERROR

转载 作者:行者123 更新时间:2023-12-03 08:55:19 25 4
gpt4 key购买 nike

我一直收到错误#1009,因为我试图使用ioErrorHandler函数内部的addChild显示警报框。
trace("IOErrorEvent: " + event);正常工作。但是我在Alert Box类中获得了Error #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 ?

关于actionscript-3 - AS3-addChild错误#1009-IOErrorEvent.IO_ERROR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27657628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com