I would like to delete a item from my array and still have the same index for every item afterwards.
Example
var arr:Array = new Array();
arr[1] = 'One';
arr[2] = 'Two';
arr[3] = 'Three';
arr.splice(2, 1);
for(var index in arr) {
trace(index+':'+arr[index]);
}
Outputs:
1:One
2:Three
And should ouput
1:One
3:Three
Anyone that could help me a little bit here? 🙂
I found a solution to my problem.
Instead of using a array, i’ll use a object to hold my items. Like this
And when I delete i do like this.
I know I wont get the array functions then. But in my case I don’t need them.