我创建了一个工人类来解析 Collada 文件(Alternativa3d 引擎)。
我正在将 dae/xml 文件发送到 Worker 类并对其进行解析。在主课上收到它时,收到一条错误消息“类型强制失败”。
这是代码。
主类:发送数据
if (bgWorkerX.state == WorkerState.RUNNING)
{
var _b:ByteArray = (new modelX() as ByteArray);
var xml:XML = (new XML(_b.readUTFBytes(_b.length)));
bgWorkerCCX.send(["START_PARSING", XParser]);
}
主类:接收数据
if (!resultCX.messageAvailable)
{
return;
}
var result:String = resultCX.receive(true);
if (result == "SUCCESS")
{
var txt3:TextField = new TextField();
txt3.text = "Parsed result : " + Mesh(resultCX.receive(true)); //ERROR LINE : TYPE COERCION FAILED.
}
}
工人阶级:
private function handleCommandMessage(event:Event):void
{
if (!commandChannel.messageAvailable) {
return;
}
var message:Array = commandChannel.receive() as Array;
if (message != null && message[0] == "START_PARSING")
{
StartParsing(XML(message[1]));
}
}
private function StartParsing(xml:XML):void
{
parser = new ParserCollada();
parser.parse(xml);
resultChannel.send("SUCCESS");
resultChannel.send(parser.getObjectByName('mainbody') as Mesh);
}
有人知道如何将类似类型的对象转换为所需的类型吗?