Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect if movie is loaded into already used depth 2

Status
Not open for further replies.

brownfox

Programmer
Jan 5, 2003
173
GB
I'm designing a game similar to the old Atari "Asteroids". I use _root.createEmptyMovieClip() to load new asteroids into levels when the parent asteroid is hit. The problem is is that there are loads of asteroids flying about (on the fly?) in many different levels and occaisionly new asteroids get loaded into a level thats already being used by another asteroid.
I'm using _root.getNextHighestDepth(); but sometimes this is not working as it should, so, is there a way to detect if a movie clip gets loaded into a depth that's being used?
T.I.A
 
I've found that using the getNextHighestDepth command has a number of problems (I ran into one when using removeMovieClip...this link has something about it ).

Anyway, my solution from now on when dynamically creating stuff or attaching movieclips is to set a variable, in this case 'tempDepth = 1' and wherever I use it, immediately after that bit of code I use tempDepth++ to ensure the same depth isn't used. So for example, when creating text fields, I would use:

Code:
_root.createTextField("txtTextField",tempDepth,tempX,tempY,tempW,tempH); [b]tempDepth++[/b];

This seems to get round the problem with depths, or at least those I've encountered!
 
Thanks Guys. getInstanceAtDepth() is exactly what I was after!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top