Problem with that is if the item you click on is under other items and it swaps depths with the top item, the top item then appears under things it wasn't. I did it this way first and it looked very weird.
I ended up just writing a depth sorter, each of the objects that are added to the screen dispatch a registration event and the depth sorter adds them to a list and stores a sorted depths list, when an item wants to be on top I figure out where it is in the Z order and then swap it with the item above it and then the next, and next and next until I get to the top, that way the Z order is preserved just like in a windowing system. Cheers, Grant -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Karthik Sent: Wednesday, March 01, 2006 4:27 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Z sorting multiple overlapping movie clips On 01/03/06, Byron Canfield <[EMAIL PROTECTED]> wrote: > You can make it a lot easier by doing some of the prep work for that > architecture in the for loop that you use to first create and assign > depths to those movieclips. It might be a lot simpler to just do something like: // Untested. // Assuming clips are given depths based on ID var highest_depth:Number = clips_array.length; // click handler function click_handler(e:Object):Void { if (e.target.getDepth() != (highest_depth)) { e.target.swapDepths(++highest_depth); } } --- This should be fine for IIRC 2 billion+ clicks, with some caveats for depths greater than 1M.. My 10p, -K _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com