I ran into the same problems a while back. I created a LevelsManager class
to get around it which you can set to "hijack" the getNextHighestDepth()
function. That way, you can run one line of code at the beginning of your
application and all your getNextHighestDepth() calls will work regardless of
whether or not there are components on the stage. You can download the small
class file at http://www.greensock.com/ActionScript/LevelsManager.zip. Here
is the primary function I used in that class:
function getNextHighestDepth(mc:Object):Number {
if (mc == undefined) {mc = this};
var maxDepth_num:Number = mc.getNextHighestDepth();
if (maxDepth_num != undefined && maxDepth_num < 16000) {
return maxDepth_num;
} else {
maxDepth_num = -1;
var depth_num:Number;
var obj:Object;
var tf = TextField.prototype;
for (var p in mc) {
obj = mc[p];
if ((typeof(obj) == "movieclip" || obj.__proto__ ==
tf) && obj._parent == mc) {
depth_num = obj.getDepth();
if (depth_num > maxDepth_num && depth_num <
16000) {
maxDepth_num = depth_num;
}
}
}
return maxDepth_num + 1;
}
}
Jack
-----Original Message-----
Date: Tue, 7 Aug 2007 17:15:55 +0800
From: "Darren Bowers" <[EMAIL PROTECTED]>
Subject: [Flashcoders] Depth issues...
To: "Flashcoders mailing list" <[email protected]>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1
I have written a class that simply creates movieclips (grids) on screen. It
draws everything from actionscript so no library items are required.
However, I am passing this class on to developers that will use it as they
see fit. The problem is with the depth management. It seems I am stuck with
forcing the developers not to use any components, otherwise the depth
management is all stuffed up.
If I use getNextHighestDepth(), I can create and destroy movieclips freely
which is fine. Until someone uses a v2 component (like a button), then it
breaks. They will create, but wont destroy because they get an invalid depth
at creation.
If I decide to use the DepthManager class, I have to have at least one v2
component in the library for it to work. The reason i created the class in
the first place was to keep things small and libraryless if i wanted to.
its seems I'm damned if i do and i'm damned if i dont.
Is there any way to detect for components and use the DepthManager class
instead of getNextHighestDepth()?
cheers,
Darren
_______________________________________________
[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