flex4中创建竖向显示的button

1.创建一个VButton的自定义类,继承与button,重写initialize()方法,为labelDisplay的text属性显示的文本添加回车,贴出代码如下:

package components{
	import spark.components.Button;

	/**
	 * flex4中竖向按钮
	 * @author   
	 * @version  1.0.0
	 * 创建时间:Nov 11, 2013 11:07:04 AM   
	 */
	public class VButton extends Button{
		public function VButton(){
		}
		
		override public function initialize():void{
			super.initialize();
			var length:int = this.label.length; 
			var newText:String = ""; 
			for(var i:int = 0; i < length; i++){ 
				newText+=this.label.charAt(i)+"\n"; 
			} 
			this.labelDisplay.text = newText; 
			trace(newText);
		}
	}
}

2.需要自定义buttonskin,将id为labelDisplay的label组件的maxDisplayedLines属性更改为-1 即可。

<s:Label id="labelDisplay"
             textAlign="center"
             maxDisplayedLines="-1"
             horizontalCenter="0" verticalCenter="1" verticalAlign="middle"
             left="2" right="2" top="2" bottom="2" >
</s:Label>



 

发布了36 篇原创文章 · 获赞 3 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/jinxiumeihappy/article/details/15337241