Change style properties for Button control using a compound String to get a reference to the object : Button Style « Components « Flex






Change style properties for Button control using a compound String to get a reference to the object

Change style properties for Button control using a compound String to get a reference to the object
       
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    public function changeLabel(s:String):void {
        s = "myButton" + s;
        this[s].setStyle("fontStyle","italic");
        this[s].setStyle("fontSize","18");
    }
  </mx:Script>
    <mx:Button id="myButton1" click="changeLabel('2')" label="Change Other Button's Styles" />
    <mx:Button id="myButton2" click="changeLabel('1')" label="Change Other Button's Styles" />
</mx:Application>

   
    
    
    
    
    
    
  








Related examples in the same category

1.A type selector for Button controlsA type selector for Button controls
2.Set all Buttons to use the font size 10Set all Buttons to use the font size 10
3.Use @font-face to style ButtonUse @font-face to style Button
4.A type selector named ButtonA type selector named Button
5.Define a type selector named ButtonDefine a type selector named Button
6.Applies both class selectors to buttonApplies both class selectors to button
7.Use a pseudo selector to change the appearance of the button when it is in the up, down, and over statesUse a pseudo selector to change the appearance of the button when it is in the up, down, and over states
8.Define a type selector for Button components, but then overrides the color with an inline definitionDefine a type selector for Button components, but then overrides the color with an inline definition
9.Using Cascading Style Sheets to apply style to ButtonUsing Cascading Style Sheets to apply style to Button
10.Assigning Button to the myFontStyle style classAssigning Button to the myFontStyle style class
11.Apply style properties to the Button, myStyle, and global style namesApply style properties to the Button, myStyle, and global style names
12.Use getStyle() and setStyle() to change the Button's fontSize styleUse getStyle() and setStyle() to change the Button's fontSize style
13.Set Button color with styleSet Button color with style
14.Set a Button control's fontSize property as font-size or fontSize in an declarationSet a Button control's fontSize property as font-size or fontSize in an <mx:Style> declaration
15.Apply the custom style to the second button onlyApply the custom style to the second button only
16.Changes style properties on each Button control using a compound String to get a reference to the objectChanges style properties on each Button control using a compound String to get a reference to the object
17.An inheriting style and a non-inheriting style set on the Button control.An inheriting style and a non-inheriting style set on the Button control.
18.Globally changes the Button control's color style propertyGlobally changes the Button control's color style property
19.Define a new style and apply it to only the myButton controlDefine a new style and apply it to only the myButton control
20.Define a new style myFontStyle and apply that style to a Button component by assigning the Button to the myFontStyle style class:Define a new style myFontStyle and apply that style to a Button component by assigning the Button to the myFontStyle style class:
21.Inheritable style properties for Button and LabelInheritable style properties for Button and Label
22.Applying style properties to the Button, myStyle, and global style namesApplying style properties to the Button, myStyle, and global style names
23.Set the fontSize to 15 and the color to 0x9933FF for myButton instanceSet the fontSize to 15 and the color to 0x9933FF for myButton instance
24.Set the fontSize to 15 and the color to 0x9933FF on only the myButton instanceSet the fontSize to 15 and the color to 0x9933FF on only the myButton instance