小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

设置FormItem容器控件的文本对齐方式。

FormItem容器控件的textAlign 和labelStyleName 样式学习。
示例:


代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/06/06/changing-the-label-text-alignment-in-a-formitem-container-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white">

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

            private function comboBox_change(evt:ListEvent):void {
                var cssObj:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".customTextAlignLabel");
                cssObj.setStyle("textAlign", evt.currentTarget.selectedItem);
            }
        
]]>
    
</mx:Script>

    
<mx:Style>
        FormItem {
            labelStyleName: customTextAlignLabel;
        }

        .customTextAlignLabel {
            textAlign: left;
        }
    
</mx:Style>

    
<mx:ApplicationControlBar dock="true">
        
<mx:Form styleName="plain">
            
<mx:FormItem label="textAlign:">
                
<mx:ComboBox id="comboBox"
                        dataProvider
="[left,center,right]"
                        change
="comboBox_change(event);" />
            
</mx:FormItem>
        
</mx:Form>
    
</mx:ApplicationControlBar>

    
<mx:Form>
        
<mx:FormItem label="Button">
            
<mx:TextInput />
        
</mx:FormItem>
        
<mx:FormItem label="ButtonBar">
            
<mx:TextInput />
        
</mx:FormItem>
        
<mx:FormItem label="CheckBox">
            
<mx:TextInput />
        
</mx:FormItem>
        
<mx:FormItem label="ColorPicker">
            
<mx:TextInput />
        
</mx:FormItem>
        
<mx:FormItem label="ComboBox">
            
<mx:TextInput />
        
</mx:FormItem>
    
</mx:Form>

</mx:Application>

posted on 2008-06-10 11:23  『小小菜鸟』  阅读(4177)  评论(0编辑  收藏  举报