`

ColorLabel

阅读更多
package com.components
{
	import mx.controls.Label;

	[Style(name="backgroundColor", type="uint", format="Color", inherit="no")]
	public class ColorLabel extends Label
	{
		public function ColorLabel()
		{
			super();
		}
		
		override public function styleChanged(styleProp:String):void
		{
			super.styleChanged(styleProp);
			
			if("backgroundColor" == styleProp)
			{
				invalidateDisplayList();
			}
		}

		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			with(graphics)
			{
				clear();
				beginFill(getStyle("backgroundColor"));
				drawRect(0, 0, this.width, this.height);
				endFill();
			}
		}
	}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics