Friday 21 December 2012

How to set depth index in action script



var aindex = getChildIndex(a);
var bindex = getChildIndex(b);
var cindex = getChildIndex(c);
trace(aindex);
trace(bindex);
trace(cindex);
xx.addEventListener(MouseEvent.CLICK, clickScrollerItem);
function clickScrollerItem(e:MouseEvent):void
{
    //setChildIndex( bindex, 0);
   

    if (a > b)
    {
        setChildIndex(a,b.numChildren);
    }
    if (a < b)
    {
        setChildIndex(a,b.numChildren-1);
    }
    trace(aindex);
    trace(bindex);
    trace(cindex);
}

1. Create a movieclips with the instance names a,b,c,d.

Arrange as per the Fig below and press Ctrl+Enter to check output :

0
1
2



No comments:

Post a Comment