实现TextInput垂直居中

这是我在veryDemo上看见的, 原文地址: http://www.verydemo.com/demo_c161_i100890.html

package com.sandy.global.view.component.textinput
{
    import mx.controls.Text;
    import mx.controls.TextInput;
    
    public class VerticalMiddleTextInput extends TextInput
    {
        public function VerticalMiddleTextInput()
        {
            super()
        }
        
        override protected function createChildren():void
        {
            super.createChildren();
        }
        
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList( unscaledWidth, unscaledHeight );
            
            this.textField.height = this.textField.textHeight ;
            
            this.textField.y = this.height/2 -this.textField.height/2
        }
    }
}


你可能感兴趣的:(Flex)