Copy link to clipboard
Copied
Hi there.
I am having an array of movieclips and when my circle(controlled with the keyboard) hitTests true with one of the movieclips inside that array i want to remove that movieclip from the array so when i hitTest it again it returns false (I hitTest using a "for in" with that array).
How do i remove a specific item from within an array?
Can someone help me? Thanks a lot.
try:
yourArray.splice(yourArray.indexOf(yourmovieclip),1);
Copy link to clipboard
Copied
try:
yourArray.splice(yourArray.indexOf(yourmovieclip),1);
Copy link to clipboard
Copied
You may need to run around the array to find the one to remove, but once you know where it is, you use splice:
mcArray.splice(indexOfOneToRemove,1);
So, if the one you want to get rid of is in the 10th position, indexoFOneToRemove would equal 9. The 1 dictates how many things from that point onwards that you want to remove. Afterwards, mcArray would be like it was, but now missing the items you spliced.
Copy link to clipboard
Copied
As Mr. kglad says, indeOf() would be a quick way to locate the movieclip in the array.
Copy link to clipboard
Copied
Yep.
That is what i did. Thanks anyway you guys are always helpful. I Looked through all the methods of the array class and didn't found a specific one for my purpose. Then i posted this discussion and then i looked more closely to the splice method.
Thanks guys.
Copy link to clipboard
Copied
Thanks for those "helpful" stars, even though I misspelled indexOf. You could give kglad the Solved check mark if you like, as what he wrote was exactly right. Mind you, it's not that he needs the points!
Copy link to clipboard
Copied
thanks.
but what are these points for anyway? do they mean anything?
and do you think this latest version of the adobe forums is an improvement on the previous version?
Copy link to clipboard
Copied
Some things about the new forum are nice, and one or two things are not as good. For example, in the old forum I could easily see a list of the threads that I had participated in, now I don't think I can.
The points system is to encourage helpful people like us to keep on helping, and it also lets people asking questions have a sense of whether the answer they just got was from someone who usually gives good answers.
Copy link to clipboard
Copied
i haven't noticed anyone showing deference because of the points. in fact, i've seen some people (a minority, to be sure) be just obnoxious about it. i never encountered that before: some people feel they have power because they can dole out points.
but overall i agree with you: the loss of the list of threads i am participating in, along with the most recent posters name, is a significant drawback of the new forums. and there's nothing new in these forums that offsets that drawback.
in addition, i think we've lost way more than 1/2 the older threads. that's a lot of information that's no longer available.
Copy link to clipboard
Copied
I marked kglad as correct answer. The new forums have your stuff where you can see all the threads you participated in.
Se you around guys.