设置RadioButton控件的背景色.

RadioButton控件的opaqueBackground样式.
示例:


代码:

<? xml version="1.0" encoding="utf-8" ?>
<!--  http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/  -->
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white" >

    
< mx:ApplicationControlBar  dock ="true" >
        
< mx:Form  styleName ="plain" >
            
< mx:FormItem  label ="opaqueBackground:" >
                
< mx:ColorPicker  id ="colorPicker"   />
            
</ mx:FormItem >
        
</ mx:Form >
    
</ mx:ApplicationControlBar >

    
< mx:RadioButton  id ="radioButton"
            label
="The quick brown fox jumped over the lazy dog"
            opaqueBackground
=" {colorPicker.selectedColor} "   />

</ mx:Application >

也可以通过AS设置:
<? xml version="1.0" encoding="utf-8" ?>
<!--  http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/  -->
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white" >

    
< mx:Script >
        
<![CDATA[
            import mx.events.ColorPickerEvent;

            private function colorPicker_change(evt:ColorPickerEvent):void {
                radioButton.opaqueBackground = evt.color;
            }
        
]]>
    
</ mx:Script >

    
< mx:ApplicationControlBar  dock ="true" >
        
< mx:Form  styleName ="plain" >
            
< mx:FormItem  label ="opaqueBackground:" >
                
< mx:ColorPicker  id ="colorPicker"
                        change
="colorPicker_change(event);"   />
            
</ mx:FormItem >
        
</ mx:Form >
    
</ mx:ApplicationControlBar >

    
< mx:RadioButton  id ="radioButton"
            label
="The quick brown fox jumped over the lazy dog"   />

</ mx:Application >

你可能感兴趣的:(RadioButton)