- Posted
- Aug 1st 2009
- Mood
To explain the problem in it's most simplest way, here's an example:
On the stage there are three layers, each with one movieClip, example:
Layer 3 = Contains an MC with the instance name: "npc3"
Layer 2 = Contains an MC with the instance name: "npc2"
Layer 1 = Contains an MC with the instance name: "npc1"
Each have their own :"onClipEvent(enterFrame)" which includes this:
"this.swapDepths(this._y);"
This code causes objects which are higher on the stage to be placed behind those underneath them.
So far so good.
Here's the problem:
Once I load the flash game, their depths are strangely arranged, meaning MC's which are supposed to be ontop of another, are located behind them, - a total mess.
Everything works fine the moment after their position changes either through AI control or player control, which is nothing more than adding or subtracting to their own "._y" or "._x" speeds.
Question:
Is there a way for "this.swapDepths(this._y);" to instantly be called the moment the movie clips are loaded onto the stage - so that all MCs are properly behind/infront one another to create a sense of depth - depending on their current _y position?
I have "this.swapDepths(this._y);" under "onClipEvent(enterFrame)" as well as "onClipEvent(load)" and it only seems to work the moment an object moves - and NOT the instant they are loaded onto the stage.
ALSO:
Say, two MovieClips are near each other, both of them start to flicker madly, with each MC swapping their depths like crazy. Perhaps "this.swapDepths(this._y);" is to blame, while on EnterFrame? Is there a way to correct this?
Any help would be immensely grateful. Thanks in advance!
NJB Says:
sorry man, the only thing I can thing of would be to have a few "set" depths (e.g. for y values 120->150 make the depth 4, for 151->180 make it 5 etc)
also, maybe the kirupa article might be able to help:
http://www.kirupa.com/developer/actionscript/swapdepth.htm