Per Sommer
Whatever makes my world go around
Jul 15 2008 | as3, code, snippet 1 Comment »

This function will trace the path DisplayObject for a DisplayObject back to root in Actionscript 3. Useful for seeing witch containers it’s belonging to.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private function tracePath (dispObj : DisplayObject, s : String = "") : void
{
	if(dispObj.parent != null)
	{
		tracePath(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("PATH: " + output.substr(1, output.length - 2));
	}
}

Usage example:

1
2
objName.name = "myDisplayObjectTest"
tracePath(objName);

Output example:

1
PATH: root1.movPreloaderHolder.loaderHolder.instance3.myDisplayObjectTest
Mar 19 2007 | Uncategorized 5 Comments »

WorldWow! So finally I managed to join the revolution and get my own blog. About time as I’ve had this domain name and hosting for nearly two years now. I’ve been spending the last week designing and setting up WordPress to fit my needs. It took a while to find the right plugins and modifying them to suit my needs. Hopefully, and in a short amount of time, I will be able write some decent and interesting tutorials. Now if only i could think of one that isn’t out there already. Meanwhile you may go have a look at my portfolio

About

This template is built with validated CSS and XHTML. © Per Sommer unless noted otherwise.

FireStats iconPowered by FireStats