03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

hitTest (BitmapData.hitTest method)<br />

public hitTest(firstPoint:Point, firstAlphaThreshold:Number,<br />

secondObject:Object, [secondBitmapPoint:Point],<br />

[secondAlphaThreshold:Number]) : Boolean<br />

Performs pixel-level hit detection between one bitmap image <strong>and</strong> a point, rectangle or other<br />

bitmap image. No stretching, rotation, or other transformation of either object is considered<br />

when doing the hit test.<br />

If an image is an opaque image, it is considered a fully opaque rectangle for this method. Both<br />

images must be transparent images to perform pixel-level hit testing that considers<br />

transparency. When you are testing two transparent images, the alpha threshold parameters<br />

control what alpha channel values, from 0 to 255, are considered opaque.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 8<br />

Parameters<br />

firstPoint:Point - A point that defines a pixel location in the current BitmapData<br />

instance.<br />

firstAlphaThreshold:Number - The highest alpha channel value that is considered opaque<br />

for this hit test.<br />

secondObject:Object - A Rectangle, Point, or BitmapData object.<br />

secondBitmapPoint:Point [optional] - A point that defines a pixel location in the second<br />

BitmapData object. Use this parameter only when the value of secondObject is a<br />

BitmapData object.<br />

secondAlphaThreshold:Number [optional] - The highest alpha channel value that is<br />

considered opaque in the second BitmapData object. Use this parameter only when the value<br />

of secondObject is a BitmapData object <strong>and</strong> both BitmapData objects are transparent.<br />

Returns<br />

Boolean - A Boolean value. If there is a hit, returns a value of true; otherwise, false.<br />

Example<br />

The following example shows how to determine if a BitmapData object is colliding with a<br />

MovieClip.<br />

import flash.display.BitmapData;<br />

import flash.geom.Point;<br />

var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);<br />

324 <strong>ActionScript</strong> classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!