⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 obo_tooltip.as

📁 flash oo tooltip asctino script 2.0 class for oo tooltip in the interface and user can customer m
💻 AS
字号:
import flash.filters.DropShadowFilter;
/**
 * fancy tool tip class
 *
 * @author  Devon O.
 * @version 1.5
 * @date    07/08/2006
 */
class OBO_ToolTip {
	private static var _tt:OBO_ToolTip;
	private var _adv:Boolean;
	private var _myRoot:MovieClip;
	private var _tip:MovieClip;
	private var _tipShape:Array;
	private var _shapeCol:Number;
	private var _shapeAlpha:Number;
	private var _format:TextFormat;
	private var _ds:DropShadowFilter;
	/**
	    * use the static method OBO_ToolTip.createTip() to create a single instance of the OBO_ToolTip class...
	    *
	    * @usage   // "Tahoma" font needs to be included in .fla library for this example
	    *          var myToolTip:OBO_ToolTip = OBO_ToolTip.createTip(this, 0xFFFFFF, 75, 0x000000, "Tahoma", 12, true);
	    *          some_mc.onRollOver = function() {
	               myToolTip.addTip("Tool tip text");
	            }
	            some_mc.onRollOut = some_mc.onDragOut = function() {
	               myToolTip.removeTip();
	            }
	    * @param   attachTo:MovieClip - the MovieClip which will create the tool tip movie clip (recommend simply using "this")
	    * @param   shapeCol:Number - the hex color of the tool tip "balloon"
	    * @param   shapeAlpha:Number - the alpha value of the tool tip "balloon" (0 - 100)
	    * @param   textCol:Number - the hex color of the tool tip text
	    * @param   textFont:String - the font used in the tool tip (must be included in the .fla library and set to export for actionscript)
	    * @param   textSize:Number - the size of the tool tip font
	    * @param   adv:Boolean - specify whether or not to set anti aliasing to advanced (recommended "false" if using a bitmap font, "true" for other fonts)
	    */
	private function OBO_ToolTip(attachTo:MovieClip, shapeCol:Number, shapeAlpha:Number, textCol:Number, textFont:String, textSize:Number, adv:Boolean) {
		_adv = adv;
		_myRoot = attachTo;
		_shapeCol = shapeCol;
		_shapeAlpha = shapeAlpha;
		_format = new TextFormat(textFont, textSize, textCol);
		_ds = new DropShadowFilter(3, 90, 0x000000, .4, 2, 2, 1, 3);
	}
	// singleton instantiation
	public static function createTip(attachTo:MovieClip, shapeCol:Number, shapeAlpha:Number, textCol:Number, textFont:String, textSize:Number, adv:Boolean):OBO_ToolTip {
		if (_tt == undefined) {
			_tt = new OBO_ToolTip(attachTo, shapeCol, shapeAlpha, textCol, textFont, textSize, adv);
			return _tt;
		} else {
			trace("ToolTip error: singleton instance already exists");
		}
	}
	public function addTip(words:String):Void {
		_tip = _myRoot.createEmptyMovieClip("tip", 20000);
		//_tip = _root.createEmptyMovieClip("tip", 20000);
		var txt_mc:MovieClip = _tip.createEmptyMovieClip("text_mc", 0);
		var tip_txt:TextField = txt_mc.createTextField("tt", 0, 0, 0, 10, 25);
		tip_txt.autoSize = true;
		tip_txt.setNewTextFormat(_format);
		tip_txt.selectable = false;
		tip_txt.embedFonts = true;
		tip_txt.multiline = true;
		if (_adv) {
			tip_txt.antiAliasType = "advanced";
		}
		tip_txt.text = words;
		var w:Number = tip_txt.textWidth;
		var h:Number = tip_txt.textHeight;
		txt_mc._x = -w;
		txt_mc._y = -20-h;
		_tipShape = [[0, -13.42], [0, -2], [10.52, -15.7], [13.02, -18.01, 13.02, -22.65], [13.02, -16-h], [13.23, -25.23-h, 3.1, -25.23-h], [-w, -25.23-h], [-w-7, -25.23-h, -w-7, -16-h], [-w-7, -22.65], [-w-7, -13.42, -w, -13.42]];
		var len:Number = _tipShape.length;
		_tip.beginFill(_shapeCol, _shapeAlpha);
		for (var i = 0; i<len; i++) {
			if (i == 0) {
				_tip.moveTo(_tipShape[i][0], _tipShape[i][1]);
			} else if (_tipShape[i].length == 2) {
				_tip.lineTo(_tipShape[i][0], _tipShape[i][1]);
			} else if (_tipShape[i].length == 4) {
				_tip.curveTo(_tipShape[i][0], _tipShape[i][1], _tipShape[i][2], _tipShape[i][3]);
			}
		}
		_tip.filters = [_ds];
		_tip.onMouseMove = function() {
			this._x = Math.round(_root._xmouse);
			this._y = Math.round(_root._ymouse);
			if (this._x-(this._width-18)<0) {
				this._xscale = txt_mc._xscale=-100;
				txt_mc._x = 5;
			} else {
				this._xscale = txt_mc._xscale=100;
				txt_mc._x = -w;
			}
			if (this._y-(this._height-5)<0) {
				this._yscale = txt_mc._yscale=-100;
				txt_mc._y = -20;
			} else {
				this._yscale = txt_mc._yscale=100;
			}
			updateAfterEvent();
		};
	}
	public function removeTip():Void {
		delete _tip.onMouseMove;
		_tip.removeMovieClip();
	}
	// setters
	public function set opacity(shapeAlpha:Number):Void {
		_shapeAlpha = shapeAlpha;
	}
	public function set tipColor(shapeCol:Number):Void {
		_shapeCol = shapeCol;
	}
	public function set fontColor(col:Number):Void {
		_format.color = col;
	}
	public function set fontSize(s:Number):Void {
		_format.size = s;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -