Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help me fix tooltip delay error

Guest
Jun 21, 2011 Jun 21, 2011

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!

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Jul 01, 2011 Jul 01, 2011

It fixed and sent you the mail

Translate
Mentor ,
Jun 21, 2011 Jun 21, 2011

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);
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 21, 2011 Jun 21, 2011

Same errors given

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 22, 2011 Jun 22, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 23, 2011 Jun 23, 2011

Mine are buttons not movieclips...can I solve it without having to change everything to movieclips? thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 23, 2011 Jun 23, 2011

The same code is also works with buttons. Tested it here. or otherwise send your source relaxatraja@aol.com to have a look.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 24, 2011 Jun 24, 2011

Just sent you the source...thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 01, 2011 Jul 01, 2011

It fixed and sent you the mail

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2011 Jul 01, 2011

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 01, 2011 Jul 01, 2011
LATEST

You'r Welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines