Hi,
In Flex, each visual component has a unique depth(like z-index). Think of
stack of objects.
So you can have only one object at one depth. That's why you need to specify
a unique depth in order to avoid any conflict, if object is created at
pre-occupied depth, existing object would be removed from there and newly
created would be placed at that depth.
As Manish mentioned in his reply, you can maintain a counter and keep
incrementing. The getNextHighestDepth(..) method does it for you, it finds
out the next available highest depth in a container. In old flash days,
incrementing a counter was the only way :)
You can do something like this:
var depthCount:Number = 0; //assuming there is not any object in container.
function addChildToContainer()
{
objRef = createClassObject(Image, "imgE" + depthCount,
depthCount++);
}
-abdul
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
Sent: Monday, April 25, 2005 7:07 PM
To: [email protected]
Subject: [flexcoders] Re: createClassObject
I have two images and three labels in each cell. Their visibility
is controlled by the data and user display criteria - thus I specify
a name for them.
I noticed that if I did not specify getNextHighestDepth() it
appeared that each time createClassObject was called the prior
object was destroyed and the new one created.
Could someone please provide me an explanation on what
getNextHighestDepth does. My understanding was that this was the z-
order, thus could I just set all the children to be at the same z-
order ? If not, is a simple one up counter sufficent ?
Thanks.
--- In [email protected], Gordon Smith <[EMAIL PROTECTED]> wrote:
> If only a single Image named "imgE" is being created per cell,
then you
> don't have to specify a unique name -- only children of a single
parent have
> to have unique names. However, there is generally no good reason
to ever
> specify a name in createClassObject. If you pass undefined for the
second
> argument, Flex will generate a unique name for you.
>
> - Gordon
>
> -----Original Message-----
> From: [email protected]
[mailto:[EMAIL PROTECTED]
> Sent: Sunday, April 24, 2005 11:26 AM
> To: [email protected]
> Subject: [flexcoders] Re: createClassObject
>
>
>
>
> --- In [email protected], "viraf_bankwalla"
> <[EMAIL PROTECTED]> wrote:
>
> > imgE = createClassObject(Image,"imgE", getNextHighestDepth());
>
> Try avoiding the call to getNextHighestDepth() by maintaining your
own
> counter.
>
> Also, I think the second argument to createClassObject() needs to
be
> unique.
>
>
>
>
>
>
> Yahoo! Groups Links
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/