package
{
/**
* ...
* @description : This Class can be used when you need to adjust depth of objects according to their heights.
* @author Aava Rani
*/
public class DepthSortingClass extends MovieClip
{
private var _parent:Object
public function DepthSortingClass()
{
super();
}
public function setSortingParent(__parent:Object):void {
_parent = __parent
}
public function sortDisplayList():void {
var len:uint = _parent.numChildren;
var i, j;
for ( i = 0; i < len - 1; i++ )
for (j = i + 1; j < len; j++)
if ( _parent.getChildAt(i).y > _parent.getChildAt(j).y )
_parent.swapChildrenAt( i, j );
}
}
}
Tags: Application, Array, complex data, depth sorting, External Interface, ExternalInterface.available, HorizontalLayout, Important Classes for games in AS 3.0, JavaScript, JavaScript using External Interface, KEY and hitTestPoint, KEY Press, keyboard command, KeyBoardEvent, maximum, minimum, numChildren, Object, random number, range, Remove All Children, remove All MovieClips From Array, Remove MovieClips, removeChild, setChildIndex, ShakingEffect, swapDepth, Timer, transfer Array, transfer Array within an Object to JavaScript using External Interface, transfer complex data, x position, y, y position


Follow us on Twitter