Arg, stupid onClipEvents!

I have duplicated a movieclip many times.

How do I seperate the onClipEvents for each one… right now when I click on one, all of them respond. How do I seperate it?

AGH!!!

use an if check in the events

onClipEvent(enterFrame){
if (this._name = “origClip”){
// do the stuff
}
}

just make sure not to name the duplicated clips the same name as the original (“origClip” in this example)

Unfortunately, I don’t know exactly which one I’m looking for. Here’s my predicament:

I have a whole bunch of duplicated clips randomly lying on the stage. When one is clicked, I wanna destroy it.

How would I go about that?

I would upload the .fla, but it’s on the other computer…

on(release){
for(obj in _root){
if(_root[obj].hitTest(_xmouse,_ymouse,true){
_root[obj].deleteMovieClip();
}
}
}

This method doesn’t need any buttons associated. It uses a hitTest against the object’s outline, vrs the mouse locations.

There might be some tweeking that will need to be done, but a for…in loop is the way to go when you don’t know what exactly you’re looking for.

Shoot, the code looks like it’s supposed to work, but it’s not figuring out which one to destroy. It senses the release event, but the loop isn’t working, methinks. There was a parenthesis missing that I added and there apparently isn’t a deleteMovieClip so I replaced it with removeMovieClip, but it’s not even going into the if execution at all…

Wait, where am I supposed to put this code?

Okay, I figure it out… I needed to add _root. to the _xmouse and _ymouse properties:


on(press) {
	for(obj in _root){
		if( _root[obj].hitTest(_root._xmouse,_root._ymouse,true) ) {
			_root[obj].removeMovieClip();
		}
	}
}

Thanks all!