Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>[[Edit]]</p> <p>The attached method will not work if both target objects are leaf nodes in a shared parent.</p> <hr> <p>The timeline children are always under whatever actionscript generated children are associated to the timeline class.</p> <p>e.g.</p> <p>If you have timeline X, which extends ClassA, and in Class A, you add children E, F, G, but timeline X contains layers B, C, D, each with a single symbol in each layer, with layer B at the bottom of the timeline, the following would be observed:</p> <pre><code>child 5: G child 4: F child 3: E child 2: D child 1: C child 0: B </code></pre> <p>To expand on a felipemaia's answer, I've devised the following method to determine which movie clip lies absolutely above the other. This has not been thoroughly tested, but should operate as a baseline for your development.</p> <pre><code>function selectAbove(obj1:DisplayObject, obj2:DisplayObject):DisplayObject { var obj1_parentCount:int = parentCount(obj1); var obj2_parentCount:int = parentCount(obj2); var target:DisplayObject; var other:DisplayObject; if (obj1_parentCount &gt; obj2_parentCount) { target = obj1; other = obj2; } else { target = obj2; other = obj1; } var container:DisplayObjectContainer = (target is DisplayObjectContainer) ? target as DisplayObjectContainer : target.parent ; var container_last:DisplayObjectContainer; var sharedParent:DisplayObjectContainer; while(container) { if(container.contains(other)) { sharedParent = container; break; } container_last = container; container = container.parent; } if(!sharedParent) { throw new Error("An object does not maintain its parent in the display heirarchy!"); } var ret:DisplayObject; if(container == other) { ret = target; } return container != other ? container.getChildIndex(container_last) &lt; container.getChildIndex(other) ? other : target : target ; } function parentCount(obj:DisplayObject):int { var ret:int = 0; while(obj) { ret++; obj = obj.parent; } return ret; } </code></pre> <p>This method will work for nested display hierarchies. I have not tested this 100%, but initial cases completed as expected.</p> <p>Best of luck!</p>
 

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