
Color.setRGB() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
499
Color.setRGB() Method
assign new offset values for Red, Green, and Blue
Flash 5
colorObj.setRGB(offset);
Arguments
offset A number in the range 0 to 16777215 (0xFFFFFF), representing the new RGB
offsets of
colorObj’s target clip. Can 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 compo-
nents. 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, repre-
senting the Red, Green, and Blue components. For example, the RGB triplet (R:51, G:51,
B:102) is equivalent to the hexadecimal value:
0x333366
Hence, to assign a gray RGB offset to a clip named menu, we can 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() with the preceding hexadecimal format. For a primer on decimal,
octal, and hexadecimal numbers, ...