Name
MovieClip.hitTest( ) Method — check whether a point is in a clip or two clips intersect
Availability
Flash 5
Synopsis
mc.hitTest(x, y, shapeFlag) mc.hitTest(target)
Arguments
- x
The horizontal coordinate of the point to test.
- y
The vertical coordinate of the point to test.
- shapeFlag
An optional Boolean value indicating whether the collision test should detect against the bounding box of
mc(false) or the actual pixels ofmc(true). Defaults tofalseif not supplied. Note thatshapeFlagmay be used only with thexandyarguments, not thetargetargument. It is meaningful only whenmchas an irregular contour or a hole like a donut; it has no effect ifmcis a solid rectangular object.
- target
A string indicating the path to the movie clip to test for collision with
mc. Because movie clip references are converted to paths when used in a string context,targetmay also be a movie clip object reference, as inmc.hitTest(ball)versusmc.hitTest("ball").
Returns
A Boolean indicating the result of the collision-detection test. The
result is true under any of the following
circumstances:
The point
(x, y)on the main Stage intersects with any occupied pixel ofmc. An occupied pixel is one that contains a visual element, such as a shape or text.
The
shapeFlagproperty isfalseand the point (x, y) on the main Stage intersects with any pixel in the bounding box ofmc. The bounding box ofmcis the smallest rectangle that can encompass every occupied pixel ofmc.
Any pixel in the bounding box of
target ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access