Copy link to clipboard
Copied
I have a tooltip function which worked perfectly until I decided to introduce a delay so that the tooltip does not appear immediately upon hovering. The initial function (which works well) is the following:
buttonObj[Save_btn.name] = ["Save Current Product Requirements to XML file",-50,-25];
Save_btn.addEventListener(MouseEvent.MOUSE_OVER,addToolTipF) ;
Save_btn.addEventListener(MouseEvent.MOUSE_OUT, removeToolTipF);
//function addToolTipF(e:MouseEvent):void{
// setTimeout(toolTipF,3000,e);
//}
function addToolTipF(e:MouseEvent):void{
var a:Array = buttonObj[e.currentTarget.name];
var tf:TextField=new TextField();
buttonObj[e.currentTarget.name].push(tf);
tf.text=a[0];
tf.multiline=false;
tf.autoSize="left";
tf.border=true;
tf.background=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.name][3]);
buttonObj[e.currentTarget.name].splice(3,1);
}
The following is upon introducing the delay (only changes performed are in bold, so error must be in the bold parts):
buttonObj[Save_btn.name] = ["Save Current Product Requirements to XML file",-50,-25];
Save_btn.addEventListener(MouseEvent.MOUSE_OVER,addToolTipF) ;
Save_btn.addEventListener(MouseEvent.MOUSE_OUT, removeToolTipF);
function addToolTipF(e:MouseEvent):void{
setTimeout(toolTipF,3000,e);
}
function toolTipF(e:MouseEvent):void{
var a:Array = buttonObj[e.currentTarget.name];
var tf:TextField=new TextField();
buttonObj[e.currentTarget.name].push(tf);
tf.text=a[0];
tf.multiline=false;
tf.autoSize="left";
tf.border=true;
tf.background=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.name][3]);
buttonObj[e.currentTarget.name].splice(3,1);
}
The error is the following. Note that error is produced even when I rest for 10seconds on the button so it's not a matter of not allowing time for the tooltip to appear.
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at Websiteversion3_Scene1_fla::MainTimeline/removeToolTipF()[Websitevers ion3_Scene1_fla.MainTimeline::frame1:246]
TypeError: Error #1010: A term is undefined and has no properties.
at Websiteversion3_Scene1_fla::MainTimeline/toolTipF()[Websiteversion3_S cene1_fla.MainTimeline::frame1:234]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at SetIntervalTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Please help me fix the error, thanks!
It fixed and sent you the mail ![]()
Copy link to clipboard
Copied
buttonObj[Save_btn.name] = ["Save Current Product Requirements to XML file",-50,-25];
Save_btn.addEventListener(MouseEvent.MOUSE_OVER,addToolTipF) ;
Save_btn.addEventListener(MouseEvent.MOUSE_OUT, removeToolTipF);
function addToolTipF(e:MouseEvent):void{
var myDelay:Timer = new Timer(3000);
myDelay.addEventListener(TimerEvent.TIMER, toolTipF);
myDelay.start();
function toolTipF(event:TimerEvent):void{
var a:Array = buttonObj[e.currentTarget.name];
var tf:TextField=new TextField();
buttonObj[e.currentTarget.name].push(tf);
tf.text=a[0];
tf.multiline=false;
tf.autoSize="left";
tf.border=true;
tf.background=true;
addChild(tf);
tf.x=a[1]+e.currentTarget.x;
tf.y=a[2]+e.currentTarget.y;
}//toolTipF
}//addToolTipF
function removeToolTipF(e:MouseEvent):void{
removeChild(buttonObj[e.currentTarget.name][3]);
buttonObj[e.currentTarget.name].splice(3,1);
}
Copy link to clipboard
Copied
Same errors given ![]()
Copy link to clipboard
Copied
Save_btn.addEventListener(MouseEvent.MOUSE_OVER,addToolTipF) ;
function addToolTipF(e:MouseEvent):void{
var myDelay:Timer = new Timer(3000);
myDelay.addEventListener(TimerEvent.TIMER, toolTipF);
myDelay.start();
function toolTipF(event:TimerEvent):void{
var tf:TextField=new TextField();
tf.text=e.target.name;
tf.multiline=false;
tf.autoSize="left";
tf.border=true;
tf.background=true;
addChild(tf);
tf.x=e.currentTarget.x+20;
tf.y=e.currentTarget.y+20;
}//toolTipF
}//addToolTipF
I just tested with a movieclip it works fine.
Copy link to clipboard
Copied
Mine are buttons not movieclips...can I solve it without having to change everything to movieclips? thanks
Copy link to clipboard
Copied
The same code is also works with buttons. Tested it here. or otherwise send your source relaxatraja@aol.com to have a look.
Copy link to clipboard
Copied
Just sent you the source...thanks ![]()
Copy link to clipboard
Copied
It fixed and sent you the mail ![]()
Copy link to clipboard
Copied
Thanks ![]()
Copy link to clipboard
Copied
You'r Welcome ![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more