Posted By

adrianparr on 07/16/10


Tagged

path name accessibility focus trace as3 tab rect tabindex focusrect yellow focusin


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Nikolai
shalomfriss
tspitzr


AS3 Keep Track of Where FocusRect Is Whilst Tabbing


 / Published in: ActionScript 3
 

This code traces out the name (and display list path) of the object that currently has focus. This handy when you are testing the tab order and you can't see a yellow rectangle anywhere.

  1. import flash.events.FocusEvent;
  2.  
  3. stage.addEventListener(FocusEvent.FOCUS_IN, onStage_FOCUS_IN);
  4.  
  5. function onStage_FOCUS_IN(event:FocusEvent):void
  6. {
  7. focusInPath(DisplayObject(event.target));
  8. }
  9.  
  10. function focusInPath(dispObj : DisplayObject, s : String = ""):void
  11. {
  12. if (dispObj.parent != null) {
  13. focusInPath(dispObj.parent, s + "." + dispObj.name);
  14. } else {
  15. var a:Array = s.split(".").reverse();
  16. var output:String = "";
  17. for (var i : Number = 0; i < a.length; i++) {
  18. output = output + "." + a[i];
  19. }
  20. trace("FOCUS_IN: " + output.substr(1, output.length - 2));
  21. }
  22. }

Report this snippet  

You need to login to post a comment.