I think I am getting a little closer:
public function sortDepths():void{
var a:Array = new Array();
for(var i:int; i<numChildren; i++){
a.push(this.getChildAt(i));
}
a.sortOn("y", Array.NUMERIC);
i = a.length;
while(i--){
if (getChildAt(i) != a[i]) {
setChildIndex(a[i], i);
}
}
}
Can anybody think of a way to optimize this so there is only one loop?
--- In [email protected], "Ralf Bokelberg"
<[EMAIL PROTECTED]> wrote:
>
> I think, you have to create your own depth property and keep the
displaylist
> sorted by this property.
> So, instead of swapping the depth, you need to find the place in the
> displaylist, where a object with a certain depth has to be inserted.
>
> Cheers,
> Ralf.
>
> On 8/1/06, John Chipps-Harding <[EMAIL PROTECTED]> wrote:
> >
> > Hi:
> >
> > I have just started using Flex Builder 2 and am finding authoring
> > Actionscript 3.0 projects a dream.
> >
> > I am having issues getting my head round the new way of managing
depths.
> > Specifically in an isometric game I am porting to AS3. Here is a
snippet of
> > code that shifts a sprite to a specific depth:
> >
> > _sprite.swapDepths( int(newX + (newY * 900)) );
> >
> > The important thing here is that I am swapping to a SPECIFIC
depth... so
> > when other movieclips redraw and swap depth they are placed in the
correct
> > depth relative to the others.
> >
> > This is very loose (you could have movieclips at depth 100,000
easily) but
> > is worked fine in AS2.
> >
> > Has anybody got any ideas on how to approach this in AS3? If you
think my
> > question is too vague let me know and ill try to elaborate more.
> >
> > Regards:
> >
> >
> > John
> >
>
>
>
> --
> Ralf Bokelberg <[EMAIL PROTECTED]>
> Flex & Flash Consultant based in Cologne/Germany
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/