/ Published in: ActionScript
Expand |
Embed | Plain Text
// Creates Array var myArray:Array = ["item1", "item2", "item3", "item4", "item5"]; // Function function removeItemFromArray( item:String ):Void { trace("Array Original: " + myArray); // Array Lenght var arrayLenght:Number = myArray.length; // Searches item in array for ( i =0; i<arrayLenght; i++ ) { // Finds item and removes it if ( myArray[i] == item ) { myArray.splice( i, 1 ); trace("Item Removed: " + myArray[i] + newline); trace("Array Updated: " + myArray); } } } // Calls Function removeItemFromArray( "item3" );
Comments
Subscribe to comments
You need to login to post a comment.

You should go in reverse that way you can supply more than one item to remove!
var myArray:Array = ["item1", "item2", "item3", "item4", "item5", "item3"];
// Function function removeItemFromArray( item:String ):Void { trace("Array Original: " + myArray);
}
// Calls Function removeItemFromArray( "item3" );
You should go in reverse that way you can supply more than one item to remove!
var myArray:Array = ["item1", "item2", "item3", "item4", "item5", "item3"];
// Function function removeItemFromArray( item:String ):Void { trace("Array Original: " + myArray);
}
// Calls Function removeItemFromArray( "item3" );