Skip to main content
June 6, 2006
Answered

Array confusion

Hi,

I have a problem with my array function, moveover, I don't understand why this is not working. I am defining 2 arrays in the code below and performing a hitTest to try and detect which object in the clip2 array that clip1 is actually hitting, when the hitTest is performed, the trace output traces out all 33 items instead of the specific item. If any1 could help me to understand what i am doing wrong, I would be very thankful.

Thanks for looking at my post,
~Brandine
This topic is closed to new replies. Start a new post to keep the conversation going.
2m91_2
2m91_2Correct answer
Inspiring
June 8, 2006
I havent used it in a long time but if I remember it corectly it should give you the clip that is under your mouse - would be the logical thing to do at least and it would almost certainly "feel" right this way.

edit:
It does behave that way, the only ploblem is, if you drag the floating item at its corner, drag it 90% over the target-clip, but the mouse isn't over the clip it won't work - but then you might have a hard time with any other solution.
Draging the object by the center only will help, but to make it real usable a visual feedback (highlightnig) before dropping would really be useful I guess.

6 replies

2m91_2
2m91_2Correct answer
Inspiring
June 8, 2006
I havent used it in a long time but if I remember it corectly it should give you the clip that is under your mouse - would be the logical thing to do at least and it would almost certainly "feel" right this way.

edit:
It does behave that way, the only ploblem is, if you drag the floating item at its corner, drag it 90% over the target-clip, but the mouse isn't over the clip it won't work - but then you might have a hard time with any other solution.
Draging the object by the center only will help, but to make it real usable a visual feedback (highlightnig) before dropping would really be useful I guess.
Translate
June 8, 2006
!w000t! Thx guys for the replies. _droptraget did the trick. Like you guys mentioned in the later posts, I'll have to finesse it a bit. I ended up putting the code on the actual mc(piece to be moved), added a bit more code, and now it's working perfectly. Thanks again guys,

~Brandine

p.s. - The code below sorted me out
Translate
Inspiring
June 6, 2006
I think there's something wrong with the logic in this code: it does a hittest for wk_array[1] and my_array[1], then for wk_array[2] and my_array[2] and so on. If the objects with matching numbers overlap, every hittest returns true and it will trace all 32 clips.
I guess you wanted to do a hittest of 1 object from array 1 with all objects of array 2, so you should define clip1 before the loop starts, like in the attached code. If you wanted something else, please explain in more detail.

hth,
blemmo

Translate
June 7, 2006
hey blemmo,

Thx for the response. That still didn't sort my problem out, I will try to provide more detail. Here's the goal:

I have a grid built on the stage, made up of 32 squares, represented by wk_array(clip1). I also have 32 draggable pieces, represented by my_array(clip2). When I let go of one of the draggable pieces, I want to be able to trace back the individual square that the individual piece is hitting. This is not the way to do it: :)

//perform hitTest
_root.onMouseUp=function(){
for (i:Number = 1; i < 33; i++) {
clip1=eval(wk_array[ i ]);
clip2=eval(my_array[ i ]);
if(clip2.hitTest(clip1)){
trace(clip1);
}
}
}

This traces back the entire list, and I agree with you, something is wroing with the logic. I am struggling to understand how this logic works. Thanks for any help.

~Brandine
Translate
2m91_2
Inspiring
June 7, 2006
take a look at "MovieClip._droptarget" in the docs should help - if not for some reason I'll take acloser look at the script. OK?
Translate