ALT TEXT function for anybody who wants it:

I thought Id add a little function that displays alt-text (you know, the little textbox with alternative text that shows up on html-pages when the mouse is over an object, for instance an image) to give something back to the forum for all the help Ive been getting. Its not advanced or anything, but perhaps somebody will find it useful.

  1. First youll have to define the functions (preferably in an included .as-file):


/////////// AltTxt ////////////////	
// PARAMETERS : 1) the text to display as alt-text 
// 2) x-position of button 3) y-position of button
// 4) width of button 5) height of button
function fn_AltTxt(alt_txt, x, y, bredd, hojd){

// adjusting the position of the textbox a little	
pos_x = x - 20; 
pos_y = y - (23 + (hojd / 2));

// create textbox "txt_AltTxt"
_root.createTextField("txt_AltTxt", 1, pos_x, pos_y, 0, 20);
// border around the textbox
txt_AltTxt.border = true;
// the textbox will autosize, expanding to the right		
txt_AltTxt.autoSize = "left";	
// there is a background (ie. not see-trough), with default color white
txt_AltTxt.background = true;	
// the text inside the textbox is not selectable
txt_AltTxt.selectable = false;
// put the text defined in the button into the textbox
txt_AltTxt.text = alt_txt;		
}
///////////// end ///////////////


////////// killAltTxt ///////////
function fn_killAltTxt(){
// deletes the textbox when the mouse leaves the button
_root.txt_AltTxt.removeTextField();
}
///////////// end ///////////////


The code will show the alt-text just above the object (instead of positioning itself after the position of the mouse). You can edit the “pos_x” and “pos_y” values to have the alt-text displayed somewhere else.

  1. Then youll have to add this code to every object (buttons, movieclips etc) that you want alt-text for:


on (rollOver) {
// change first parameter to whatever 
// alt-text you desire (it will autosize)
_root.fn_AltTxt("Change this text", this._x, this._y, this._width, this._height);
}

on (rollOut){
_root.fn_killAltTxt();
}


Thats it! All youll have to change is the first parameter in the function-call to fn_AltTxt.

ps. If you want the alt-text to position itself after the position of the mouse, then youll have to edit the second and third parameters sent with the fn_AltTxt - call to “_root._xmouse” and “_root._ymouse”.