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.

Example<br />

The following example shows how to change the color value of pixels whose color value is<br />

greater than or equal to a certain threshold.<br />

import flash.display.BitmapData;<br />

import flash.geom.Rectangle;<br />

import flash.geom.Point;<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 />

myBitmapData.fillRect(new Rectangle(0, 0, 50, 80), 0x00FF0000);<br />

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

myBitmapData.threshold(myBitmapData, new Rectangle(0, 0, 100, 40), new<br />

Point(0, 0), "==", 0x00CCCCCC, 0x000000FF, 0x00FF0000, false);<br />

}<br />

transparent (BitmapData.transparent property)<br />

public transparent : Boolean [read-only]<br />

Defines whether the bitmap image supports per-pixel transparency. You can set this value only<br />

when you construct a BitmapData object by passing in true for the transparent parameter.<br />

After you create a BitmapData object, you can check whether it supports per-pixel<br />

transparency by seeing if the value of the transparent property is true.<br />

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

Example<br />

The following example shows that the transparent property of the Bitmap instance is readonly<br />

by trying to set it <strong>and</strong> failing:<br />

import flash.display.BitmapData;<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 />

trace(myBitmapData.transparent); // false<br />

myBitmapData.transparent = true;<br />

trace(myBitmapData.transparent); // false<br />

BitmapData (flash.display.BitmapData) 339

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

Saved successfully!

Ooh no, something went wrong!