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