Monday, May 2, 2011

Stacking Order / Draw Order Explained. AS3

Original Thread Link:
http://board.flashkit.com/board/showthread.php?t=771640

Post By:neznein9
Whenever you use addChild, the object is put on the top of the display list (highest z-index). You can use a couple different methods to manually set the index - also, remember that you have to use an index thats in bounds, you can only set an index to 100 if there are 100 other things on stage.

addChildAt(mc, 0); <= this will add to the back

addChildAt(mc, 10); <= this will add to layer 10 and bump anything already there

setChildIndex(mc, 20); <= this moves mc to index 20, bumping anything else

setChildIndex(mc, this.numChildren - 1); <= bring mc to the top

swapChildren(mc, mc2); <= switches the two

swapChildrenAt(0, 10); <= switches whatever is at 0 with whatever is at 10

1 comment:

  1. Tangent Between Two Circles:
    http://jwilson.coe.uga.edu/emt669/Student.Folders/Kertscher.Jeff/Essay.3/Tangents.html

    ReplyDelete