Yarin
Yarin

Reputation: 183589

Change order of layers in Flash MovieClip with ActionScript?

Is it possible to change the order of layers in a Flash MovieClip timeline using ActionScript 3?

Upvotes: 1

Views: 10293

Answers (1)

djrsargent
djrsargent

Reputation: 394

You cannot change the layer order, but you can change the z-index (stacking order) of a movie clip within a same layer. So you can consolidate all the relevant movie clips into one layer, then change the z index using acrtionscript.

parent.setChildIndex(childObject, i)

Change childObject to the name of the movie clip you want to change the z-index, change i to an integer (the desired z-index value).

If you want to make this happen on a mouse event, put above code inside a function and attach an event listener to a button to invoke this function on a mouse event.

Upvotes: 3

Related Questions