View comments | RSS feed

DepthManager class

ActionScript Class Name mx.managers.DepthManager

The DepthManager class allows you to manage the relative depth assignments of any component or movie clip, including _root. It also lets you manage reserved depths in a special highest-depth clip on _root for system-level services such as the pointer and tooltips.

In general, Depth Manager manages components automatically, using its own "shuffling" algorithm. You do not need to use its APIs unless you are an advanced Flash developer.

NOTE

 

To use the DepthManager class for movie clip instances, you need to have a component in the library or on the Stage, and use "import mx.managers.DepthManager" at the beginning of your ActionScript.

The following methods constitute the relative depth-ordering API:

The following methods constitute the reserved depth space API:

Method summary for the DepthManager class

The following table lists the methods of the DepthManager class.

Method

Description

DepthManager.createChildAtDepth()

Creates a child of the specified symbol at the specified depth.

DepthManager.createClassChildAtDepth()

Creates an object of the specified class at the specified depth.

DepthManager.createClassObjectAtDepth()

Creates an instance of the specified class at a specified depth in the special highest-depth clip.

DepthManager.createObjectAtDepth()

Creates an object at a specified depth in the highest-depth clip.

DepthManager.setDepthAbove()

Sets the depth above the specified instance.

DepthManager.setDepthBelow()

Sets the depth below the specified instance.

DepthManager.setDepthTo()

Sets the depth to the specified instance in the highest-depth clip.

Property summary for the DepthManager class

The following table lists the properties of the DepthManager class. The constant values shown are the default values that the DepthManager algorithm uses to arrange depth. If you trace the following properties, you will see those constant values in the Output panel.

However, after you implement a DepthManager method, such as DepthManager.setDepthTo(), using one of the following properties, and then trace the component or movie clip depth, you see that DepthManager sets the depths in increments of 20. The algorithm increments depths in case Flash needs to insert something else in the middle, based on other scripts, components, and so on.

Property

Description

DepthManager.kBottom

A static property with the constant value 202.

DepthManager.kCursor

A static property with the constant value 101. This is the cursor depth.

DepthManager.kNotopmost

A static property with the constant value 204.

DepthManager.kTooltip

A static property with the constant value 102. This is the tooltip depth.

DepthManager.kTop

A static property with the constant value 201.

DepthManager.kTopmost

A static property with the constant value 203.


Version 8

Comments


No screen name said on Nov 15, 2006 at 8:43 AM :
How does the DepthManager class works? I can't even create a movie clip using it! Please give a sample.
Cpt LoadTest said on Feb 3, 2007 at 8:48 AM :
I have found what I believe to be a bug in the DepthManager; it only shows up when there is a bug in another component. It manifests as Alerts and Windows created through PopUpManager, modal=true, not rendering to the stage.

If a component is added to the stage that does not have a getDepth function (such as if it extends Object rather than MovieClip), the object will have getDepth of undefined. DepthManager's DepthTable will have this undefined entry in it causing getDepthByFlag to always return NaN, and findNextAvailableDepth to always return 0.

Under this scenario, when an Alert or modal window is generated, the popup is created at depth 0, followed by the modal layer also being created at depth 0 overwriting the popup instance. The modal layer will render, but the popup layer is gone.

I realize that components on the stage should inherit from MovieClip, but it would be nice if the DepthManager ensured getDepth != undefined before adding it to the DepthTable.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00003457.html