hitTest fails after loadMovie

Hi people,

  • I have a movie which checks for a hitTest between a red ball and a blue
    square. If I trace it, it says TRUE
  • if I load this movie in a main swf with loadMovie(“game.swf”,gameMC), the
    trace says FALSE!

the gameMC is at x=50 and y=50. If I put it at x=0, y=0… it works!

So, there must be something with x- and y-coordinates. I cannot figure out
after 2 full days what is wrong!

I’ve checked:

  • I do not use any _root or references in the game.swf
  • I traced the _x and _y of the ball and the square, they give same results
    in both cases!


Kind regards

Post your fla(s)?


Ok, I’ve posted the fla’s. stripped down to very basic, 1 frame each.

the main movie: www.formedia.nl/hittest/game.fla
the movie to load: www.formedia.nl/hittest/test.fla

And still looking for answer :slight_smile:

Works fine here:)
You’re aware that you check the hitTest between the ball mc and the square x/y coordinates?


It gives true when you check it in the original movie, and when loading it in the main movie? How can that be, do you have another Flash MX?

I’m aware of the x/y coordinates, it requires that in my movie. If it works in the movie itself, it should work in the main movie, I think :slight_smile: But I will try to find another way to solve it then

Maybe I’m getting you wrong, but have a look at my example;)


Yes. Do you notice how they are not the same?
situation 1: game.swf loaded in main movie
situation 2: game.swf

In your fla’s : situation 1 gives the Been Hit signal much later than in situation 2.
It becomes more clear when you put the blue ball over the red square and trace it in both movies. One says: been hit, the other not hit.

Do you see the difference?

You’re right :blush:
If you look in AS dictionary

Availability Flash Player 5.


my_mc.hitTest(x:Number, y:Number, shapeFlag:Boolean) : Boolean
my_mc.hitTest(target:Object) : Boolean


xThe x coordinate of the hit area on the Stage.
The y coordinate of the hit area on the Stage.

The x and y coordinates are defined in the global coordinate space

I think the last line is what’s making it go wrong.
I guess you have to look for localToGlobal or globalToLocal, but I never got those two working properly [size=1](But that says more about me then about those functions, LOL)[/size]