Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-10 Thread Tyler Wright
:)   uh, a bit of code I've failed to remove.

Taken care of, thanks ... have you used it yet? Is it useful or would there
be any changes I could make to make it more so? I haven't actually had
anyone else use it before so any feedback (good or bad) would be
appreciated.

Tyler

On 3/8/06, eric dolecki [EMAIL PROTECTED] wrote:

 That class imports:

 import xt.core.*;

 which is nowhere to be found in the release :/



 On 3/8/06, Tyler Wright [EMAIL PROTECTED] wrote:
 
  Take a look at the XT DepthManager ( http://codext.com/code/6 ). It
 makes
  messing with depths like this really simple.
 
  Tyler
 
 
  On 3/2/06, Scott Pobiner [EMAIL PROTECTED] wrote:
  
   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:0xDD, fontSize:
   72});
   //_name_lbl = _tools_mc.createClassObject
   (Label,_name_lbl,_tools_mc.getNextHighestDepth(),
   {styleName:myStyle, color:0x33, 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_Partsfile=3458.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 flashcoders@chattyfig.figleaf.com
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 flashcoders@chattyfig.figleaf.com
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

Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-08 Thread eric dolecki
That class imports:

import xt.core.*;

which is nowhere to be found in the release :/



On 3/8/06, Tyler Wright [EMAIL PROTECTED] wrote:

 Take a look at the XT DepthManager ( http://codext.com/code/6 ). It makes
 messing with depths like this really simple.

 Tyler


 On 3/2/06, Scott Pobiner [EMAIL PROTECTED] wrote:
 
  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:0xDD, fontSize:
  72});
  //_name_lbl = _tools_mc.createClassObject
  (Label,_name_lbl,_tools_mc.getNextHighestDepth(),
  {styleName:myStyle, color:0x33, 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_Partsfile=3458.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 flashcoders@chattyfig.figleaf.com
   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 flashcoders@chattyfig.figleaf.com
   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
  
  ___
  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

Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-02 Thread Scott Pobiner

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:0xDD, fontSize: 
72});
		//_name_lbl = _tools_mc.createClassObject 
(Label,_name_lbl,_tools_mc.getNextHighestDepth(), 
{styleName:myStyle, color:0x33, 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_Partsfile=3458.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 flashcoders@chattyfig.figleaf.com
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 flashcoders@chattyfig.figleaf.com
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


___
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


Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Karthik
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


RE: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Grant Davies
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


Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Karthik
On 02/03/06, Grant Davies [EMAIL PROTECTED] wrote:
 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.

Not really - I'm swapping with (the depth of the topmost item + 1).

-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


Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Ramon Miguel M. Tayag
why not mc.swapDepths(getNextHighestDepth() ) ?  Do you have that many
movieclips?


On 3/2/06, Karthik [EMAIL PROTECTED] wrote:

 On 02/03/06, Grant Davies [EMAIL PROTECTED] wrote:
  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.

 Not really - I'm swapping with (the depth of the topmost item + 1).

 -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




--
Ramon Miguel M. Tayag
Managing Director
Quirkworks
___
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


RE: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Grant Davies
Ok so you are doing it with the item just below the top, how does that
put your selected item on the top ?

Grant 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ramon
Miguel M. Tayag
Sent: Thursday, March 02, 2006 12:26 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Z sorting multiple overlapping movie clips

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


On 3/2/06, Karthik [EMAIL PROTECTED] wrote:

 On 02/03/06, Grant Davies [EMAIL PROTECTED] wrote:
  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.

 Not really - I'm swapping with (the depth of the topmost item + 1).

 -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




--
Ramon Miguel M. Tayag
Managing Director
Quirkworks
___
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


RE: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Grant Davies
I thought you could only swap depths with movieclips, get night higest
depths just returns what depth would be the next highest, it doesn't
actually create the depth.

Gran 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ramon
Miguel M. Tayag
Sent: Thursday, March 02, 2006 12:26 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Z sorting multiple overlapping movie clips

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


On 3/2/06, Karthik [EMAIL PROTECTED] wrote:

 On 02/03/06, Grant Davies [EMAIL PROTECTED] wrote:
  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.

 Not really - I'm swapping with (the depth of the topmost item + 1).

 -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




--
Ramon Miguel M. Tayag
Managing Director
Quirkworks
___
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


Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Karthik
 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
___
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


Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-03-01 Thread Ramon Miguel M. Tayag
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
___
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


Re: [Flashcoders] Z sorting multiple overlapping movie clips

2006-02-28 Thread Byron Canfield
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.

This isn't exactly OOP, but it demonstrates the architecture:

var qtyClips:Number = 4;
var nbrDepthOffset:Number = 7;
var rraClips:Array = new Array();
var nbrLastPressed:Number;
//
function fncClipInit() {
for (var i = 0; iqtyClips; i++) {
var nbrDepth:Number = i+nbrDepthOffset;
var rfcClip:MovieClip = createEmptyMovieClip(item+i, 
nbrDepth);
rfcClip.nbrIDX = i;
rfcClip.nbrDepth = nbrDepth;
rraClips[i] = rfcClip;
//
// ---
// This part just so there's something to see...
var rraDim:Array = [[Math.random()*600, Math.random()*300],
[Math.random()*600, Math.random()*300]];
rfcClip.beginFill(Math.floor(Math.random()*0xFF), 100);
rfcClip.lineStyle(2, Math.floor(Math.random()*0xFF), 100);
rfcClip.moveTo(rraDim[0][0], rraDim[0][1]);
rfcClip.lineTo(rraDim[1][0], rraDim[0][1]);
rfcClip.lineTo(rraDim[1][0], rraDim[1][1]);
rfcClip.lineTo(rraDim[0][0], rraDim[1][1]);
rfcClip.lineTo(rraDim[0][0], rraDim[0][1]);
rfcClip.endFill();
// ---
//
rfcClip.onPress = function() {
fncDepthSort(this);
};
}
}
//
function fncDepthSort(rfcBtn:MovieClip) {
if (rfcBtn.nbrIDX != nbrLastPressed) {
var rfcClip:MovieClip = rraClips[rfcBtn.nbrIDX];
rraClips.splice(rfcBtn.nbrIDX, 1);
rfcClip.swapDepths(qtyClips+nbrDepthOffset);
rraClips.push(rfcClip);
for (var i = 0; irraClips.length; i++) {
rraClips[i].swapDepths(i+nbrDepthOffset);
rraClips[i].nbrIDX = i;
}
nbrLastPressed = rfcBtn.nbrIDX;
}
trace(rraClips: +rraClips);
}
//
fncClipInit();
trace(rraClips: +rraClips);



-- 
Byron Barn Canfield


 Does anyone have a an algorithm for Z sorting multiple overlapping
 clips...

 I have an array of clips and when one is clicked I want it to come to
 the top, but I want the other overlapping items to also shift
 appropriately...

 So

 Item [1] at depth 10
 Item [2] at depth 9
 Item [3] at depth 8
 Item [4] at depth 7

 If you click item [4], it would go to depth 10, and the other would
 shift down 1

 Item [4] depth 10
 Item [1] depth 9
 Item [2] depth 8
 Item [3] depth 7

 But if any of those items are overlaping other items, they also need to
 be Z sorted.

 I'd rather not re-invent the wheel.

 Thanks
 Grant
 ___
 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