# Tooltip help

**URL:** https://forum.kirupa.com/t/tooltip-help/305181
**Category:** Uncategorized
**Created:** [February 20, 2010, 2:29pm UTC](https://forum.kirupa.com/t/tooltip-help/305181 "2010-02-20T14:29:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![izzo101](https://avatars.discourse-cdn.com/v4/letter/i/c6cbf5/32.png) [@izzo101](https://forum.kirupa.com/u/izzo101)
#### Post date: [February 20, 2010, 2:29pm UTC](https://forum.kirupa.com/t/tooltip-help/305181/1 "2010-02-20T14:29:02Z")

</div>

[FONT=arial][SIZE=3]Got this layout with previous and a next buttons and I’m trying to attach tooltips to both but when I get back to the first page I receive this error.[/SIZE][/FONT]  
[FONT=Arial][SIZE=3][/SIZE][/FONT]  
[FONT=arial][SIZE=3]RangeError: Error #2006: The supplied index is out of bounds.  
at flash.display::DisplayObjectContainer/removeChildAt()  
at Project\_fla::MainTimeline/removeToolTip()[/SIZE][/FONT]  
[FONT=arial][SIZE=3]Can anyone help tell me what’s wrong without me having to recreate the whole layout. Thanks. Here is the code:[/SIZE][/FONT]

[FONT=Arial][SIZE=3]var box\_pos = 10;  
var x\_pos = -20; var y\_pos = 10; [/SIZE][/FONT]  
[FONT=Arial][SIZE=3]var tooltip:MovieClip = new MovieClip();  
this.addChild(tooltip);[/SIZE][/FONT]  
[FONT=Arial][SIZE=3]var txt:TextField = new TextField();  
txt.multiline = true;  
txt.autoSize = TextFieldAutoSize.LEFT;[/SIZE][/FONT]  
[FONT=Arial][SIZE=3]var tf:TextFormat = new TextFormat();  
tf.size = 14;  
txt.defaultTextFormat = tf[/SIZE][/FONT]  
[FONT=Arial][SIZE=3]function showTip(ttip,color,c1,c2,c3,c4)  
{  
tooltip.x = mouseX-x\_pos;  
tooltip.y = mouseY-tooltip.height-y\_pos;  
txt.htmlText = ttip  
var h:Number = txt.height+box\_pos;  
var w:Number = txt.width+box\_pos;  
drawShape(txt.x-5,txt.y-5,w,h,c1,c2,c3,c4,color)  
}[/SIZE][/FONT]  
[FONT=Arial][SIZE=3]function drawShape(x,y,w,h,c1,c2,c3,c4,color)  
{  
tooltip.visible = true;  
var shape:Shape = new Shape();  
var graphic:Graphics = shape.graphics;  
graphic.beginFill(color,.4); [/SIZE][/FONT][FONT=Arial][SIZE=3] [/SIZE][/FONT]  
[FONT=Arial][SIZE=3] graphic.lineStyle(0,0x95969A);  
graphic.drawRoundRectComplex(x,y,w,h,c1,c2,c3,c4);  
tooltip.addChild(shape);  
tooltip.addChild(txt);  
}[/SIZE][/FONT]  
[FONT=Arial][SIZE=3]function moveToolTip(event:MouseEvent)  
{  
tooltip.x = mouseX-x\_pos;  
tooltip.y = mouseY-tooltip.height-y\_pos;  
event.updateAfterEvent();  
}[/SIZE][/FONT]  
[FONT=Arial][SIZE=3]function removeToolTip(event:MouseEvent) {  
tooltip.removeChildAt(0);  
tooltip.visible = false;  
}[/SIZE][/FONT]  
[FONT=Arial][SIZE=3]nextBtn.addEventListener(“mouseMove”,moveToolTip);  
nextBtn.addEventListener(“mouseOut”,removeToolTip);  
nextBtn.addEventListener(“mouseOver”,function(){  
showTip("\<font color=’#000000’\>Next Page\</font\>",0x95969A,17,17,17,17) [/SIZE][/FONT]  
[FONT=Arial][SIZE=3] } [/SIZE][/FONT]  
[FONT=Arial][SIZE=3] ) [/SIZE][/FONT]  
[FONT=Arial][SIZE=3]prevBtn.addEventListener(“mouseMove”,moveToolTip);  
prevBtn.addEventListener(“mouseOut”,removeToolTip);  
prevBtn.addEventListener(“mouseOver”,function(){  
showTip("\<font color=’#000000’\>Previous Page\</font\>",0x95969A,17,17,17,17) [/SIZE][/FONT]  
[FONT=Arial][SIZE=3] } [/SIZE][/FONT]  
[FONT=Arial][SIZE=3] )[/SIZE][/FONT]  
[FONT=Arial][SIZE=3][/SIZE][/FONT]
