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
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 
Nat 2003.01.14, 02:10PM — Setting an mc's depth
swampy 2003.01.14, 02:18PM —
using swapDepths method :
this.swapDepths(9999)
where the number in the brackets is the depth / level
Nat 2003.01.14, 02:43PM —
Wow, easy as that eh? I thought I'd have to swap it with another mc
Thanks swampy 
jimmyn 2003.01.14, 03:13PM —
Originally posted by Natwell, swapDepths actually does swap depth with another mc so one would go to the front and the other to the back.
Wow, easy as that eh? I thought I'd have to swap it with another mc![]()
Thanks swampy![]()
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, 02:47PM —
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, 02:56PM —
onClipEvent (load) {
mcDancer.swapDepths(9999);
}
in the clip didnt work either
persist 2007.08.11, 03:12PM —
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, 08:01PM —
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, 03:33AM —
The other thing I was thinking was a simple swap with two holders, but the problem is the non-sequential aspect.
Again, thoughts?
DontBogartMe 2009.05.07, 10:03AM —
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
arigato 2009.05.07, 12:31PM —
Hey, I never learned as3, what can I say. You want to have a throwdown in photoshop or illustrator, I'm up to date.
Storm 2009.05.07, 02:28PM —
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, 02:34PM —
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, 11:20PM —
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.
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, 01:39PM —
I'm not scared, I just get huffy easy.
You know how tetchy designer-types get.