Karthik, Ramon, and all...

When doing complex z-sorting ESPECIALLY when using V2 components, you should use the DepthManager class. it makes life much easier. Essentially the DepthManager provides you with functionality for rearranging depths without explicitly stating the depth numbers... HOW you ask?! Well it just so happens that DepthManager comes complete with a nifty, handy, dandy set of constants (i.e. DepthManager.kTop) These constants place your chosen MC on a single level and consequently shifts all of the prior classes (up or down depending on the constant used). BUT THAT'S NOT ALL!! You also get free sorting algorithms for moving groups of MC's and components ABSOLUTELY FREE!

The thing to keep in mind is that you can't use traditional "attachMovie" calls to move things to the stage dynamically, nor can you use items already on the stage with DepthManager. The reason is because the DepthManager needs to know what it is sorting at loadtime.

Here is a snippet example from one of my apps...


/******CODE HERE******/
import mx.managers.DepthManager;
/*clipped for brevity*/
                // Create a container movie clip.
                _tools_mc = target.createChildAtDepth("_tools_mc", 
DepthManager.kTop);
                //
                //create a name label for this users screen
                
_name_lbl = target.createClassChildAtDepth(Label, DepthManager.kBottom, {styleName:"myStyle", color:0xDDDDDD, fontSize: 72}); //_name_lbl = _tools_mc.createClassObject (Label,"_name_lbl",_tools_mc.getNextHighestDepth(), {styleName:"myStyle", color:0x333333, fontSize:72});
                _name_lbl.autoSize = "left";
                _name_lbl.text = " ";
                _name_lbl.move(55,30);
                //
                //create _menuBar to show and hide color _dropDown
_menuBar = _tools_mc.createClassChildAtDepth(MenuBar, DepthManager.kTop);
                _menuBar.setSize(Stage.width,_menuBar.height);
/******CODE HERE******/

Now to move these guys around all I have to do is call the depth modifiers to change things around...

        # DepthManager.setDepthAbove()
        # DepthManager.setDepthBelow()
        # DepthManager.setDepthTo()

see the documentation for more info... http://livedocs.macromedia.com/ flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm? context=LiveDocs_Parts&file=00003458.html

Also, see this chattyfig thread... http://chattyfig.figleaf.com/ pipermail/flashcoders/2004-May/111796.html

More info on managers from macromedia... http://www.macromedia.com/ devnet/flash/articles/component_architecture_06.html


Hope this helps..

S

------------------------------

Message: 4
Date: Thu, 2 Mar 2006 11:46:23 +0530
From: Karthik <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] Z sorting multiple overlapping movie clips
To: "Flashcoders mailing list" <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

why not mc.swapDepths(getNextHighestDepth() ) ? Do you have that many
movieclips?

That's what I'm doing.. but without getNextHighestDepth which is (was)
buggy when used with v2 components.

-K


------------------------------

Message: 5
Date: Thu, 2 Mar 2006 14:56:46 +0800
From: "Ramon Miguel M. Tayag" <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] Z sorting multiple overlapping movie clips
To: "Flashcoders mailing list" <[email protected]>
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

mc.swapDepths(getNextHighestDepth() ) works with me. It puts it above the rest.

"Parameters

target:Object - This parameter can take one of  two forms:
- A Number that specifies the depth level where the movie clip is to
be  placed.
- A String that specifies the movie clip instance whose depth is
swapped with  the movie clip for which the method is being applied.
Both movie clips must have  the same parent movie clip."

--
Ramon Miguel M. Tayag
Managing Director
Quirkworks

_______________________________________________
[email protected]
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

Reply via email to