View Full Version : arg, stupid onClipEvents!
GW02
April 16th, 2003, 08:56 PM
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!!!
senocular
April 16th, 2003, 09:06 PM
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)
GW02
April 16th, 2003, 11:01 PM
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....
upuaut
April 17th, 2003, 12:19 AM
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.
GW02
April 17th, 2003, 01:36 PM
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?
GW02
April 17th, 2003, 01:42 PM
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!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.