ActionScript 2.0 Language Reference for Macromedia Flash 8 - page 26


Color

Object

  |

  +-Color



public class Color

extends Object

Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class.

The Color class lets you set the RGB color value and color transform of movie clips and retrieve those values once they have been set.

You must use the constructor new Color() to create a Color object before calling its methods.

Availability: ActionScript 1.0; Flash Player 5

Property summary

Properties inherited from class Object

constructor (Object.constructor property),

  __proto__ (Object.__proto__

property), prototype (Object.prototype property),

  __resolve

(Object.__resolve property)


Constructor summary

Signature

Description

Color(target:Object)

Class Deprecated.

Creates a Color object for the movie clip specified by the target_mc parameter.


Method summary

Modifiers

Signature

Description

 

getrGB() : Number

Class Deprecated.

Returns the R+G+B combination currently in use by the color object.

 

gettransform() : Object

Class Deprecated.

Returns the transform value set by the last Color.setTransform() call.

 

setRGB(offset:Number) : Void

Class Deprecated.

Specifies an RGB color for a Color object.

 

setTransform(transformObject:Object) : Void

Class Deprecated.

Sets color transform information for a Color object.


Methods inherited from class Object

addProperty (Object.addProperty method),

  hasOwnProperty

(Object.hasOwnProperty method), isPropertyEnumerable

(Object.isPropertyEnumerable method),

  isPrototypeOf (Object.isPrototypeOf

method), registerClass (Object.registerClass

  method), toString

(Object.toString method), unwatch (Object.unwatch

  method), valueOf

(Object.valueOf method), watch (Object.watch method)


Color constructor

public Color(target:Object)

Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class.

Creates a Color object for the movie clip specified by the target_mc parameter. You can then use the methods of that Color object to change the color of the entire target movie clip.

Availability: ActionScript 1.0; Flash Player 5

Parameters

target:Object - The instance name of a movie clip.

Example

The following example creates a Color object called my_color for the movie clip my_mc and sets its RGB value to orange:

var my_color:Color = new Color(my_mc);

my_color.setRGB(0xff9933);

getRGB (Color.getRGB method)

public getRGB() : Number

Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class.

Returns the R+G+B combination currently in use by the color object.

Availability: ActionScript 1.0; Flash Player 5

Returns

Number - A number that represents the RGB numeric value for the color specified.

Example

The following code retrieves the RGB value for the Color object my_color, converts the value to a hexadecimal string, and assigns it to the myValue variable. To see this code work, add a movie clip instance to the Stage, and give it the instance name my_mc:

var my_color:Color = new Color(my_mc);

// set the color

my_color.setRGB(0xff9933);

var myValue:String = my_color.getRGB().toString(16);

// trace the color value

trace(myValue); // traces ff9933

See also

setRGB (Color.setRGB method), rgb (ColorTransform.rgb property)

getTransform (Color.getTransform method)

public getTransform() : Object

Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class.

Returns the transform value set by the last Color.setTransform() call.

Availability: ActionScript 1.0; Flash Player 5

Returns

Object - An object whose properties contain the current offset and percentage values for the specified color.

Example

The following example gets the transform object, and then sets new percentages for colors and alpha of my_mc relative to their current values. To see this code work, place a multicolored movie clip on the Stage with the instance name my_mc. Then place the following code on Frame 1 in the main Timeline and select Control > Test Movie:

var my_color:Color = new Color(my_mc);

var myTransform:Object = my_color.getTransform();

myTransform = { ra: 50, ba: 50, aa: 30};

my_color.setTransform(myTransform);

For descriptions of the parameters for a color transform object, see Color.setTransform().

See also

setTransform (Color.setTransform method)

setRGB (Color.setRGB method)

public setRGB(offset:Number) : Void

Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class.

Specifies an RGB color for a Color object. Calling this method overrides any previous Color.setTransform() settings.

Availability: ActionScript 1.0; Flash Player 5

Parameters

offset:Number - 0xRRGGBB The hexadecimal or RGB color to be set. RR, GG, and BB each consist of two hexadecimal digits that specify the offset of each color component. The 0x tells the ActionScript compiler that the number is a hexadecimal value.

Example

This example sets the RGB color value for the movie clip my_mc. To see this code work, place a movie clip on the Stage with the instance name my_mc. Then place the following code on Frame 1 in the main Timeline and select Control > Test Movie:

var my_color:Color = new Color(my_mc);

my_color.setRGB(0xFF0000); // my_mc turns red

See also

setTransform (Color.setTransform method), rgb (ColorTransform.rgb property)

setTransform (Color.setTransform method)

public setTransform(transformObject:Object) : Void

Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class.

Sets color transform information for a Color object. The colorTransformObject parameter is a generic object that you create from the new Object constructor. It has parameters specifying the percentage and offset values for the red, green, blue, and alpha (transparency) components of a color, entered in the format 0xRRGGBBAA.

The parameters for a color transform object correspond to the settings in the Advanced Effect dialog box and are defined as follows:

  • ra is the percentage for the red component (-100 to 100).

  • rb is the offset for the red component (-255 to 255).

  • ga is the percentage for the green component (-100 to 100).

  • gb is the offset for the green component (-255 to 255).

  • ba is the percentage for the blue component (-100 to 100).

  • bb is the offset for the blue component (-255 to 255).

  • aa is the percentage for alpha (-100 to 100).

  • ab is the offset for alpha (-255 to 255).

You create a colorTransformObject parameter as follows:

var myColorTransform:Object = new Object();

 myColorTransform.ra = 50;

 myColorTransform.rb = 244;

 myColorTransform.ga = 40;

 myColorTransform.gb = 112;

 myColorTransform.ba = 12;

 myColorTransform.bb = 90;

 myColorTransform.aa = 40;

 myColorTransform.ab = 70;

You can also use the following syntax to create a colorTransformObject parameter:

var myColorTransform:Object = { ra: 50, rb: 244, ga: 40, gb: 112, ba: 12,

  bb: 90, aa: 40, ab: 70}

Availability: ActionScript 1.0; Flash Player 5

Parameters

TRansformObject:Object - An object created with the new Object constructor. This instance of the Object class must have the following properties that specify color transform values: ra, rb, ga, gb, ba, bb, aa, ab. These properties are explained below.

Example

This example creates a new Color object for a target SWF file, creates a generic object called myColorTransform with the properties defined above, and uses the setTransform() method to pass the colorTransformObject to a Color object. To use this code in a Flash (FLA) document, place it on Frame 1 on the main Timeline and place a movie clip on the Stage with the instance name my_mc, as in the following code:

// Create a color object called my_color for the target my_mc

var my_color:Color = new Color(my_mc);

// Create a color transform object called myColorTransform using

// Set the values for myColorTransform

var myColorTransform:Object = { ra: 50, rb: 244, ga: 40, gb: 112, ba: 12,

  bb: 90, aa: 40, ab: 70};

// Associate the color transform object with the Color object

// created for my_mc

my_color.setTransform(myColorTransform);

See also

Object