class ToolTip { private var target:MovieClip; private var temp_mc:MovieClip; private var clips:Array = ["null"]; private var styles:Array = ["null"] private var style:TextFormat; private var background:String; private var title:String; private var index:Number = 0; function ToolTip() { } public function make(target:MovieClip, title:String, style:TextFormat, background:String):Number { this.index++; this.target = target; this.title = title; this.style = (style == undefined) ? new TextFormat("Verdana", 10, 0x000000) : style; this.background = (background == undefined) ? 0xFEFDB6 : background; this.clips.push(target); this.styles.push(style); this.doBox(); return this.index; } private function doBox() { this.temp_mc = this.target.createEmptyMovieClip("tooltip_temp", this.target.getNextHighestDepth()); this.temp_mc._visible = false; this.temp_mc.createTextField("label_txt", 10, 5, 2, 0, 0); this.temp_mc.label_txt.text = this.title; this.temp_mc.label_txt.selectable = false; this.temp_mc.label_txt.autoSize = true; this.temp_mc.label_txt.border = true; this.temp_mc.label_txt.background = true; this.temp_mc.label_txt.borderColor = 0x000000; this.temp_mc.label_txt.backgroundColor = this.background; this.temp_mc.label_txt.setTextFormat(this.style); this.makeEvents(); } private function makeEvents() { var holder:MovieClip = this.temp_mc; this.target.onRollOver = function() { this.swapDepths(10000) holder._visible = true; holder.startDrag(false); holder._x = holder._xmouse; holder._y = holder._ymouse-holder.label_txt._height; }; this.target.onReleaseOutside = this.target.onRollOut = function() { holder._visible = false; holder.stopDrag(); holder._x = 0; holder._y = 0; }; } public function setTitle(id:Number, newTitle:String) { var tm_mc:MovieClip = this.clips[id].tooltip_temp; tm_mc.label_txt.text = newTitle; tm_mc.label_txt.setTextFormat(this.styles[id]); } public function setBackground(id:Number, newColor:String) { var tm_mc:MovieClip = this.clips[id].tooltip_temp; this.background = newColor; tm_mc.label_txt.backgroundColor = newColor; tm_mc.label_txt.setTextFormat(this.styles[id]); } public function setStyles(id:Number, newStyle:TextFormat) { var tm_mc:MovieClip = this.clips[id].tooltip_temp; this.styles[id] = newStyle; tm_mc.label_txt.setTextFormat(this.styles[id]); } public function getTitle(id:Number):String { var tm_mc:MovieClip = this.clips[id].tooltip_temp; return tm_mc.label_txt.text; } }