1 Reply Latest reply on Aug 2, 2010 10:29 PM by Flex harUI

    Why is my object not getting deleted?

    iamcootis Level 1

      I have a character Map object that adds two eventListeners on creationComplete.One of the character maps is in Spanish and the other is in French, so I only want one to be working at a time. So if one is initialized and then the user decides to use the other one, the first on is destroyed.

       

      The initialization looks like this:

       

      public function init():void{
                      stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, false, 0 , true);
                      stage.addEventListener(KeyboardEvent.KEY_UP,keyUpHandler, false, 0 , true);
                  }

       

      I am deleting the object like this:

       

      private function wordListLoaded(event:ApplicationEvent):void{
                      var charMapArray:Array = charMapBox.getChildren();
                      for(var i:int = 0; i < charMapArray.length; i++){
                          charMapArray[i].removeEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
                          charMapArray[i].removeEventListener(KeyboardEvent.KEY_UP,keyUpHandler);
                         
                          delete charMapArray[i];
                          charMapBox.removeAllChildren();
                      }

      }

       

      For some reason, even though I remove the Event listeners and then delete the object, the event listeners are still catching the events. How can I be sure to completely delete this object?