ForumsProgramming ForumNeed help

3 2603
No_Thumbs
offline
No_Thumbs
20 posts
Nomad

how do i detect the closest movieclip to a certain Point

  • 3 Replies
LonLonRanch
offline
LonLonRanch
172 posts
Nomad

One way would be to run checks with every movieClip that you're trying to detect in a onEnterFrame type of listener and use the .x and .y values to determine which MC is closest. Something like:

diffx = point.x - mc.x

Could you give an example of how this code would be applied to your game to give a better idea of how it needs to work?

No_Thumbs
offline
No_Thumbs
20 posts
Nomad

I press a button

I add mc

for (var i:int; i< 1; i++) {
mc[i] = new mc();
container.addChild(mc[i]);
}
mc moves around

add more copies of mc

now i want to know which one of the Movie Clips is closest to a certain point

No_Thumbs
offline
No_Thumbs
20 posts
Nomad

don't worry worked it out myself

Showing 1-3 of 3