Skip to main content
Participant
June 7, 2006
Answered

Help with hitTest

I have a movie clip that drags over several other movie clips. These other movie clips have various names and were not created by an array or any other dynamic means. So here's my question. Is there a way to get the name of these movie clips when I drag the original clip over them. I though I could get it with hitTest, but so far no luck.
This topic is closed to new replies. Start a new post to keep the conversation going.
TimAndrodneyCorrect answer
Participant
June 8, 2006
Alright, I got it. I was looking at it backwards. Rather having one MC figure out the names of the rest of the MC's, I created an element clip that I placed within each of clips I was trying to get that name for and did the hitTest to the one that's draggable.

I should be ashamed of myself...

6 replies

TimAndrodneyAuthorCorrect answer
Participant
June 8, 2006
Alright, I got it. I was looking at it backwards. Rather having one MC figure out the names of the rest of the MC's, I created an element clip that I placed within each of clips I was trying to get that name for and did the hitTest to the one that's draggable.

I should be ashamed of myself...
Translate
Known Participant
June 8, 2006
then do _children.your_mc
Translate
Participant
June 7, 2006
OK it works, except...

The clips I need to get the names from are inside a larger movie clip, but also within seperate movie clips in the larger one. Is there a way I could get them two levels in? To use your example, something like:

for (var n in mcHolder._children){

The "_children" being the movies that are in the larger movie clip, but contain the clips I'm trying to get the names from.
Translate
Participant
June 7, 2006
Actually, I think I got it. ...Maybe. I had a ")" missing in the code.
Translate
Participant
June 7, 2006
Thanks Fleece, I tried the first way because I can't use an array for this but I get this error:

**Error** Symbol=periodic_activator, layer=Layer 1, frame=1:Line 6: ')' expected
if(this.hitTest(_root.periodic_table){

Total ActionScript Errors: 1 Reported Errors: 1

Any thoughts?

Thanks Again.
Translate
June 7, 2006
if you put the mc that are not dragged in an mc called mcHolder, you could do this:

dragged_mc.onMouseMove = function () {
for (var n in mcHolder){
if(typeof(mcHolder)=="movieclip"){
if(this.hitTest(mcHolder){
trace(mcHolder._name)
}
}
}
}

or if in different locations, you could indeed push them onto an array and loop through that...

mcArray:Array = new Array()
mcArray.push(mc_1)
mcArray.push(mc_2)
mcArray.push(mc_3)
//
dragged_mc.onMouseMove = function () {
for (var n in mcArray){
if(this.hitTest(mcArray){
trace(mcArray._name)
}
}
}
Translate