PDA

View Full Version : swapdepths question


mobzilla
07-26-2004, 08:00 PM
I've seen a few posts about swapdepths, but I still can't seem to get it to do anything. I've got two buttons, one is at a lower depth than the other. When the first button is clicked, I want to disable it and lower the depth, and also enable the lower button and raise the depth. The enable / disable thing is working fine, but I can't seem to get it to change depths.

_root.LockTiles._alpha = 100;
_root.LockTiles.enabled = true;
_root.SelectTile.enabled = false;
_root.SelectTile._alpha = 1;
_root.SelectTile.swapDepths(25);


fmx2004, the above code is linked to the on(press) of the SelectTile button.

SavageGurl
07-26-2004, 11:57 PM
You can code it to swap depths specifically with another MC...as long as the have the same _parent of course.

for ex: _root.SelectTile.swapDepths(_root.LockTiles);

another way : _root.SelectTile.swapDepths(this.getNextHighestDep th)

cobo
07-28-2004, 10:10 AM
or you create a _root variable with a specific value.
everytime a button is pressed at first the value is incremented then the swapDepths is set to the specific value.
the result will be that the pressed button is always in front of the others...

cobo

ajl
07-31-2004, 11:26 PM
I would like to second some problems with buttons and swapdepths. My little movie has three balls, each with a message that pops up when a ball is rolled over. I want the message to appear above all other balls. I made the balls into symbols, and then the symbols into buttons. I put a swapdepths command as well as a trace command for each button on an empty frame, so each ball had code like this:

redball.onRollOver = function() {
redball.swapDepths(100);
trace("I was rolled over!");
}

The trace works when I roll over each ball, but the depth-swapping doesn't. (Here's a link to this try: http://www.wfu.edu/~lausaj1/balls.swf)

When I made all of the symbols movie clips, the swapdepths worked, but unfortunately amidst a quick looping of each symbol through its up/over/down/hit states so that all the messages keep flashing (over/down is where I created the messages). (A link to the movie clip try: http://www.wfu.edu/~lausaj1/balls_mc.swf)

So I'm looking for a solution down either road -- getting the swapdepths to work with buttons or getting the movieclips to not play each state repeatedly. Does anyone have any ideas of how to fix this?

tg
08-01-2004, 05:37 AM
there is also an excellent swapdepths tutorial on this site, even tho it was written for flash5 (or mx), the same concept should work for mx2004.

ajl
08-01-2004, 09:12 PM
Well, I still wasn't able to get the swapdepths to work for buttons with me, but I was able to solve my problem. Thanks for the help though!

beau
08-13-2004, 09:56 PM
it helps if you post your final solution so I could learn how you figured it out. just a fyi/help!

mobzilla
08-16-2004, 10:57 PM
yes, I would like to hear your solution too. thanks.

mobzilla
08-30-2004, 11:21 PM
I finally figured out what my problem was! Nobody's responses were working for me, and then I read that swapDepths only worked for mc's and not for buttons. I switched my button to a MC and everything works! Thanks for all the help, once I figured out my problem I had all the correct code right here!