swap depths flash
- Started
- Last post
- 16 Responses
- snizl
I am having problems with swapping depths in my flash movie. I am populating a map by attaching mc's. I am applying the actions to the variable name, when looping, such as masterHouse.onRollOver = function() { }
masterHouse being the var name. Basically what I need to do is everytime masterHouse is rolled over I need to bring it to the front. I've tried just about every combination I could think of. but bascially I need:
masterHouse.onRollOver = function() {
masterHouse.swapDepths(masterHou... );
}Any help is appreciated.
- fate_0
Easiest thing to do, is everytime you rollover an MC, you first ++ a variable (add 1) and then swapDepths to the value of the variable. That way, no matter what, that swapDepths value is going to be the highest it can be, since it was just increased.
- snizl0
So would I initially set a variable to a number, then recall that variable + 1??
- snizl0
I think part of the problem I might be having is when I reference the masterHouse variable in the onRollOver function do I refer to masterHouse as 'masterHouse' or 'this'?
- unfittoprint0
I prefer adding a var to each mc using the getDepth method.
http://livedocs.macromedia.com/f…Then saving the highest available depth on another Stage's var.
Then is just a question of using the last var for the 'active mode' and the saved original depth for the 'inactive mode': that way the inactive mc can get back to its original stack.
- snizl0
I'm starting to undertsand the basic concepts of swapDepths and getDepth. But am still having problems.
When I setting up the on masterHouse.rollOver action do I reference masterHouse as 'this' or 'masteHhouse' since its a variable?
- unfittoprint0
I see.
myMc.onRollOver = function(){
this.swapDepths(this._parent.oth...
}
should work.
- Mick0
If you do this.swapDepths(5000) on the MCs you're mousing over with each rollover it should bring it to that level (or swap it if the last one was at 5000). Don't have to mess with all the other movieclip depths this way.
5000 should ve a value that is above existing MCs depths and unused.
MC Depths are also dependent on the timeline they're on, so when I'm getting into complicated depth stuff, I place all dynamically generated MCs in one MC so there are no depth issues with anything else.
- snizl0
Fusion Pixel: Already looked through that. While it worked fine for specifically declared Instance names. I need the instance names to be dynamic hence the variable.
Unfit:
If I set it up like you said, what do i set otherMC to if I have, masterName as the variable :masterHome.onRollOver = function(){
this.swapDepths(this ._parent.otherMC);
- dijitaq0
this.onRollOver = function() {
this.swapDepths(this._parent.get...
};this will always make the mc swap depths with the highest depth. so it will always be on top
- snizl0
Trust me, I tried that already, didn't work.
- unfittoprint0
dijitaq's right.
this._parent.getNextHigh estDepth() should also work.
- dijitaq0
make a instane called box and try this
for (z=0; z
- dijitaq0
damn they cut the code
- snizl0
Oi, I tried that and it did not work.
This is the output I get when i put a trace before and after the swap depth command and moused over the same button when adding 10 to the next highest depth:3
3
3
3
3
38
- dijitaq0
snizl i sent you an email with a script.