ActionScript 2.0 Components Language Reference |
|
|
|
| List component > Customizing the List component > Setting styles for all List components in a document | |||
The List class inherits from the ScrollSelectList class. The default class-level style properties are defined on the ScrollSelectList class, which the Menu component and all List-based components extend. You can set new default style values on this class directly, and the new settings are reflected in all affected components.
_global.styles.ScrollSelectList.setStyle("backgroundColor", 0xFF00AA);
To set a style property on the List and List-based components only, you can create a new CSSStyleDeclaration instance and store it in _global.styles.List.
import mx.styles.CSSStyleDeclaration;
if (_global.styles.List == undefined) {
_global.styles.List = new CSSStyleDeclaration();
}
_global.styles.List.setStyle("backgroundColor", 0xFF00AA);
When creating a new class-level style declaration, you lose all default values provided by the ScrollSelectList declaration. This includes backgroundColor, which is required for supporting mouse events. To create a class-level style declaration and preserve defaults, use a for..in loop to copy the old settings to the new declaration.
var source = _global.styles.ScrollSelectList;
var target = _global.styles.List;
for (var style in source) {
target.setStyle(style, source.getStyle(style));
}
To provide styles for the List component but not for components that extend List (DataGrid and Tree), you must provide class-level style declarations for these subclasses.
import mx.styles.CSSStyleDeclaration;
if (_global.styles.DataGrid == undefined) {
_global.styles.DataGrid = new CSSStyleDeclaration();
}
_global.styles.DataGrid.setStyle("backgroundColor", 0xFFFFFF);
if (_global.styles.Tree == undefined) {
_global.styles.Tree = new CSSStyleDeclaration();
}
_global.styles.Tree.setStyle("backgroundColor", 0xFFFFFF);
For more information about class-level styles, see Setting styles for a component class in Using ActionScript 2.0 Components.
|
|
|
|