-
Notifications
You must be signed in to change notification settings - Fork 1
/
ToolTip.as
99 lines (85 loc) · 2.77 KB
/
ToolTip.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.events.MouseEvent;
import Sombra;
import Delay;
public class ToolTip extends Sprite {
private var _ruta:Sprite;
private var _boton:Object;
private var _clip:Sprite;
private var _fondo:Shape;
private var _texto:TextField;
private var _formato:TextFormat;
private var _sombra:Sombra;
private var _delay:Delay;
public function ToolTip(boton:Object, texto:String) {
_ruta = boton.parent;
_boton = boton;
_clip = new Sprite();
_clip.x = _boton.x;
_clip.y = _boton.y;
_clip.visible = false;
_ruta.addChild(_clip);
iniFondo();
iniTexto();
iniEvents();
setTexto(texto);
}
private function iniFondo():void {
_fondo = new Shape();
_fondo.x = _fondo.y = 0;
_sombra = new Sombra(_fondo);
_clip.addChild(_fondo);
}
private function iniTexto():void {
_texto = new TextField();
_texto.autoSize = TextFieldAutoSize.LEFT;
_texto.background = false;
_texto.border = false;
_texto.multiline = false;
_formato = new TextFormat();
_formato.font = "Verdana";
_formato.color = 0x000000;
_formato.size = 10;
_formato.underline = false;
_texto.defaultTextFormat = _formato;
_texto.x = 5;
_texto.y = 0;
_clip.addChild(_texto);
}
public function setTexto(texto:String):void {
_texto.text = texto;
updateFondo(_texto.textWidth+15,_texto.textHeight+5);
}
private function updateFondo(qWidth:int,qHeight:int):void {
_fondo.graphics.clear();
_fondo.graphics.beginFill(0xFFFFCC);
_fondo.graphics.lineStyle(1, 0x999999);
_fondo.graphics.drawRect(0, 0, qWidth, qHeight);
_fondo.graphics.endFill();
}
private function iniEvents() {
_boton.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
_boton.addEventListener(MouseEvent.MOUSE_MOVE, mouse_move);
_boton.addEventListener(MouseEvent.MOUSE_OUT, mouse_out);
}
private function mouse_over(event:MouseEvent):void {
Delay.action(1,true,this,"mouse_over2");
}
public function mouse_over2():void {
_clip.visible = true;
}
private function mouse_move(event:MouseEvent):void {
_clip.x = mouseX ;
_clip.y = mouseY + 20;
}
private function mouse_out(event:MouseEvent):void {
_clip.visible = false;
Delay.reset();
}
}
}