Google says that:
displayObject.hitTest(stage.mouseX, stage.mouseY, true)
is the way to test for the mouse being over a DisplayObject开发者_运维问答. This works if my movie is displayed at 100% scale. But if maximise my browser window so the Flash movie changes scale, it all goes to pieces.
Does anyone have a way to fix this, please?
Many thanks.
I normally use:
stage.addEventListener(MouseEvent.MOUSE_OVER, functionName);
But, if you have a specific reason for using the hitTest method, than you may want to look into converting your point from a global to a local MovieClip coordinate. Once you scale a MovieClip, it's x-y coordinates are no longer mapped 1-to-1 to the stage coordinates. BUT, you can make Flash figure out which coordinate you ARE talking about by using:
yourMovieClip.globalToLocal( yourTestPoint )); // [x=-10, y=0]
Here is the related link with all the documentation...
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html
You may also want to take a look at the "hitTestObject()" method which does the same thing as hitTestPoint, only using the entire object... no points!
hope this helps.
精彩评论