EzeQL's Blog Actionscript and more..

27Apr/080

SimpleButton, Botones en as3

La clase SimpleButton proporciona una forma fácil de crear los típicos estados de un botón pasandole  las imagenes de los estados que este mostrara.

Ejemplo:

[SWF]

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
package
{
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import caurina.transitions.Tweener;
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
import flash.geom.Rectangle;
 
public class Main extends Sprite
{
/*www.ezeql.com*/
private var _button_on:Sprite;
private var _button_out:Sprite;
private var _button_press:Sprite;
 
private var _simpleButton:SimpleButton;
 
public function Main():void
{
_button_on = new Sprite();
_button_out = new Sprite();
_button_press = new Sprite();
 
_button_on.addChild(drawButton(0xff0000));
_button_on.filters = [new DropShadowFilter()];
 
_button_out.addChild(drawButton(0x00ff00));
_button_out.filters = [new DropShadowFilter(8)];
 
_button_press.addChild(drawButton(0x0000ff));
_button_press.filters = [new DropShadowFilter(15)];
 
_simpleButton = new SimpleButton(_button_on, _button_out, _button_press,_button_on);
_simpleButton.x = 150;
_simpleButton.y = 125;
 
_simpleButton.addEventListener(MouseEvent.CLICK, SimpleButton_Click);
 
addChild(_simpleButton);
}
 
private function SimpleButton_Click(e:MouseEvent):void
{
trace("click");
}
 
private function drawButton(pColor:uint ):Shape
{
var _rect:Shape = new Shape();
with (_rect.graphics)
{
lineStyle(1);
beginFill(pColor);
drawCircle(0,0,100);
 
}
return _rect;
}
 
}
}
Comments (0) Trackbacks (1)

Leave a comment