Color.getTransform( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Color.getTransform( ) Method Flash 5

retrieve both the current offset and percentage values for a clip's Red, Green, Blue, and Alpha components
colorObj.getTransform()

Returns

An object whose properties contain the color transformation values for the target clip of colorObj.

Description

The getTransform( ) method returns an object containing properties that tell us which transformations are currently applied to the target of a Color object. That is, it returns multiple individual values, wrapped in an object for convenience. The returned object is a instance of the generic Object class; it is not a Color object. The property names and values of the returned object are described in Table 18-5.

Table 18-5. Properties of object returned by getTransform( )

Property name

Property value

Property description

ra

-100 to 100

The Red transformation percentage

rb

-255 to 255

The Red offset amount

ga

-100 to 100

The Green transformation percentage

gb

-255 to 255

The Green offset amount

ba

-100 to 100

The Blue transformation percentage

bb

-255 to 255

The Blue offset amount

aa

-100 to 100

The Alpha transformation percentage

ab

-255 to 255

The Alpha offset amount

Usage

Note in Table 18-5 that both the percentage and the offset can have negative values; although negative percentages aren't meaningful in isolation, they can be factored in when calculating the RGB color components, which always range from 0 to 255. Values outside that range are clipped to the allowable range. See the Color class description for an explanation of the calculation used to determine final RGB and Alpha color components.

Example

We can use getTransform( ) in combination with setTransform( ) to modify the Red, Green, Blue, or Alpha components of a color transformation individually. For example, in the following code, we adjust the Red and Alpha components of a clip named box:

// Create a new Color object for a clip named box boxColor = new Color("box");     // Assign the return object of getTransform( ) to boxTransform boxTransform = boxColor.getTransform();     // Now, make some modifications to the transform object's properties boxTransform.rb = 200;      // Set Red offset to 200 boxTransform.aa = 60;       // Set Alpha percentage to 60     // Apply the new transformations to box via boxColor boxColor.setTransform(boxTransform);

See Also

Color.setTransform( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

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