TwelvestoneFlash

Setting an mc's depth


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
Nat
 
2003-01-14

I'm a flash newbie (longtime director prog) and I was wondering if there's an easy way to set the depth of a particular clip so that it always appears on top of other clips. In lingo you can set a sprites z property to control the front to back order.

I have a dynamically generated clip that is duplicated into up to 20 instances and another clip that I want to play on top of all of these. I thought of using swapDepth with hitTest, but I don't think I need to go that in depth.

I suppose I could do a duplicate movie clip with the final one and give it a higher depth, but this means I need a dummy clip offstage to duplicate from right? Or can I duplicate an mc straight from the library? Still getting the hang of all this :confused:

Anyways, what I have so far is here.

The ripples are the instances, duped into levels 1-20, and the fish is what I want on top. It's a work in progress k

swampy
 
2003-01-14

using swapDepths method :

this.swapDepths(9999)

where the number in the brackets is the depth / level

Nat
 
2003-01-14

Wow, easy as that eh? I thought I'd have to swap it with another mc :rolleyes:

Thanks swampy k

jimmyn
 
2003-01-14

_Originally posted by Nat _ **Wow, easy as that eh? I thought I'd have to swap it with another mc :rolleyes:

Thanks swampy k ** well, swapDepths actually does swap depth with another mc so one would go to the front and the other to the back.

using swapDepths(9999) is pretty safe because i can't think of any reason to actually have 10000 mc's on the screen at once. if you did though, the clip at 9999 would swap depths.

Media44
 
2007-08-11

hmm I found this which is exactly what I think I'm looking for but doesn't seem to be working

I have text dynamically appearing at a new depth each time and need a movie clip playing on top....

I have the layers setup with the movie clip on top and then tried: girl_3.swapDepths(9999); on the clip and in the frame and neither did it. when in the frame it seems to be approved by the compiler... in the mc it shows up: "Statement must appear within on/onClipEvent handler"

I just tried: mcDancer.onLoad = function() { mcDancer.swapDepths(9999); }

and that didnt work either (I renamed girl_3 to mcDancer)

Media44
 
2007-08-11

onClipEvent (load) { mcDancer.swapDepths(9999); }

in the clip didnt work either

persist
 
2007-08-11

I don't understand why you're placing this code on the MC itself. It's probably looking for a child of that MC called mcDancer, which I suspect is actually the MC you put the code on.

Also there is no reason to send it an arbitrary depth. You can use

mcDancer.swapDeths(this.getNextHighestDepth());

if you place the code on the timeline which the mcDancer appears on.

As well, since you're taking the time to name it mcDancer you should really be using

dancer_mc so that the code hinting in the editor works at it's fullest potential for you.

arigato
 
2009-05-06

When I use this.getNextHighestDepth() I would have thought that it would actually create a new depth layer, but it doesn't seem to...

Basically, here's the deal - I have 6 layers. When you click a layer's sidenav link, I want it to load above the previous layer so that the previous layer will be visible beneath it (I'm doing some masking).

What I seem to get, though, is that each layer loads on top, but the one underneath doesn't get switched out - so it's as if there's only 2 layers visible.

What I want is this:

You're on layer 1. You click the layer 2 link, it rolls in over layer 1. you click on the layer 6 link, it rolls in over layer 2. You click the layer 3 link, it rolls in over layer 6.

What I'm getting is this:

You're on layer 1. You click the layer 2 link, it rolls in over layer 1. you click on the layer 6 link, it rolls in over layer 1. you click the layer 3 link, it rolls in over layer 1.

BUT sometimes the underlying layer switches, though not in any way that I see the pattern.

code example: on (press) { _root.layer_mc1.swapDepths(this.getNextHighestDepth()); _root.layer_mc1.gotoAndPlay(1);

}

Thoughts?

arigato
 
2009-05-07

The other thing I was thinking was a simple swap with two holders, but the problem is the non-sequential aspect.

Again, thoughts?

JLM
 
2009-05-07

not really following if you want to pm me fla I can take a look.;j

DontBogartMe
 
2009-05-07

Try this:

on (press) { _root.layer_mc1.swapDepths(_root.getNextHighestDepth()); _root.layer_mc1.gotoAndPlay(1); }

dunno though... reading your code is like listening to Chaucer describe an iPhone k

arigato
 
2009-05-07

Hey, I never learned as3, what can I say. You want to have a throwdown in photoshop or illustrator, I'm up to date. k

DontBogartMe
 
2009-05-07

I've got my PS7 ready to rock k

So did it even work?

Storm
 
2009-05-07

I'm not sure I'm completely following either.....but......

In AS2, if you call the swapDepths from the layer that is clicked on, it will move it to the top and not just over the one above it.

this.onPress = function() { this.swapDepths(this._parent.getNextHighestDepth()); }

It's saying, swap MY depth with whatever would be the highest level currently on the parent timeline, so it's kind of a sibling swap in this case because all the children are on the parent timeline.

If yours is only going above Level 1 when you're on Level 1 then its a scope problem. Try referencing the parent timeline for the depth.

arigato
 
2009-05-07

Ah, I see. That would explain it. I suspected something like this was going on. I'll give your suggestion a go & see what ensues!

Arsis
 
2009-05-07

Originally posted by: arigato Hey, I never learned as3, what can I say. You want to have a throwdown in photoshop or illustrator, I'm up to date. k oooohhh... look at Mr Fancy designer man stomping all over our little hidey-hole with his demands for technical support and his chest-puffed drawing challenges.

Admit it, you get the scares whenever you come in here.... we know you do.

arigato
 
2009-05-12

I'm not scared, I just get huffy easy. You know how tetchy designer-types get. k

DontBogartMe
 
2009-05-12

moves pixels in spite

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Setting an mc's depth