views:

18

answers:

2

for example i have object one a Textinput haveing id="

id_txtBox

", and a panel having a lot of children(TextInputs, Trees, Buttons etc.).. if user is editing text in one of panel's child and then clik on "id_txtBox". can we get to know

the id/object user were editing before the click on "id_txtBox

". i mean from which object the "id_txtBox" has stolen focus..?

A: 

You can maintain history of objects in focus internally. So whenever an object acquires focus add it to the history. So if you want to query from which object, current focussed object has stolen focus you need to check the previous object in the history. You can setup your history to store as many object as you want according to your needs and keep removing the oldest object history exceeds its size.

bhups
+1  A: 

Add an event listener to each child that will update a currentChild property by getting the name of the clicked element.


 var previousChild:DisplayObject;
 var currentChild:DisplayObject;

 panelChild.addEventListener(MouseEvent.CLICK , clickHandler );

private function clickHandler(event:MouseEvent):void
{ 
  //to avoid an error on the first click
  if(currentChild != null )
     previousChild = currentChild;

  // do whatever you need to do here, after it's complete, update the currentChild value;
  // this way the previousChild value indicates the object that was clicked before

  currentChild = this.getChildByName(event.currentTarget.name );
}
PatrickS