Thursday, April 10, 2008

Dynamic ToolTip

//^^^^^^^^^^^^^^^^^^^^Code^^^^^^^^^^^^^^^
import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup(Shortcuts, FuseFMP);
Tooltip.prototype.theTip = new MovieClip();
Tooltip.prototype.tFormat = new TextFormat();
function Tooltip() {
this.theTip = _root.createEmptyMovieClip("tooltip", _root.getNextHighestDepth());
this.theTip.createTextField("theText", this.theTip.getNextHighestDepth(), 3, 1, 95, 20);
this.theTip.theText.autoSize = true;
this.theTip._visible = false;
this.theTip.theText.selectable = false;
this.tFormat = new TextFormat();
this.tFormat.font = "Arial Narrow";
this.tFormat.size = 11;
this.tFormat.bold = true;
this.tFormat.color = "0xFFFFFF";
this.tFormat.align = "left";
this.theTip.theText.setNewTextFormat(this.tFormat);
}
Tooltip.prototype.draw_baloon = function(ax, ay, w, h, dir) {
var r = 0;
//radius
var w2 = w/2;
this.theTip.clear();
this.theTip.beginFill(0x00CCFF, 80);
this.theTip.lineStyle(1, 0x000000, 80);
//this.theTip.
this.theTip.moveTo(r, 0);
if (dir == 1) {
this.theTip.lineTo(w2-16, 0);
this.theTip.lineTo(ax, ay);
this.theTip.lineTo(w2, 0);
}
this.theTip.lineTo(w-r, 0);
this.theTip.curveTo(w, 0, w, r);
this.theTip.lineTo(w, h-r);
this.theTip.curveTo(w, h, w-r, h);
if (dir != 1) {
this.theTip.lineTo(w2, h);
this.theTip.lineTo(ax, ay);
this.theTip.lineTo(w2-16, h);
}
this.theTip.lineTo(r, h);
this.theTip.curveTo(0, h, 0, h-r);
this.theTip.lineTo(0, r);
this.theTip.curveTo(0, 0, r, 0);
this.theTip.endFill();
};
Tooltip.prototype.showTip = function(theText) {
this.theTip.theText.html = true
this.theTip.theText.htmlText = theText;
dwidth = this.theTip.theText.textWidth+12;
dheight = this.theTip.theText.textHeight+6;
if (dwidth<70) {
dwidth = 70;
}
if (dheight<10) {
dheight = 10;
}
dir = 0;
//arrow up down
offseth = 36;
//y offset
if (_root._xmouse+dwidth>Stage.width) {
xx = Stage.width-dwidth-8;
defpeak = 1;
} else if (_root._xmouse+dwidth xx = 8;
} else {
xx = _root._xmouse-26;
}
this.theTip._x = xx;
if (_root._ymouse yy = _root._ymouse+offseth;
dir = 1;
} else {
yy = _root._ymouse-(offseth+dheight);
}
this.theTip._y = yy;
this.draw_baloon(_root._xmouse-xx, _root._ymouse-yy, dwidth, dheight, dir);
this.theTip.DropShadow_distance = 0;
this.theTip.DropShadow_angle = 90;
this.theTip.DropShadow_alpha = 0.5;
this.theTip.DropShadow_hideObject = false;
this.theTip.DropShadow_distance = 2;
this.theTip._visible = true;
if (this.intervalID) {
clearInterval(this.intervalID);
}
};
Tooltip.prototype.removeTip = function() {
this.theTip._visible = false;
if (this.intervalID) {
clearInterval(this.intervalID);
}
};
Tooltip.prototype.delayTip = function(theText) {
this.theTip._visible = false;
this.intervalID = setInterval(this, "showTip", 1000, theText);
};
Tooltip.prototype.moveTip = function(xpos, ypos) {
this.theTip._x = xpos;
this.theTip._y = yxpos;
};
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Usage^^^^^^^^^^^^^^^^^
this.mainMap.map.pan.seaport.onRollOver = function() {
tooltp.showTip(" SEAPORT\n INTERNATIONAL PORT OF CALL");
};
this.mainMap.map.pan.seaport.onRollOut = this.mainMap.map.pan.seaport.onDragOut=function () {
tooltp.removeTip();
};
mainMap.map.pan.seaport.onMouseMove = function() {
tooltp.moveTip(_xmouse, _ymouse);
//tooltp._x = _root._xmouse;
};