FlashMX hit test

  • XLax
  • Novice
  • Novice
  • User avatar
  • Posts: 21

Post 3+ Months Ago

I've posted this before, but the thread disappeared O.O

I want to know if there's a way to make a hitTest() function that returns the _name of the movie clip that collides with the point I'm determining

Flash MX
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

so ... what you want to do is to know all movieclips that overlaps a point?
because hitTest(x,y, shapeFlag) only tests the given mc.
i.e.: if (mc.hitTest(x, y, true)) { trace("collides"); } else { trace("doesnt collide");}
So this means you know exactly which movieclip you test.
If you try to test all movieclips nested in a given movieclip,
then you can try
Code: [ Select ]
for (obj in givenMC)
{
    if (typeof(givenMC[obj]) == "movieclip")
    {
       if (givenMC[obj].hitTest(x,y,true) { trace (obj + " collides"); }
    }
}
  1. for (obj in givenMC)
  2. {
  3.     if (typeof(givenMC[obj]) == "movieclip")
  4.     {
  5.        if (givenMC[obj].hitTest(x,y,true) { trace (obj + " collides"); }
  6.     }
  7. }

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.