Bring to front, send to back

Flash, Flex Add comments

These are some util functions I use to order my components on screen. They’re so simple and straightforward that maybe someone else could have written it allready. If that’s the case, please warn me: I’ll post the link here.

/*****************************/

[code lang="actionscript"] package com.util{
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;

public class ObjectOrdering{

public static function bringToFront(object:DisplayObject):void{
var father:DisplayObjectContainer=DisplayObjectContainer(object.parent);
var brothers:int=father.numChildren;
father.setChildIndex(object,brothers-1);
}

public static function sendToBack(object:DisplayObject):void{
var father:DisplayObjectContainer=DisplayObjectContainer(object.parent);
father.setChildIndex(object, 0);
}
}
} [/code]

3 Responses to “Bring to front, send to back”

  1. kumar Says:

    Thanks a lot.

  2. William Says:

    Parabenéns Gabriela,foi bem Util pra mim =)

    vlw

  3. Anderson Says:

    Muito util, obrigado pela ajuda

    Att,

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in