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 tofalse
if not supplied. Note thatshapeFlag
may be used only with thex
andy
arguments, not thetarget
argument. It is meaningful only whenmc
has an irregular contour or a hole like a donut; it has no effect ifmc
is 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,target
may 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
shapeFlag
property isfalse
and the point (x, y) on the main Stage intersects with any pixel in the bounding box ofmc
. The bounding box ofmc
is the smallest rectangle that can encompass every occupied pixel ofmc
.
Any pixel in the bounding box of
target ...
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.