Set color, font family, theme color, font size with CSSStyleDeclaration : CSSStyleDeclaration « Style « Flex






Set color, font family, theme color, font size with CSSStyleDeclaration

Set color, font family, theme color, font size with CSSStyleDeclaration
   


<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="initApp()">
    <mx:Script>
        import mx.styles.StyleManager;
        private var myDynStyle:CSSStyleDeclaration;
        private function initApp():void {
            myDynStyle = new CSSStyleDeclaration('myDynStyle');
            myDynStyle.setStyle('color', 'blue');
            myDynStyle.setStyle('fontFamily', 'georgia');
            myDynStyle.setStyle('themeColor', 'green');
            myDynStyle.setStyle('fontSize', 24);
            StyleManager.setStyleDeclaration(".myButtonStyle",myDynStyle, true);
            myOtherButton.styleName=myDynStyle;
        }
      </mx:Script>
    <mx:Button id="myButton" label="Click Me" styleName="myButtonStyle" />
    <mx:Button id="myOtherButton" label="Click Me" />
</mx:Application>

   
    
    
  








Related examples in the same category

1.Create a new CSSStyleDeclaration objectCreate a new CSSStyleDeclaration object
2.A CSSStyleDeclaration object for the Spark and MX Button controlsA CSSStyleDeclaration object for the Spark and MX Button controls