Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/08/2008, 05:36
Pez_del_Web
 
Fecha de Ingreso: julio-2007
Mensajes: 239
Antigüedad: 16 años, 10 meses
Puntos: 2
capturar teclado

saludos,

estoy intentando capturar las pulsaciones del teclado pero no lo logro

el código que he generado es el siguiente

Main
Código:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"		
	xmlns="pack_probando.*"
	creationComplete="inicia()" >
		
	<mx:Script>
        <![CDATA[  

            public function inicia():void
            {
                id_prueba.init();               
            }
		]]>
	</mx:Script>

  <MyPrueba id="id_prueba" width="300" height="300" />
</mx:Application>

pack_probando
Código:
package pack_probando{
	import MisClases.Captura_Teclado;	
        import mx.core.UIComponent;
	
	import mx.controls.Alert; 			
	

	public class MyPrueba extends UIComponent{		
		private var t:Captura_Teclado;
		
		//iniciamos
		public function init():void {		
			t=new Captura_Teclado(this);			
			
		}
		
   }
}


Misclases

Código:
package MisClases {
	import flash.events.*;
	import mx.core.*;
	import mx.controls.Alert; 			
	
	public class Captura_Teclado extends UIComponent {
		 public function Captura_Teclado(aParent:UIComponent) {
			  aParent.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
			  aParent.addEventListener(KeyboardEvent.KEY_UP, keyUp);
		 }

		 private function keyDown(event:KeyboardEvent):void {
		 	Alert.show("dejo de pulsar");
		 }

		 private function keyUp(event:KeyboardEvent):void {
		 	Alert.show("pulso "+event.keyCode.toString() );
                }
	}
}
¿alguien podría ayudarme?