BitmapInstance object

 < Day Day Up > 

Inheritance Element object > Instance object > BitmapInstance object

Availability

Flash MX 2004.

Description

The BitmapInstance object is a subclass of the Instance object and represents a bitmap in a frame (see Instance object).

Method summary for the BitmapInstance object

In addition to the Instance object methods, you can use the following methods with the BitmapInstance object:

Method

Description

bitmapInstance.getBits()

Lets you create bitmap effects by getting the bits out of the bitmap, manipulating them, and then returning them to Flash.

bitmapInstance.setBits()

Sets the bits of an existing bitmap element.


Property summary for the BitmapInstance object

In addition to the Instance object properties, you can use the following properties with the BitmapInstance object.

Property

Description

bitmapInstance.hPixels

Read-only; an integer that represents the width of the bitmap, in pixels.

bitmapInstance.vPixels

Read-only; an integer that represents the height of the bitmap, in pixels.


bitmapInstance.getBits()

Availability

Flash MX 2004.

Usage

bitmapInstance.getBits()

Parameters

None.

Returns

An object that contains width, height, depth, bits, and, if the bitmap has a color table, cTab properties. The bits element is an array of bytes. The cTab element is an array of color values of the form "#RRGGBB". The length of the array is the length of the color table.

The byte array is meaningful only when referenced by a DLL or shared library. You typically use it only when creating an extensible tool or effect. For information on creating DLLs for use with Flash JavaScript, see Chapter 3, "C-Level Extensibility."

Description

Method; lets you create bitmap effects by getting the bits out of the bitmap, manipulating them, and then returning them to Flash. See also bitmapInstance.setBits().

Example

The following code creates a reference to the currently selected object; tests whether the object is a bitmap; and traces the height, width, and bit depth of the bitmap:

var isBitmap = fl.getDocumentDOM().selection[0].instanceType; if(isBitmap == "bitmap"){   var bits = fl.getDocumentDOM().selection[0].getBits();   fl.trace("height = " + bits.height);   fl.trace("width = " + bits.width);   fl.trace("depth = " + bits.depth); }

See also

bitmapInstance.setBits()

bitmapInstance.hPixels

Availability

Flash MX 2004.

Usage

bitmapInstance.hPixels

Description

Read-only property; an integer that represents the width of the bitmap that is, the number of pixels in the horizontal dimension.

Example

The following code retrieves the width of the bitmap in pixels:

// Get the number of pixels in the horizontal dimension. var bmObj = fl.getDocumentDOM().selection[0]; var isBitmap = bmObj.instanceType; if(isBitmap == "bitmap"){   var numHorizontalPixels = bmObj.hPixels; }

See also

bitmapInstance.vPixels

bitmapInstance.setBits()

Availability

Flash MX 2004.

Usage

bitmapInstance.setBits(bitmap)

Parameters

bitmap An object that contains height, width, depth, bits, and cTab properties. The height, width, and depth properties are integers. The bits property is a byte array. The cTab property is required only for bitmaps with a bit depth of 8 or less and is a string that represents a color value in the form "#RRGGBB".

Note

The byte array is meaningful only when referenced by an external library. You typically use it only when creating an extensible tool or effect.


Returns

Nothing.

Description

Method; sets the bits of an existing bitmap element. This lets you create bitmap effects by getting the bits out of the bitmap, manipulating them, and then returning the bitmap to Flash.

Example

The following code tests whether the current selection is a bitmap, and then sets the height of the bitmap to 150 pixels:

var isBitmap = fl.getDocumentDOM().selection[0].instanceType; if(isBitmap == "bitmap"){   var bits = fl.getDocumentDOM().selection[0].getBits();   bits.height = 150;   fl.getDocumentDOM().selection[0].setBits(bits); }

See also

bitmapInstance.getBits()

bitmapInstance.vPixels

Availability

Flash MX 2004.

Usage

bitmapInstance.vPixels

Description

Read-only property; an integer that represents the height of the bitmap that is, the number of pixels in the vertical dimension.

Example

The following code gets the height of the bitmap in pixels:

// Get the number of pixels in the vertical dimension. var bmObj = fl.getDocumentDOM().selection[0]; var isBitmap = bmObj.instanceType; if(isBitmap == "bitmap"){   var numVerticalPixels = bmObj.vPixels; }

See also

bitmapInstance.hPixels

     < Day Day Up > 


    Developing Extensions for Macromedia Flash 8
    Developing Extensions for Macromedia Flash 8
    ISBN: 032139416X
    EAN: 2147483647
    Year: 2005
    Pages: 81

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net