forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetParents.as
More file actions
28 lines (25 loc) · 970 Bytes
/
getParents.as
File metadata and controls
28 lines (25 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package utils.display
{
import flash.display.DisplayObject;
/**
* Get the parents of a display object as an array
* @param obj Object whose parents should be retrieved
* @param includeSelf If obj should be included in the returned array
* @param stopAt Display object to stop getting parents at. Passing
* null indicates that all parents should be included.
* @return An array of the parents of the given display object. This
* includes all parents unless stopAt is non-null. If stopAt is
* non-null, it and its parents will not be included in the
* returned array.
* @author Jackson Dunstan
*/
public function getParents(obj:DisplayObject, includeSelf:Boolean = true, stopAt:DisplayObject = null):Array
{
var ret:Array = [];
for (var cur:DisplayObject = includeSelf ? obj : obj.parent; cur != stopAt && cur != null; cur = cur.parent)
{
ret.push(cur);
}
return ret;
}
}