简单纯文字浮动信息-Tooltip
生活随笔
收集整理的這篇文章主要介紹了
简单纯文字浮动信息-Tooltip
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
分享個AS3 ToolTip類 純文本
效果預(yù)覽:
package ui {import flash.display.*;import flash.events.*;import flash.text.*;public class ToolTip {private static var tips:Array = [];private static var nowShowTip:DisplayObject;public static var isOn:Boolean = true;private static function hideTip(_arg1:MouseEvent):void{var textField:DisplayObjectContainer;textField = (_arg1.currentTarget.root as DisplayObjectContainer);nowShowTip.addEventListener(Event.ENTER_FRAME, alphaHide);}public static function findTip(_arg1:Object):String{var textField:Object;for each (textField in tips) {if (textField[0] == _arg1){return (textField[1]);};};return ("tip");}private static function onOverTip(_arg1:MouseEvent):void {if (isOn == false) return;var textField:TextField;var sp:Sprite;var disContainer:DisplayObjectContainer;textField = new TextField();textField.width = 300;textField.height = 200;textField.textColor = 0xFFFFFF;textField.x = (3 + 4);textField.selectable = false;textField.htmlText = findTip(_arg1.currentTarget);textField.multiline = true;textField.wordWrap = true;textField.width = (textField.textWidth + 17);textField.height = (textField.textHeight + 5);textField.blendMode = BlendMode.LAYER;textField.setTextFormat(new TextFormat("Tahoma,Arial,Verdana"));sp = new Sprite();sp.graphics.beginFill(0x0099FF, 0.45);sp.graphics.lineStyle(1, 0x0099FF);sp.graphics.drawRoundRect(0.5, 0.5, (textField.width + 3), textField.height, 3, 3);sp.addChild(textField);sp.mouseEnabled = false;sp.mouseChildren = false;sp.visible = false;sp.alpha = 0;sp.addEventListener(Event.ENTER_FRAME, alphaShow);sp.cacheAsBitmap = true;disContainer = (_arg1.currentTarget.root as DisplayObjectContainer);disContainer.addChild(sp);nowShowTip = sp;moveTip(_arg1);}private static function alphaShow(_arg1:Event):void{var textField:DisplayObject;textField = (_arg1.currentTarget as DisplayObject);textField.alpha = (textField.alpha + 0.039);textField.visible = true;if (textField.alpha >= 1){textField.removeEventListener(Event.ENTER_FRAME, alphaShow);};}private static function moveTip(_arg1:MouseEvent):void{var textField:DisplayObjectContainer;if (nowShowTip == null){return;};textField = (_arg1.currentTarget.root as DisplayObjectContainer);nowShowTip.x = (textField.mouseX - 1);nowShowTip.y = (textField.mouseY + 22);if (nowShowTip.x > ((textField.stage.stageWidth - nowShowTip.width) - 2)){nowShowTip.x = ((textField.stage.stageWidth - nowShowTip.width) - 2);};if (nowShowTip.y > ((textField.stage.stageHeight - nowShowTip.height) - 2)){nowShowTip.y = ((textField.mouseY - nowShowTip.height) - 5);};}private static function alphaHide(_arg1:Event):void{var textField:DisplayObject;textField = (_arg1.currentTarget as DisplayObject);textField.alpha = (textField.alpha - 0.15);if (textField.alpha < 0.05){textField.removeEventListener(Event.ENTER_FRAME, alphaHide);textField.parent.removeChild(textField);};}public static function addText(_arg1:InteractiveObject, _arg2:String):void{tips.push([_arg1, _arg2]);_arg1.addEventListener(MouseEvent.MOUSE_OVER, onOverTip);_arg1.addEventListener(MouseEvent.MOUSE_OUT, hideTip);_arg1.addEventListener(MouseEvent.MOUSE_MOVE, moveTip);}} }?
喜歡的可以拿過去哦~
轉(zhuǎn)載于:https://www.cnblogs.com/LLLoveLL/p/3333216.html
總結(jié)
以上是生活随笔為你收集整理的简单纯文字浮动信息-Tooltip的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis在Windows+linux平
- 下一篇: hdu 4753 Fishhead’s