/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import flash.events.FocusEvent; stage.addEventListener(FocusEvent.FOCUS_IN, onStage_FOCUS_IN); function onStage_FOCUS_IN(event:FocusEvent):void { focusInPath(DisplayObject(event.target)); } function focusInPath(dispObj : DisplayObject, s : String = ""):void { if (dispObj.parent != null) { focusInPath(dispObj.parent, s + "." + dispObj.name); } else { var a:Array = s.split(".").reverse(); var output:String = ""; for (var i : Number = 0; i < a.length; i++) { output = output + "." + a[i]; } trace("FOCUS_IN: " + output.substr(1, output.length - 2)); } }