I’m looking at the Adobe documentation here and it’s not clear.
Since I’m having an issue with my app I’m wondering if it could be because I’m evaluating two sprites, one that is on the stage and the other that is created but no addChild’ed
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually, the answer depends on which platform you are targeting. In FlashPlayer, hitTestObject just checks if the bounding boxes of the objects overlap, so as long as you have the correct x and y positions and the correct width and height for your objects you don’t need them to actually be on the stage.
However, in AIR, probably some kind of code optimization is taking place, and if one of the objects is not actually on the stage it will return false
Let’s just tinker a little with the example from the docs, removing just one addChild:
In FP10 we get the following output:
However, in AIR we get:
The key difference is that hitTestObject between the circle1 and circle2 is false in AIR because circle1 has not been added to the stage, but in FlashPlayer is true anyways. Thanks to @user1113426 for pointing there was something amiss here!