Search Tutorials
Flash MX hitTest methodUsageMovieclip.hitTest(x, y, shapeflag)
If performing a simple hit test with target, it will still work if written reversed, but it’s not correct. BackgroundI wrote this tutorial after running into problems porting over one of my action
games into OverviewMy action game was a shoot the puck on the goalie/targets type game, in which I had to determine if the puck hit the target (easy) or the goalie (a little more difficult because of legs and arms). The target was a picture a circle inside a movie clip, and the goalie was basically the same. The trouble with the goalie was if it hit between his legs, that had to be a goal. So using the target argument was out, I needed to use x,y, and shapeflag arguments. In this tutorial, I am going to test using both target and shapeflag, mainly because I wanted to know what is possible in a variety of situations. All the code for determining hits resides within the ActionPuck Movie Clip, on frame 6. Commented out are all the examples listed below. Testing using the Target ArgumentThe ‘help’ file in MX says the target usually represents a button or text-entry field. Well, maybe, but I’ve only ever used it to reference another movie clip, so that’s what I’ll test against in this tutorial. On a basic level, testing for a hit using target is the same in MX or Flash 5, however, that’s about where the similarities end. hit1 = _root.TestGoalie.hitTest("_root.ActionPuck"); // if (hit1)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|