ActionScript and Layers

Just wondering, can actionscript manipulate layers?

Examples include:
creating, removing, editing, ect.

If it is possible, I have thought of some major effects using it.

Anyone know how?


About the only thing it can do with layers and actionsript is edit the stacking order of objects using swapDepths(). This doesn’t really manipulate the layer itself, just the object in the layer, you can move it on top of on the bottom, etc.

how exactly does that work? Does flash number them and you refer that way, up/down commands, or do you simply refer to the Layer names that you give them?? Thanks

I’d have said that ActionScript can only manipulate objects on layers, not the layers themselves.

I agree… you cannot refer to a layer at all, or in any way move what is placed in one layer to another layer.

Depth is attributed to EACH layer, and you can manipulate what depth something is at.

here are some examples.

if a movie clip is duplicated, or attached to the root timeline, it will exist in a depth above all the layers.

if a movie clip is duplicated, or attached to the inside of another movie clip, it will have the same effect, but in relation to that timeline’s layers.

if a movie clip is attached to a movie clip that resides on a layer in the main timeline then it will be at a depth above any object which is in that layer, or in any layer below that layer, but not objects from higher up layers.

There is a very good diagram of how it works in Action Script the definitive guide, on page 297

ultim8, you don’t need layers for anything, since you can do everything with AS. If you _root.createEmptyMovieClip(“layer”,5);
there it is: you have a clip layer at depth 5. The only difference with ‘real’ layers is that they have negative depths (starting from -16800 or so).

pom :asian:

I see… I thought you were refering to the actual manipulation of the layer order. Thanks for all the info guys- even though I didnt even start this thread. : )

So, I can change the so called “layer” of an object with actionscript, but it really isnt a layer.

An example of what I am talking about is if a movie clip is behind another movie clip, I can make the behind movie clip “move” in front of the other one?

BINGO, thats what swapDepth does :slight_smile: