Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting item in array

Status
Not open for further replies.

sarak

Programmer
May 3, 2001
25
US
More on arrays... :)

I'd like to delete an item from an array that I've been populating with movie clips. I have a variable, mainMC, that stores the name of the movie clip that the user is currently interacting with. When the user clicks a button, I would like mainMC deleted from the array. Because the movie clip referenced by mainMC changes constantly, I can't refer to it by name.

I believe I need to search within the array for the contents of mainMC. However, I've been unsuccessful using indexOf. Has anyone worked through a similar situation and would be willing to shed some light on the steps involved?? Thanks!
 
for (i=0; i<=yourarray.length; i++) {
if (yourarray==mainMC) {
yourarray.splice(i,1)
}
}

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Code:
for (i=0; i<=yourarray.length; i++) {
	if (yourarray[i]==mainMC) {
yourarray.splice(i,1);
	}
}

oops, lets try that as 'code' shall we?

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Thanks for the code, Dave! It's working perfectly... :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top