ActionScript 2.0 Components Language Reference |
|
|
|
| Menu component > Customizing the Menu component > Setting styles for all Menu components in a document | |||
The Menu class inherits from the ScrollSelectList class. The default class-level style properties are defined on the ScrollSelectList class, which is shared by all List-based components. 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 Menu components only, you can create a new CSSStyleDeclaration and store it in _global.styles.Menu.
import mx.styles.CSSStyleDeclaration; if (_global.styles.Menu== undefined) { _global.styles.Menu= new CSSStyleDeclaration(); } _global.styles.Menu.setStyle("backgroundColor", 0xFF00AA);
When you create 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.Menu;
for (var style in source) {
target.setStyle(style, source.getStyle(style));
}
For more information about class-level styles see Setting styles for a component class in Using ActionScript 2.0 Components.
|
|
|
|