1、组件添加事件监听,鼠标移入,移除
mouseOver="onMouseOver(event)" mouseOut="onMouseOut(event)"
2、鼠标移入显示tooltip
private function onMouseOver(event:MouseEvent):void{ // tip文本 var msg:String = "hello"; // 获取当前组件的绝对位置 var __point:Point = new Point(this.x, this.y); __point = this.localToGlobal(__point); tip = ToolTipManager.createToolTip(msg, __point.x + this.width, __point.y) as ToolTip; }
3、鼠标移除组件时销毁tooltip
private function onMouseOut(event:MouseEvent):void{ ToolTipManager.destroyToolTip(tip); }