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.

import flash.geom.ColorTransform;<br />

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

var mc:MovieClip = this.createEmptyMovieClip("mc",<br />

this.getNextHighestDepth());<br />

mc.attachBitmap(myBitmapData, this.getNextHighestDepth());<br />

mc.onPress = function() {<br />

myBitmapData.colorTransform(myBitmapData.rectangle, new<br />

ColorTransform(1, 0, 0, 1, 255, 0, 0, 0));<br />

}<br />

See also<br />

ColorTransform (flash.geom.ColorTransform), Rectangle (flash.geom.Rectangle)<br />

compare (BitmapData.compare method)<br />

public compare(otherBitmapData:BitmapData) : Object<br />

Compares two BitmapData objects. If the two BitmapData objects have the same dimensions<br />

(width <strong>and</strong> height), the method returns a new BitmapData object, in which each pixel is the<br />

"difference" between the pixels in the two source objects:<br />

■ If two pixels are equal, the difference pixel is 0x00000000.<br />

■ If two pixels have different RGB values (ignoring the alpha value), the difference pixel is<br />

0xFFRRGGBB where RR/GG/BB are the individual difference values between red, green,<br />

<strong>and</strong> blue channels. Alpha channel differences are ignored in this case.<br />

■ If only the alpha channel value is different, the pixel value is 0xZZFFFFFF, where ZZ is<br />

the difference in the alpha value.<br />

For example, consider the following two BitmapData objects:<br />

var bmd1:BitmapData = new BitmapData(50, 50, true, 0xFFFF0000);<br />

var bmd2:BitmapData = new BitmapData(50, 50, true, 0xCCFFAA00);<br />

var diffBmpData:BitmapData = bmd1.compare(bmd2);<br />

Note: The colors used to fill the two BitmapData objects have slightly different RGB values<br />

(0xFF0000 <strong>and</strong> 0xFFAA00). The result of the compare() method is a new BitmapData<br />

object with each pixel showing the difference in the RGB values between the two bitmaps.<br />

Consider the following two BitmapData objects, in which the RGB colors are the same, but<br />

the alpha values are different:<br />

var bmd1:BitmapData = new BitmapData(50, 50, true, 0xFFFFAA00);<br />

var bmd2:BitmapData = new BitmapData(50, 50, true, 0xCCFFAA00);<br />

var diffBmpData:BitmapData = bmd1.compare(bmd2);<br />

310 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!