• 鼠标经过延时出现Hint


    舞台上有个影片剪辑mc
    库中有个元件hint由bg元件和文本txt组成
    import flash.events.MouseEvent;
    
    var time:int = 500;
    var dyid:int;
    var flag:Boolean;
    
    mc.addEventListener(MouseEvent.ROLL_OVER,_onRollOver);
    mc.addEventListener(MouseEvent.ROLL_OUT,_onRollOut);
    
    function _onRollOver(e:MouseEvent):void
    {
    	dyid = setTimeout(delayed,time,e);
    }
    function delayed(e:MouseEvent):void
    {
    	flag = true;
    	Hint.addHint(e,"延时"+time+"毫秒");
    }
    function _onRollOut(e:MouseEvent):void
    {
    	if (flag)
    	{
    		flag = false;
    		Hint.removeHint();
    	}
    	clearTimeout(dyid);
    }
    
    package
    {
    	import flash.display.DisplayObject;
    	import flash.display.MovieClip;
    	import flash.display.Sprite;
    	import flash.display.Stage;
    	import flash.events.MouseEvent;
    	import flash.geom.Rectangle;
    	import flash.text.TextField;
    	import flash.text.TextFieldAutoSize;
    
    	public class Hint extends Sprite
    	{
    		private static  var _txt:TextField;
    		private static var _mcBg:MovieClip;
    		private static var _hint:Hint;
    		private static var _stage:Stage;
    		public function Hint() 
    		{
    			_txt = getChildByName("txt") as TextField;
    			_mcBg = getChildByName("bg") as MovieClip;
    		}
    		public static function getInstance():Hint
    		{
    			if (_hint == null)
    			{
    				_hint = new Hint();
    			}
    			return _hint;
    		}
    		public static function addHint(e:MouseEvent,str:String):void
    		{
    			_stage = e.target.stage;
    			_stage.addChild(getInstance());	
    			_txt.text = str;
    			_txt.autoSize = TextFieldAutoSize.CENTER;
    			resize();
    			getInstance().x = _stage.mouseX;
    			getInstance().y = _stage.mouseY;
    			_stage.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler);
    		}
    		public static function moveHandler(e:MouseEvent):void
    		{
    			getInstance().x = _stage.mouseX;
    			getInstance().y = _stage.mouseY;
    		}
    		public static function resize():void
    		{
    			_mcBg.width = _txt.textWidth + 30;
    		}
    		public static function removeHint():void
    		{
    			_stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveHandler);
    			_stage.removeChild(getInstance());
    		}
    	}
    
    }
    
  • 相关阅读:
    IBatisNet之获取和操作SQL语句
    IIS7站点/虚拟目录中访问共享文件夹(转)
    asp.net 4.0 IIS7.0/7.5环境提供了自动预热功能(程序池自动重启)
    仅此一文让你明白ASP.NET MVC原理
    博客、论坛集
    软件开发工具
    delete表1条件是另一个表中的数据,多表连接删除(转)
    Quartz.Net架构入门—开源的作业调度框架
    C# URL 中文编码与解码
    HDU4619--Warm up 2
  • 原文地址:https://www.cnblogs.com/602147629/p/1942972.html
Copyright © 2020-2023  润新知