flex:闪动的label,鼠标放上去就停止闪动并显示。

<转载请注明:来自火柴天堂的博客http://hepeng19861212.iteye.com >
flex:闪动的label,鼠标放上去就停止闪动并显示,鼠标离开后又开始闪动。
package actionScript
{
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import mx.controls.Label;

	public class BlinkLabel extends Label
	{
		private var timer:Timer;
		
		public function get interval():int {
			return timer.delay;
		}
		
		public function set interval(interval:int):void {
			timer.delay = interval;
		}
		
		public function BlinkLabel()
		{
			super();
			
			this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			
			timer = new Timer(1000, 0);
			timer.addEventListener(TimerEvent.TIMER, blink);
			timer.start();
		}
		
		private function blink(event:TimerEvent):void {
			this.visible = !this.visible;
		}
		
		private function onMouseOver(event:MouseEvent):void {
			timer.stop();
			this.visible = true;
		}
		
		private function onMouseOut(event:MouseEvent):void {
			timer.start();
		}
	}
}

你可能感兴趣的:(Flex,Flash,actionscript)