Changing Depth Shape order dynamically:
When you create your design normally, always 1 shape will be on top of the other.
But you could change this using actionscripts.
Swap Depths Sample: (Click and Drag the shape below to view demo)
you will noticed that the one you click will be always on top of the others.
This is the structure of the design.
The main function used to accomplish this is swapDepths(stackOrder)
The higher the stackOrder is, the higher up the window movie clip will be placed.
We have 3 sprites and everyone has same script:
onSelfEvent (press) { _root.SWC +=1; this.swapdepths(_root.SWC); startDragUnlocked(); } onSelfEvent (release,dragOut) { startDragUnlocked(); stopDrag(); }
|
_root.SWC+=1 to increase the value of SWC to keep the shape we click on the hight stack order. we need to initialize the value of SWC when our movie load.
the starDragUnlocked() an stopDrag() was explained here Drag Object with Mouse
This concept is useful for flip in/out image or menu, very easy to implement in any application.