Using Components > Customizing component colors and text > Changing the properties of specific components

 

Changing the properties of specific components

You can create custom style formats to specify a unique set of properties for specific components in your Flash document. You use the FStyleFormat object constructor to create a new instance of the FStyleFormat object, to define your custom style format, and to specify the properties and values for the format. The FStyleFormat object is accessible if you have placed at least one component instance on the Stage. It is recommended that you use a separate layer in the document Timeline to set properties.

You make changes to a custom style format in the same way that you edit the properties in the global style format. Instead of the globalStyleFormat object name, use the FStyleFormat object name. See Changing properties of all Flash UI components.

The FStyleFormat object has three methods in addition to the constructor method:

FStyleFormat.applyChanges applies changes you make to the properties of a custom style format you have created.

FStyleFormat.addListener assigns components the style format.

FStyleFormat.removeListener removes components from the style format.

For more information, see FStyleFormat (object) in the ActionScript Dictionary.

The following table summarizes the properties of the FStyleFormat object. For a complete description of each property, see the individual entries in the online ActionScript Dictionary. You can set or change any of the FStyleFormat object properties in the global style format, or in custom style formats that you create.

 
Property summary for the FStyleFormat object

Property

Description

FStyleFormat.arrow

The color of the arrow used in scroll bars and drop-down lists.

FStyleFormat.background

The color of the background portion of components.

FStyleFormat.backgroundDisabled

The color of the background portion of disabled components.

FStyleFormat.check

The color of the check in a selected check box.

FStyleFormat.darkshadow

The color of the inner border or shadow portion of a component.

FStyleFormat.face

The main color of the component.

FStyleFormat.foregroundDisabled

The foreground color of a disabled component.

FStyleFormat.highlight

The color of the inner border or darker shadow portion of a component when it is selected.

FStyleFormat.highlight3D

The color for the outer border or light shadow portion of a component when it is selected.

FStyleFormat.radioDot

The color of the dot in a selected radio button.

FStyleFormat.scrollTrack

The color of the track in a scroll bar.

FStyleFormat.selection

The color of the selection bar highlighting an item in a list of a component.

FStyleFormat.selectionDisabled

The color of the selection bar that highlights an item in a list of a disabled component.

FStyleFormat.selectionUnfocused

The color of the selection bar (highlighting) when the component does not have keyboard focus.

FStyleFormat.shadow

The color of the outer border or light shadow portion of a component.

FStyleFormat.textAlign

Specifies left, right, or center alignment for text displayed in or on a component.

FStyleFormat.textBold

Specifies whether text is bold (true) or not (false).

FStyleFormat.textColor

The color of list items in a component when they are not selected.

FStyleFormat.textDisabled

The color of the text in a disabled component.

FStyleFormat.textFont

The name of the font to display text.

FStyleFormat.textIndent

The indentation of the text from the left margin to the first text character in pixels.

FStyleFormat.textItalic

Specifies whether text is italic (true) or not (false).

FStyleFormat.textLeftMargin

The left paragraph margin in text in pixels.

FStyleFormat.textRightMargin

The right paragraph margin for text in pixels.

FStyleFormat.textSelected

The color of a selected list item in a component.

FStyleFormat.textSize

The size of the text in points.

FStyleFormat.textUnderline

Specifies whether text is underlined (true) or not (false).


To create a custom style format for specific components:


1

Make sure the document contains at least one component instance. See Adding components to Flash documents.

2

Create a new layer in the Timeline and give it a name.

3

Select any frame in the new layer.

4

Open the Actions panel in expert mode.

5

Use the following syntax to create an instance of the FStyleFormat object to define the new custom style format:

var myStyleFormat = new FStyleFormat();

6

In the same Script pane as above, use the following syntax to specify the properties you want to define for the myStyleFormat object:

myStyleFormat.arrow  = 0x333300;
myStyleFormat.background = 0xffffff;
myStyleFormat.backgroundDisabled  = 0xccffcc;
myStyleFormat.darkshadow = 0x333300;
myStyleFormat.foregroundDisabled  = 0x999999;
myStyleFormat.face = 0x99cc99;
myStyleFormat.textSize = 12
myStyleFormat.highlight = 0x99cc00;
myStyleFormat.highlight3D  = 0x333300;
myStyleFormat.radioDot = 0x333300;
myStyleFormat.scrollTrack = 0x99cc99;
myStyleFormat.selection = 0x333300;
myStyleFormat.selectionDisabled = 0x999999;
myStyleFormat.selectionUnfocused = 0x999999;
myStyleFormat.shadow = 0x99cc00;
myStyleFormat.textColor = 0x000000; 
myStyleFormat.textDisabled  = 0x999999;
myStyleFormat.textSelected = 0x000000; 

7

In the same Script pane, use the following syntax to assign the format style to specific components.

myStyleFormat.addListener(myComboBox, myListBox);

8

Use the following syntax to remove a component from a style format:

myStyleFormat.removeListener(myComboBox);