00:00
00:00
Newgrounds Background Image Theme

AVKid4 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS - swapDepths();

3,913 Views | 4 Replies
New Topic Respond to this Topic

AS - swapDepths(); 2005-03-16 21:33:19


hello there, I am making a game and have a problem. I am using
this.swapDepths(_y);
so my character's depth is always changing and he will correctly be displayed in front or behind objects that will have the same code.
The problem is that any object that has the swapDepth code is duplicated when returning to a previous frame that it was on. Im not sure how to explain it exactly so look at the swf. rightclick and press forward, then rightclick and press back.
http://img190.exs.cx/my.php?loc=img190&image=knight21jm.swf

It seems that whenever it goes to a new frame, it leaves a duplicate of the MC in the previous frame because of swapDepths, does anyone know a way around this?
thanks for your help, if any.


BBS Signature

Response to AS - swapDepths(); 2005-03-16 21:44:18


ah nevermind, figured it out. Apparently flash has problems setting depths within the same movieclip. this.swapDepths(sfdf) is no good because your changing the movieclip's depth from within itself, what works nicely is to put this somewhere else and just put
MC.swapDepths(sfdf);


BBS Signature

Response to AS - swapDepths(); 2005-03-16 22:04:37


damnit, my bad, that wasnt it. It actually didnt work that way either. Any help anyone?


BBS Signature

Response to AS - swapDepths(); 2005-03-16 23:07:01


When you go back, the character gets re-created at the originating level while the previous doesn't get whiped out. Try putting a removeMovieClip(); before creating the character to remove any previous instances


BBS Signature

Response to AS - swapDepths(); 2005-03-17 12:35:46


good idea, i removed the characters instance name and put this on the load cliphandler

_root.guy1.removeMovieClip();
_name="guy1";

it works but it deleted the current person and leaves the duplicated one, so each time you go back a frame the person will be standing in the default position. But that can be easily fixed with alittle extra code. thanks for the help.


BBS Signature