I have a array originated in a loop like this:
var arr:Array = [0,1,0,0,0,0,0,2];
var objectArr:Array = new Array();
for(i = 0; i<arr.length; i++) {
if(arr* != 0) {
var newNpc:Npc = new Npc(arr*)
objectArr.push(newNpc);
}else{
objectArr.push(0);
}
and i want to, later on, change the position of a npc in the array and set the old position to zero, like:
Before: [0,objectNpc,0,0,0,0,0,objectNpc];
After: [0,0,0,0,objectNpc,0,0,objectNpc];
I tried using splice(), but the objectNpc in the new position then has all his properties undefined instead of being the same as it was in the other position.