[转]文字竖排TabBar

http://uh.9ria.com/space-12147-do-blog-id-668.html

package
{
    import mx.controls.Button;
    import mx.controls.ButtonLabelPlacement;
    import mx.controls.TabBar;
    import mx.core.IFlexDisplayObject;
    import mx.core.UITextField;
    import mx.core.mx_internal;
    import mx.events.FlexEvent;
    
    use namespace mx_internal;
    public class VerticalTabBar extends TabBar
    {
        public function VerticalTabBar()
        {
            super();
            addEventListener(FlexEvent.CREATION_COMPLETE,createCompleteEvt);
        }
        
        override  protected function createNavItem(label:String,icon:Class = null):IFlexDisplayObject{
            var button:Button=(super.createNavItem(label,icon) as Button);
            button.addEventListener(FlexEvent.UPDATE_COMPLETE,buttonUpdateComplete);
            return button;
        }
        
        private function buttonUpdateComplete(event:FlexEvent):void{
            var button:Button=event.currentTarget as Button;
            button.getTextField().y=(button.height-button.getTextField().textHeight)/2;
        }
        
        private function createCompleteEvt(event:FlexEvent):void{
            for each(var button:Button in getChildren()){
                button.labelPlacement= ButtonLabelPlacement.TOP;
                var text:UITextField=button.getTextField() as UITextField;
                text.explicitHeight=text.textHeight+5;
            }
        }
        
    }
}


如果只是做Button竖排,就不用搞这么恶心的办法了。问题在于Button没有用接口,架构不允许。

你可能感兴趣的:(html,Blog)