|
Flash CS4 Resources |
Use the ColorPicker componentThe ColorPicker component allows a user to select a color from a swatch list. The default mode of the ColorPicker shows a single color in a square button. When a user clicks the button, the list of available colors appears in a swatch panel along with a text field that displays the hexadecimal value of the current color selection. You can set the colors that appear in the ColoPicker by setting its colors property with the color values that you want to display. User interaction with the ColorPicker componentA ColorPicker allows a user to select a color and apply it to another object in the application. For example, if you want to allow the user to personalize elements of the application, such as a background color or the color of text, you can include a ColorPicker and apply the color that the user selects. A user chooses a color by clicking its swatch in the panel or by entering its hexadecimal value in the text field. Once the user selects a color, you can use the ColorPicker’s selectedColor property to apply the color to text or another object in the application. A ColorPicker instance receives focus if a user moves the pointer over it or tabs to it. When a ColorPicker’s swatch panel is open, you can use the following keys to control it:
ColorPicker component parametersYou can set the following authoring parameters in the Property inspector or in the Component inspector for each ColorPicker instance: selectedColor and showTextField . Each of these parameters has a corresponding ActionScript property of the same name. For information on the possible values for these parameters, see the ColorPicker class in the ActionScript 3.0 Language and Components Reference . Create an application with the ColorPicker componentThe following example adds a ColorPicker component to an application while authoring. In this example, each time you change the color in the ColorPicker, the changeHandler() function calls the drawBox() function to draw a new box with the color you selected in the ColorPicker.
Create a ColorPicker using ActionScriptThis example uses the ColorPicker() constructor and addChild() to create a ColorPicker on the Stage. It sets the colors property to the color values for red (0xFF0000), green (0x00FF00), and blue (0x0000FF) to specify the colors that the ColorPicker will display. It also creates a TextArea and each time you select a different color in the ColorPicker, the example changes the color of the text in the TextArea to match.
|