toolTip类响应号召用AS2.0编写 |
| 作者:佚名 来源:闪吧 作者: xucan 更新:2007-1-13 20:46:50 错误报告 我要投稿 |
class toolTip { private var _tip:String; private var _movie:MovieClip; private var _color:String = "0xffffe1"; private var _style:String; private var width:Number = 0; private var height:Number = 0; private var _timer:Number = 450; private var _effects:String; private var selected:Boolean = true; public function get _width() { return width; } public function set _width(w) { width = w; } public function get _height() { return height; } public function set _height(h) { height = h; } public function get parent() { return _movie._parent; } public function get style() { return _style; } public function set style(s:String) { _style = s; } public function get effects() { return _effects; } public function set effects(e:String) { _effects = e; } public function get tip() { return _tip; } public function set tip(str:String) { _tip = str; } public function set movie(m) { _movie = m; } public function get color():String { return _color; } public function set color(cl:String) { _color = cl; } public function toolTip(movie:MovieClip, tip:String) { _movie = movie; _tip = tip; } public function Show() { var path = this; _movie.onRollOver = function() { var tip_mc = this._parent.createEmptyMovieClip("t_toolTip", _root.getNextHighestDepth()); path.msgBox(tip_mc); path.Cheak(tip_mc); }; removeTip(parent.t_mc); } public function showTip() { var path = this; _movie.onRollOver = function() { var timer = getTimer(); this._parent.onEnterFrame = function() { var time = getTimer(); if (time-timer>=path._timer) { path.Draw(); delete _root.onEnterFrame; } //end if }; //end onE }; //end onR removeTip(); } function removeTip() { var path = this; _movie.onRollOut = _movie.onReleaseOutside=_movie.onPress=function () { this._parent.Tip_toolTip.removeMovieClip(); this._parent.t_toolTip.removeMovieClip(); delete _root.onEnterFrame; }; } function Draw() { var path = this; var tip_mc = parent.createEmptyMovieClip("Tip_toolTip", _root.getNextHighestDepth()); with (tip_mc) { lineStyle(1, "0x000000", 50); beginFill(path._color, 100); moveTo(0, 0); switch (path.style) { default : //矩形 lineTo(path.width, 0); lineTo(path.width, path.height); lineTo(0, path.height); lineTo(0, 0); endFill(); } } Effects(tip_mc); Cheak(tip_mc); msgBox(tip_mc); } function Cheak(mc:MovieClip) { var path = this; with (mc) { (_xmouse+_width)<Stage.width ? _x=_xmouse : _x=Stage.width-_width; _y = _ymouse; var b:Object = path._movie.getBounds(mc._parent); (b.yMin-_height-2)>0 ? _y=b.yMin-_height-2 : _y=b.yMax+2; } } function msgBox(mc:MovieClip) { var path = this; mc.createTextField("msg", _root.getNextHighestDepth(), 2, -2, width, height); with (mc.msg) { html = true; htmlText = path.tip; selectable = false; if (mc == path.parent.t_toolTip) { autoSize = true; background = true; border = true; borderColor = "0x000000"; backgroundColor = path._color; } else { autoSize = "right"; multiline = true; wordWrap = true; } //end if } //end with } //end function function Select(mc) { } function Effects(mc:MovieClip) { switch (_effects) { case "淡出" : mc._alpha = 0; mc.onEnterFrame = function() { this._alpha += 30; }; if (mc._alpha == 100) { break; } default : break; } } }
源代码
点击浏览该文件
效果
点击浏览该文件
|
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |