316
ActionScript classes
If an image is an opaque image, it is considered a fully opaque rectangle for this method. Both
images must be transparent images to perform pixel-level hit testing that considers
transparency. When you are testing two transparent images, the alpha threshold parameters
control what alpha channel values, from 0 to 255, are considered opaque.
Availability:
ActionScript 1.0; Flash Player 8
Parameters
firstPoint
:flash.geom.Point
- A point that defines a pixel location in the current
BitmapData instance.
firstAlphaThreshold
:Number
- The highest alpha channel value that is considered opaque
for this hit test.
secondObject
:Object
- A Rectangle, Point, or BitmapData object.
secondBitmapPoint
:flash.geom.Point
[optional] - A point that defines a pixel location in
the second BitmapData object. Use this parameter only when the value of
secondObject
is a
BitmapData object.
secondAlphaThreshold
:Number
[optional] - The highest alpha channel value that is
considered opaque in the second BitmapData object. Use this parameter only when the value
of
secondObject
is a BitmapData object and both BitmapData objects are transparent.
Returns
Boolean
- A Boolean value. If there is a hit, returns a value of
true
; otherwise,
false
.
Example
The following example shows how to determine if a BitmapData object is colliding with a
MovieClip
.
import flash.display.BitmapData;
import flash.geom.Point;
var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
var mc_1:MovieClip = this.createEmptyMovieClip("mc",
this.getNextHighestDepth());
mc_1.attachBitmap(myBitmapData, this.getNextHighestDepth());
var mc_2:MovieClip = createRectangle(20, 20, 0xFF0000);
var destPoint:Point = new Point(myBitmapData.rectangle.x,
myBitmapData.rectangle.y);
var currPoint:Point = new Point();
mc_1.onEnterFrame = function() {
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...