Name
Color
Class — control over movie clip color values
Availability
Flash 5
Constructor
new Color(target)
Arguments
- target
A string or reference indicating the path to the movie clip or document level whose color will be controlled by the new object (references are converted to paths when used in a string context).
Methods
- getRGB
( )
Retrieve the current offset values for Red, Green, and Blue.
- getTransform
( )
Retrieve the current offset and percentage values for Red, Green, Blue, and Alpha.
- setRGB
( )
Assign new offset values for Red, Green, and Blue, while reducing percentage values to 0.
- setTransform
( )
Assign new offset and/or percentage values for Red, Green, Blue, and Alpha.
Description
We use objects of the Color
class to
programmatically dictate the color and transparency of a movie clip or
main movie. Once we’ve created an object of the
Color
class for a specific
target
, we can then invoke the methods of
that object to affect its target
’s
color and transparency. For example, suppose we have a clip instance
named ball
that we want to make red. We first make
a Color
object
with a target
of ball
and store it in the variable ballColor
. Then we
use ballColor.setRGB( )
to assign
ball
the color red, as follows:
var ballColor = new Color("ball"); ballColor.setRGB(0xFF0000); // Pass setRGB( ) the hex value for red
The preceding example provides color control for simple applications. But to handle more complex scenarios, we need to know more about how color is represented in Flash. Every individual ...
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.