1

I'm generating a number of MovieClips and am putting them on the container on random positions... However, it sometimes happens that one MC is almost directly on top of another...

I could solve this easily if I could somehow check if the random-generated x and y are on top of any other MCs x and y...

Any ideas?

Pero44
  • 105
  • 2
  • 10

1 Answers1

3

The hitTestPoint() can tell you if your object is over a specific point:

if (myMovieClip.hitTestPoint(myX,myY) == true)
{
   trace("hit detected");
}

You can also use hitTestObject() to detect a collision or overlap with another movieClip:

if (myMovieClip1.hitTestObject(myMovieClip2) == true)
{
   trace("hit detected");
}
CyanAngel
  • 1,240
  • 1
  • 14
  • 28