What does this mean for me? You will always be able to play your favorite games on Kongregate. However, certain site features may suddenly stop working and leave you with a severely degraded experience.
What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security.
We suggest you install the latest version of one of these browsers:
I’m sure there is a simple way to do this but I can’t figure it out.
I have a loop that adds several movieclips at a random x and y position. How can I make it so that after they are all added the movieclips depth will sort so that the higher the y the higher the depth of the object so that the ones at 0y for instance are behind the ones at 10y and the ones at 70y are behind the ones at 100 etc etc?
Depth in AS3 depends on the index of the child relative to the parent. (aka, order that you addChild() em, with the most recent on top).
So you can just sort the objects based on their y values and then swap their indices.
> *Originally posted by **[evan999333](/forums/4/topics/303762?page=1#posts-6439826):***
> Yah so how do I go about that?
> *Originally posted by **[evan999333](/forums/4/topics/303762?page=1#posts-6439874):***
> I know how arrays work NineFiveThree… I do not however understand how to swap objects depths based off their position in an array.
re-addChild them with addChildAt.
Read the manual.
[`setChildIndex`](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#setChildIndex%28%29) is relevant too and probably makes more sense then using `addChildAt`
If you break the problem down into pieces, you’ll see it’s not so daunting.
Here’s some pseudo-code on how you may want to start approaching the problem:
for each child of the current object (hint: numChildren)
add the child to an array (hint: getChildAt)
sort the objects in the array based on their "y" property (hint: read up on sorting methods)
(alternate hint: check the manual page NineFiveThree posted and look up Array's built-in sort method)
for each object in the array
set the index of the object to its new array position (hint: setChildIndex)
Those 3 steps should be nothing scary individually, and the overarching problem will just be a simple matter of connecting it all together.
Thanks BobTheCoolGuy and Khronosis that’s just what I needed – I knew it would be something simple.
What I did is
for (var i=0; i<levelChunkVar.treeArray.length; i++)