# Tooltip and button

**URL:** <https://forum.kirupa.com/t/tooltip-and-button/258372>\
**Category:** flash\
**Created:** [April 23, 2008, 2:22pm UTC](https://forum.kirupa.com/t/tooltip-and-button/258372 "2008-04-23T14:22:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![baljane\_hamre](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@baljane\_hamre](https://forum.kirupa.com/u/baljane_hamre)\
**Post date:** [April 23, 2008, 2:22pm UTC](https://forum.kirupa.com/t/tooltip-and-button/258372/1 "2008-04-23T14:22:36Z")

</div>

Hi, I’m learning AS3 and trying to create tooltip which pops up when a button is rolled over. Can anyone please tell me how to attach this code to a button? What this code does now, is create a line and a rectangle which follows the mousepointer.

What I what to do is to activate this code snippet when the mousepointer rolls over a button…

> package {  
> import flash.display.MovieClip;  
> import flash.display.Sprite;  
> import flash.events.Event;

```
public class ToolTip extends Sprite {
    private var ball:Ball;
    private var easing:Number = 0.05;

    public function ToolTip() {
        init();
    }
    
    
    public function init():void {
        ball = new Ball();
        addChild(ball);
        addEventListener(Event.ENTER_FRAME, myEnterFrame);
    }
    public function myEnterFrame(event:Event):void {
        var vx:Number = (mouseX - ball.x+200) * easing;
        var vy:Number = (mouseY - ball.y-150) * easing;
        ball.x += vx;
        ball.y += vy;
        graphics.clear();
        graphics.lineStyle(2, 0, 0.2, true, "none", "none", "round");
        graphics.moveTo(ball.x, ball.y);
        graphics.lineTo(mouseX, mouseY);

    }
}

```

}
