it can but using simple buttons adds complexity to the coding:
// create one buttonObj for all your buttons
var buttonObj:Object={};
//////////////////////////////////////change nothing above ////////////////////////////////////
//the next 3 lines need to be done for all your buttons
buttonObj[yourbutton] = ["hello",2,2];
yourbutton.addEventListener(MouseEvent.MOUSE_OVER,addToolTipF) ;
yourbutton.addEventListener(MouseEvent.MOUSE_OUT, removeToolTipF);
////////////////////////////////////change nothing below/////////////////////////
function addToolTipF(e:MouseEvent):void{
var a:Array = buttonObj[e.currentTarget];
var tf:TextField=new TextField();
buttonObj[e.currentTarget].push(tf);
tf.text=a[0];
tf.multiline=false;
tf.autoSize="left";
tf.border=true;
addChild(tf);
tf.x=a[1]+e.currentTarget.x;
tf.y=a[2]+e.currentTarget.y;
}
function removeToolTipF(e:MouseEvent):void{
removeChild(buttonObj[e.currentTarget][3]);
buttonObj[e.currentTarget].split(3,1);
}
if both the add and remove functions are on the same timeline you won't see that error message. but i see a typo:
// create one buttonObj for all your buttons var buttonObj:Object={}; //////////////////////////////////////change nothing above //////////////////////////////////// //the next 3 lines need to be done for all your buttons buttonObj[yourbutton] = ["hello",2,2]; yourbutton.addEventListener(MouseEvent.MOUSE_OVER,addToolTipF) ; yourbutton.addEventListener(MouseEvent.MOUSE_OUT, removeToolTipF); ////////////////////////////////////change nothing below///////////////////////// function addToolTipF(e:MouseEvent):void{ var a:Array = buttonObj[e.currentTarget]; var tf:TextField=new TextField(); buttonObj[e.currentTarget].push(tf); tf.text=a[0]; tf.multiline=false; tf.autoSize="left"; tf.border=true; addChild(tf); tf.x=a[1]+e.currentTarget.x; tf.y=a[2]+e.currentTarget.y; } function removeToolTipF(e:MouseEvent):void{ removeChild(buttonObj[e.currentTarget][3]); buttonObj[e.currentTarget].splice(3,1); } |