• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Style Objects

Essentially, style objects are just a collection of style properties, like a stylesheet in Cascading Style Sheets, if you're used to HTML. Once you have this collection of styles (font family is this, text color is that), you can apply that set of styles to individual components, like so:

// create the style object
var styleObj = new mx.styles.CSSStyleDeclaration;

// set the styles
styleObj.fontFamily = "verdana";
styleObj.fontSize = 15;
styleObj.fontWeight = "bold";
styleObj.color = 0x336699;
styleObj.setStyle("themeColor", 0xE1F412);

// stick the style object into _global.styles, so it'll have
// an effect when components use it
styleObj.styleName = "boldStyle";
_global.styles.boldStyle = styleObj;

// assign the style object to a couple components
aButton.setStyle("styleName", "boldStyle");
someLabel.setStyle("styleName", "boldStyle");


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint