Color.setTransform( ) Method

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

assign new offset and/or percentage values for Red, Green, Blue, and Alpha
colorObj.setTransform(transformObject)

Arguments

transformObject

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

Description

The setTransform( ) method gives us precise control over the percentage and offset of the Red, Green, Blue, and Alpha components of a movie clip's color. To use setTransform( ), we must first create an object (normally an instance of the Object class) with a series of predefined properties. The transformation we wish to apply to our Color object is expressed using those properties, which are listed in Table 18-5 for the getTransform( ) method (except that setTransform( ) sets their values rather than reading their values).

Once we have created an object with the properties described in Table 18-5, we pass that object to the setTransform( ) method. The values of the properties on our transformObject become the new offset and percentage transform values of colorObj and, hence, colorObj's target movie clip. The final color values in the clip are then determined according to the calculation discussed under the Color class Description.

To examine the current offsets and percentages of a particular Color object, we use the getTransform( ) method.

Example

// Create a new Color object for the box clip boxColor = new Color("box");     // Create a generic object (not a Color object) and store it in boxTransform boxTransform = new Object();     // Assign the required properties of boxTransform (ra, rb, etc.), setting our // transformation values as desired boxTransform.ra = 50;    // Red percentage boxTransform.rb = 0;     // Red offset boxTransform.ga = 100;   // Green percentage boxTransform.gb = 25;    // Green offset boxTransform.ba = 100;   // Blue percentage boxTransform.bb = 0;     // Blue offset boxTransform.aa = 40;    // Alpha percentage boxTransform.ab = 0;     // Alpha offset     // Now that our transform object has been prepared, pass it to setTransform( )  boxColor.setTransform(boxTransform);

This approach to creating a transform object is fairly labor-intensive. We can generate a new transform object more easily using the getTransform( ) method, as follows:

// Create a new Color object for the box clip boxColor = new Color("box");     // Invoke getTransform() on boxColor, which retrieves a transform object boxTransform = boxColor.getTransform();     // Now alter boxTransform's properties as needed, leaving others unchanged boxTransform.rb = 51;   // Red offset boxTransform.aa = 40;   // Alpha percentage     // Use our transform object with setTransform( ) boxColor.setTransform(boxTransform);

See Also

Color.getTransform( )



    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