This content has been marked as final. Show 10 replies
First I wouldn't define the remove() function inside the onEnterFrame(). There is no reason to define that method 30 times a second or what have you. I would move that out of there perhaps making it a private method.
After that I would make sure that the hitTest is working. So inside that I would add a trace like:
trace(this+" has hit "+_root.player);
Next I would see that it was getting called and where it thought it was. So in the remove() function I would add a trace like this:
trace("Should be deleting: "+this);
Finally there are some special issues regarding depth of movieclips and whether they can be removed. So if everything else is working out I would trace the depth of your item.
neat, I learned what a trace does :). And everything works perfectly fine. So what should i do about the depth for the code, or some such thing?
--edit-- thanks for the quick reply --edit--
Glad you learned about trace, it is a learner's best friend.
I'm confused. Everything is working? Or you are getting the hits and scope traces, but it still isn't being removed?
In any event check the MovieClip class documentation for the getDepth() method. Trace that out and what do you get?
its just the removing of the movieclip that wont work! I will try and learn about the getdepth() thingy :). Thank you for all your help.
Alright, the depth is "-16289"!
That means that it is a clip you placed during authortime on the stage, right? You cannot use removeMovieClip on clips like that. You can only use them on clips that come from attachMovieClip or duplicateMovieClip.
It is also possible to swapDepths to a positive value and then remove it. But if your timeline loops then you will have other problems.
Ok thank you. I will fix this with the info you have given me! You are awesome!
THANK YOU SO MUCH(sorry for caps!) I was able to change the depth and now everything is functional! YIIIIPEEEEEEE!!!!
Be very careful. It generally isn't a good idea to use removeMovieClip() with timeline placed artwork. Generally if you plan to use a dynamic remove it is better to dynamically place the item as well.
Ok, thank you for the warning!