Movieclip.hittest() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

MovieClip.hitTest()

Availability
Flash Player 5.
Usage
my_mc.hitTest(x:Number, y:Number, shapeFlag:Boolean) : Boolean
my_mc.hitTest(target:Object) : Boolean
Parameters
The x coordinate of the hit area on the Stage.
x
The y coordinate of the hit area on the Stage.
y
The x and y coordinates are defined in the global coordinate space.
The target path of the hit area that may intersect or overlap with the instance specified
target
by
. The
my_mc
target
A Boolean value specifying whether to evaluate the entire shape of the specified
shapeFlag
instance (
), or just the bounding box (
true
area is identified using
Returns
A Boolean value of
Description
Method; evaluates the instance specified by
area identified by the
Usage 1: Compares the
instance, according to the
occupied by the instance on the Stage is evaluated, and if
is returned. This is useful for determining if the movie clip is within a specified hit or
true
hotspot area.
Usage 2: Evaluates the bounding boxes of the
they overlap or intersect at any point.
Example
The following example uses
intersects the movie clip
square_mc.onPress = function() {
this.startDrag();
};
square_mc.onRelease = function() {
this.stopDrag();
if (this.hitTest(circle_mc)) {
trace("you hit the circle");
}
};
534
Chapter 2: ActionScript Language Reference
parameter usually represents a button or text-entry field.
and
coordinate parameters.
x
y
if
overlaps with the specified hit area,
true
my_mc
or
and
coordinate parameters.
target
x
y
and
coordinates to the shape or bounding box of the specified
x
y
setting. If
shapeFlag
to determine if the movie clip
hitTest()
when the user releases the mouse button:
square_mc
). This parameter can be specified only if the hit
false
to see if it overlaps or intersects with the hit
my_mc
is set to
shapeFlag
and
x
y
and specified instance, and returns
target
otherwise.
false
, only the area actually
true
overlap at any point, a value of
overlaps or
circle_mc
if
true

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flash mx

Table of Contents