Jay Roy
asked on
Flex - remove element from array
hi guys
I have code like this
myArray contains Objects
myArray [0] = object1;
myArray [1] = object2;
myArray [2] = object3;
myArray [3] = object4;
private function removeAnObjectFromArray(my Array:Arra y,entryToB eRemoved:S tring):voi d{
for(var k:Number=0; k< myArray.length; k++){
if(entryToBeRemoved == myArray[k].id){
//here i want to remove the element from myArray. any ideas?
}
}
}
should i use splice() ?
thanks
I have code like this
myArray contains Objects
myArray [0] = object1;
myArray [1] = object2;
myArray [2] = object3;
myArray [3] = object4;
private function removeAnObjectFromArray(my
for(var k:Number=0; k< myArray.length; k++){
if(entryToBeRemoved == myArray[k].id){
//here i want to remove the element from myArray. any ideas?
}
}
}
should i use splice() ?
thanks
another way you can create a new array and push values what valid for your condition
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can I remove the elements from the array without
change the index of elements?
change the index of elements?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000752.html
shift and unsift will remove from beggining or end