`
hepeng19861212
  • 浏览: 147117 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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

    博客分类:
  • flex
阅读更多
<转载请注明:来自火柴天堂的博客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();
		}
	}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics