Revision: 37857
Updated Code
at December 18, 2010 12:49 by burnandbass
Updated Code
package game.utils{
import flash.display.DisplayObject;
/*
burnandbass[at]gmail
util for easy managing depths / z-index in stack of a displayObject
Only works within display object's parent list
*/
public class DisplayUtil {
public function DisplayUtil() {
trace("use with static methods only!");
}
//sets the Display Object of the top of the stack
public static function sendFront(_do:DisplayObject):void {
_do.parent.setChildIndex(_do,_do.parent.numChildren - 1);
}
//sends @_do below @child
public static function sendBelow(_do:DisplayObject, child:DisplayObject):void {
_do.parent.setChildIndex(_do, _do.parent.getChildIndex(child))
}
//sets @_do above @child
public static function sendAbove(_do:DisplayObject, child:DisplayObject):void {
_do.parent.setChildIndex(_do, _do.parent.getChildIndex(child));
_do.parent.swapChildren(_do, child);
}
//sets @_do at the back of the display list stack
public static function sendBack(_do:DisplayObject):void {
_do.parent.setChildIndex(_do,0);
}
}//end
}
Revision: 37856
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 18, 2010 12:10 by burnandbass
Initial Code
package game.utils{
import flash.display.DisplayObject;
/*
burnandbass[at]gmail
util for easy managing depths / z-index in stack of a displayObject
Only works within display object's parent list
*/
public class DisplayUtil {
public function DisplayUtil() {
trace("use with static methods only!");
}
//sets the Display Object of the top of the stack
public static function sendFront(_do:DisplayObject):void {
_do.parent.setChildIndex(_do,_do.parent.numChildren - 1);
}
//sends @_do below @child
public static function sendBelow(_do:DisplayObject, child:DisplayObject):void {
_do.parent.setChildIndex(_do, _do.parent.getChildIndex(child))
}
//sets @_do above @child
public static function sendAbove(_do:DisplayObject, child:DisplayObject):void {
_do.parent.setChildIndex(_do, _do.parent.getChildIndex(child));
_do.parent.swapChildren(_do, child);
}
//sets @_do at the back of the display list stack
public static function sendBack():void {
_do.parent.setChildIndex(_do,0);
}
}//end
}
Initial URL
Initial Description
the code is self-explanary
Initial Title
Util for managing DisplayObject\'s depths
Initial Tags
Initial Language
ActionScript 3