Apr. 16, 2008
En este primer post voy a mostrar el uso basico de Eventos en AS3
This movie requires Flash Player 9
?Download eventosintro.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 | package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.TextField; /** * ... * @author EzeQL * @see WWW.EZEQL.COM/BLOG */ public class EventosIntro extends Sprite { private var _box:Sprite; private var _tf:TextField; private var _click:int = 0; private const VECES_CLICK:String = " veces clickeado"; public function EventosIntro() { draw(); initListeners(); } private function draw():void { _box = new Sprite(); _box.graphics.lineStyle(1, 0); _box.graphics.beginFill(0xFF0000); _box.graphics.drawCircle(50, 75, 50); _box.graphics.endFill(); _box.alpha = 0.4; addChild(_box); _tf = new TextField(); _tf.selectable = false; _tf.textColor = 0x0000ff; _tf.autoSize = flash.text.TextFieldAutoSize.LEFT; updateText(); addChild(_tf); } private function initListeners():void { _box.addEventListener(MouseEvent.CLICK, onBoxCLick, false, 0, true); _box.addEventListener(MouseEvent.MOUSE_OVER, onBoxOver, false, 0, true); _box.addEventListener(MouseEvent.MOUSE_OUT, onBoxOut, false, 0, true); } private function onBoxOut(e:MouseEvent):void { _box.alpha = .4; } private function onBoxOver(e:MouseEvent):void { _box.alpha = 1; } private function onBoxCLick(e:MouseEvent):void { _click++; _box.x++; _box.y++; updateText(); } private function updateText():void{ _tf.text = _click.toString() + VECES_CLICK; } } } |