Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want the "complete path" like meddlingwithfire suggested in his comment on 3lionz's answer, then you can use a class I created that does it for you. The class is called DOPath(short for display object path). The following is an example of it being used to get the complete path of a display object:</p> <p><strong>Main.as</strong>(document class):</p> <pre><code>package { import com.example.display.DOPath; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); }// end function private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); var container1:Sprite = new Sprite(); container1.name = "container1"; var container2:Sprite = new Sprite(); container2.name = "container2"; var square:Square = new Square(); square.name = "square"; square.addEventListener(MouseEvent.CLICK, onSquareClick); addChild(container1); container1.addChild(container2); container2.addChild(square); }// end function private function onSquareClick(e:MouseEvent):void { var square:Square = e.target as Square; var doPath:DOPath = new DOPath(square); trace(doPath); // output: stage.root1.container1.container2.square }// end function }// end package }// end package import flash.display.Sprite; internal class Square extends Sprite { public function Square() { graphics.beginFill(0xFF0000); graphics.drawRect(0, 0, 100, 100); graphics.endFill(); }// end function }// end class </code></pre> <p><strong>DOPath.as</strong>:</p> <pre><code>package com.example.display { import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.Stage; public class DOPath { private var _parents:Vector.&lt;DisplayObjectContainer&gt;; private var _d:DisplayObject; public function DOPath(d:DisplayObject):void { _d = d; init(); }// end function private function init():void { _parents = new Vector.&lt;DisplayObjectContainer&gt;; pushParent(_d); }// end function private function pushParent(d:DisplayObject):void { if(d.parent) { _parents.push(d.parent); pushParent(d.parent); }// end if }// end function public function toString():String { var path:String = _d.name; for (var i:uint = 0; i &lt; _parents.length; i++) { var name:String = (_parents[i] is Stage) ? "stage" : _parents[i].name; path = name + "." + path; }// end for return path; }// end function }// end class }// end package </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload