button1_btn.onRollOut = button1_btn.onRelease = hideToolTip;
Printable View
button1_btn.onRollOut = button1_btn.onRelease = hideToolTip;
Yep... that kind of functionality is easy to add. That's one of the neat things about coding ActionScript Classes. Just add a few new methods and properties and you're done.
I attached a new fla,swf, and tooltip class that adds the funtionality you wanted.
On the time delay issue:
I added a new property to the class (called it tipDelay). In the constructor I set it to 1000. Then used setInterval to display the tooltip.
You could change that 1000 to whatever is your preferred delay time. Or if you wanted... you could change it dynamically by calling the class' setTipDelay method. Like this:
code:
toolTip_mc = attachMovie("ToolTip_mc", "toolTip_mc", getNextHighestDepth());
toolTip_mc.setTipDelay(2000);
toolTip_mc.showToolTip("Button Five Info", this);
That way different buttons could have different tip delay times. Well...not sure that's really needed. But the same principle applies to background colors, borders etc. Each button could have it's own tip characteristics. If you want them all the same... do nothing and leave the default settings.
On the "Click" issue:
I've never seen syntax to combine events in one statement. I just added onRelease events in the fla and that fixes the problem. Maybe someone more knowledgable in ActionScript will suggest a way to do it with one line.
Anyway, check out the attached files and see if that helps with what you are doing.
CD
Thanks alot.
Great help
Zorra
I'm not crazy about this tool tip solution.
It does not work when testing movie and does not work in all browsers.
http://www.thecodebehind.com/resourc...p/default.aspx
Very simple to use tooltip set of functions.
Ben
Code:mes = new Array();
mes[0] = "Example";
mes[1] = "Home";
mes[2] = "Portfolio";
mes[3] = "Mail me";
mes[4] = "About us";
mes[5] = "iuyiuyi";
MovieClip.prototype.behav = function(){
this.onRollOver = function(){
_root.hovered = true
mess = mes[this.i];
}
this.onRollOut = function(){
_root.hovered = false;
}
this.onRelease = function(){
_root.hovered = false;
hover._visible = false;
}
}
for(i=0;i<5;i++){
this.createEmptyMovieClip("but"+i,i-50);
with(_root["but"+i]){
lineStyle(0);
beginFill(0x0000FF,100);
lineTo(120,0);
lineTo(120,20);
lineTo(0,20);
lineTo(0,0);
endFill();
}
_root["but"+i]._x = 100;
_root["but"+i]._y = 40+30*i;
_root["but"+i].i = i;
_root["but"+i].behav();
}
this.createEmptyMovieClip("hover",0);
hover.createEmptyMovieClip("shad",0);
with(hover.shad){
moveTo(2,2);
lineStyle(0);
beginFill(0x000000,70);
lineTo(122,2);
lineTo(122,22);
lineTo(2,22);
lineTo(2,2);
endFill();
}
hover.createTextField("tf", 1, 0,0,120, 20);
hover.tf.type = "dynamic";
hover.tf.variable = "tip";
hover.tf.textColor = 0x000000;
hover.tf.background = true;
hover.tf.backgroundColor = 0xF0F066;
hover.tf.selectable = false;
tform = new TextFormat();
tform.font = "Arial";
tform.size = 12;
tform.align = "center";
hover.tf.setNewTextFormat(tform);
hover.tip = "";
hover._visible = 0;
this.onMouseMove = function(){
if(hovered){
hover._visible = true;
hover._x = _xmouse;
hover._y = _ymouse-30;
hover.tip = mess;
}else{hover._visible = false;}
}