Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 184

Programming actionscript 3.0
Table of Contents

Advertisement

Creating and manipulating bitmaps
The BitmapData class lets you manipulate the pixels of a Bitmap object. This can be a bitmap
that you loaded from a file, or one that you draw exclusively through one of the BitmapData
methods. Each Bitmap object has a
A BitmapData object represents a rectangular array of pixels. You can create a new bitmap
programmatically. The BitmapData constructor lets you create a rectangle with a specified
color, and you can attach that BitmapData object to a new Bitmap object, as shown in the
following example:
var bdWidth:Number = 100;
var bdHeight:Number = 100;
var bdTransparent:Boolean = true;
var bdFillColorARGB:uint = 0xFF007090;
var myBitmapData:BitmapData = new BitmapData(bdWidth,
bdHeight,
bdTransparent,
bdFillColorARGB);
var myBitmap:Bitmap = new Bitmap(myBitmapData);
addChild(myBitmap)
More commonly, however, you will work with bitmap data from a loaded image file. In either
case, the BitmapData class includes methods for working with and modifying the
BitmapData. For example, you can use the
RGB value. For details on properties and methods of the Bitmap and BitmapData class, see
the ActionScript 3.0 Language Reference.
Note that the
bitmapData
BitmapData object, and you can apply different effects and transformations to each Bitmap
object.
Working with SimpleButton objects
In ActionScript 3.0, you can define button behavior through the SimpleButton class. A
SimpleButton has three states:
properties of the SimpleButton object, and they are each DisplayObject objects. For example,
the following class defines a simple text button:
import flash.display.*;
import flash.events.*;
public class TextButton extends SimpleButton
{
public var selected:Boolean = false;
public function TextButton(txt:String)
184
Display Programming
bitmapData
setPixel()
property of multiple Bitmap objects can reference the same
,
upState
downState
property that is a BitmapData object.
method to set a pixel to a specific
, and
. These are each
overState

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents