Problems with listening for an event in child object in Actionscript
        Posted  
        
            by Raigomaru
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Raigomaru
        
        
        
        Published on 2010-03-21T19:57:27Z
        Indexed on 
            2010/03/22
            2:41 UTC
        
        
        Read the original article
        Hit count: 335
        
I have two classes. The first one (the starting class):
package
{
 import flash.display.Sprite;
 import flash.events.KeyboardEvent;
 import tetris.*;
 public class TetrisGame extends Sprite
 {
  private var _gameWell:Well;
  public function TetrisGame()
  {    
   _gameWell = new Well();
   addChild(_gameWell);
  } 
 }
}
The second:
package tetris
{
 import flash.display.Sprite;
 import flash.events.KeyboardEvent;
 public class Well extends Sprite
 {
  public function Well()
  {
   super();
   addEventListener(KeyboardEvent.KEY_DOWN, onKeyboard);
  }
  private function onKeyboard(event:KeyboardEvent):void
  {
   //some code is here
  }
 }
}
But when I press any buttons on my keyboard, the child class Well doesn't have any reaction. What's the problem?
© Stack Overflow or respective owner