0
更新陣列節點I有一個陣列等:使用關聯數組
> 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
objectArr.length = 4 and objectXMl.length() = 4
更新XML節點我這樣做了:
for(var i:int = 0; i < objectXML.length(); i++)
{
objectXML.object[i][email protected] = objectArr[i].ID;
objectXML.object[i][email protected] = objectArr[i].x;
objectXML.object[i][email protected] = objectArr[i].y;
objectXML.object[i][email protected] = objectArr[i].distance;
objectXML.object[i]= objectArr[i].Type;
}
但xml沒有按照數組元素進行更新。 我應該選擇其他解決方案嗎?
如果我需要更新xml刪除後應該怎麼做? 用於刪除數組我寫我寫這個代碼::
for(var i:int = 0; i<objectXML.object.length();i++)
{
if(objectXML.object.length() && objectXML.object[i][email protected] == objectArr[i].objID)
delete objectXML.object[i];
}
此多
var ID:String = Obj.getObjectId();
for(var i:int=0; i < objectArr.length; i++)
{
if(objectArr[i].objID == ID)
objectArr.splice(i, 1);
}
並刪除XML節點,但它示出了該誤差
錯誤#1010:甲術語是未定義的並且沒有屬性。
謝謝對於這....只是一個愚蠢的錯誤,但花了我很多時間...我只是忘了檢查長度... – subrat71
很高興知道它幫助:) –
我編輯了問題因此,我取消選擇接受的標記...所以在我得到我的答案後,我會選擇你的答案爲正確的。 – subrat71