Return to Snippet

Revision: 28904
at July 16, 2010 01:21 by adrianparr


Initial Code
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));
	}
}

Initial URL


Initial Description
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.

Initial Title
AS3 Keep Track of Where FocusRect Is Whilst Tabbing

Initial Tags
path

Initial Language
ActionScript 3