【发布时间】:2014-05-01 06:09:13
【问题描述】:
我有一个像这样的数组:
> ObjectArr[ID,x,y,distance,Type];
还有一个类似的xml:
objectXML =
<objects>
<object id={ID} x={x} y={y} distance={distance}>{Type}</object>
<object id={ID} x={x} y={y} distance={distance}>{Type}</object>
<object id={ID} x={x} y={y} distance={distance}>{Type}</object>
<object id={ID} x={x} y={y} distance={distance}>{Type}</object>
</objects>
目标:根据objectArr更新XML节点
objectArr.length = 4 and objectXMl.length() = 4
我是这样做的:
for(var i:int = 0; i < objectXML.length(); i++)
{
objectXML.object[i].@ID = objectArr[i].ID;
objectXML.object[i].@x = objectArr[i].x;
objectXML.object[i].@y = objectArr[i].y;
objectXML.object[i].@distance = objectArr[i].distance;
objectXML.object[i]= objectArr[i].Type;
}
但是 xml 没有根据数组元素进行更新。 我应该选择其他解决方案吗??
如果我需要在删除后更新 xml,我该怎么办?? 为了删除数组我写了这么多
var ID:String = Obj.getObjectId();
for(var i:int=0; i < objectArr.length; i++)
{
if(objectArr[i].objID == ID)
objectArr.splice(i, 1);
}
为了删除 xml 节点,我编写了这段代码 ::
for(var i:int = 0; i<objectXML.object.length();i++)
{
if(objectXML.object.length() && objectXML.object[i].@objID == objectArr[i].objID)
delete objectXML.object[i];
}
但它显示了这个错误
错误 #1010:术语未定义且没有属性。
【问题讨论】:
标签: arrays xml actionscript-3 apache-flex flex4.5