ActionScript 3 – Z index function

This function lets you calculate the z-index or depth of an object in a flash movie based on its vertical position. The greater the y component the closer to the viewer the object is.


elements.sortOn("y", Array.NUMERIC);

var i:int = this.numChildren;
var a:int = elements.length;
while(a--){
i--;
setChildIndex(elements[a], i);
}

Leave a Reply

You must be logged in to post a comment.