Name

Color.setRGB( ) Method — assign new offset values for Red, Green, and Blue

Availability

Flash 5

Synopsis

colorObj.setRGB(offset);

Arguments

offset

A number in the range 0 to 16777215 (0xFFFFFF), representing the new RGB offsets of colorObj’s target clip. May be a decimal integer or a hexadecimal integer.

Numbers outside the allowed range are converted to numbers within the allowed range (using the rules of twos-complement binary notation). Therefore, setRGB( ) cannot be used to set negative offset values (as setTransform( ) can).

Description

The setRGB( ) method assigns new transformation offsets for a movie clip’s RGB components. The new offset is most easily specified as a six-digit hexadecimal number of the form 0xRRGGBB, where RR, GG, and BB are two-digit numbers between 00 and FF representing the Red, Green, and Blue components. For example, the RGB triplet (51, 51, 102) is equivalent to the hexadecimal value:

0x333366

Hence, to assign a gray RGB offset to a clip named menu, we could use:

var menuColor = new Color("menu");
menuColor.setRGB(0x999999);

Web developers comfortable with six-digit hexadecimal color values in HTML will have an easy time using setRGB( ) using the preceding hexadecimal format. For a primer on decimal, octal, and hexadecimal numbers see http://www.moock.org/asdg/technotes.

Note that in addition to setting offsets, setRGB( ) also automatically sets the Red, Green, and Blue percentages of a clip’s color transformation to 0, meaning that color changes performed ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.