And you can use trace() in combination with mx.utils.ObjectUtil.toString()
which will display the object tree structure in the console

trace(ObjectUtil.toString(myCanvas.getChildren()));

http://livedocs.adobe.com/flex/201/langref/mx/utils/ObjectUtil.html#toString()

regards,
Muzak

----- Original Message ----- 
From: "Gordon Smith" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, September 05, 2007 8:35 AM
Subject: RE: [flexcoders] getChildren() ... what's in it?


Trace output appears in the Console pane. To see trace output, you need
to Debug rather than Run you app. If you trace an Array, each element of
the Array will be converted to a String (using its toString() method)
and the resulting strings will be output with a comma between each one.

As the docs for getChildren() state, it "returns an Array of
DisplayObject objects consisting of the content children of the
container." Each child in the Array has properties like id, title, x, y,
width, height, etc. So you could write code like

var children:Array = getChildren();
var n:int = children.length;
for (var i:int = 0; i < n; i++)
{
    var child:DisplayObject = DisplayObject(children[i]);
    trace(child.x, child.y, child.width, child.height);
}

If you simply do trace(getChildren()), you will see a comma-separated
list of unique strings produced by the toString() method that is
inherited from FlexSprite; each unique string is produced from the
'name' properties of the child and its ancestors.

You can also simply use numChildren and getChildAt() to enumerate the
children:

var n:int = numChildren;
for (var i:int = 0; i < n; i++)
{
    var child:DisplayObject = getChildAt(i);
    trace(child.x, child.y, child.width, child.height);
}

- Gordon


________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of nasawebguy
Sent: Tuesday, September 04, 2007 8:12 PM
To: [email protected]
Subject: [flexcoders] getChildren() ... what's in it?




I'm trying to save the Panel children of a Canvas to the database.

Docs say myCanvas.getChildren() creates an array.

How can I output the contents of getChildren() to an Alert or
something? Just to confirm what data is in it?

I need to know if the getChildren() will give me back the properties
of each child panel: id, title, x, y, width, height, etc. Couldn't
find any examples of what it actually stores in the array.

Secondly, I've not used trace() yet. Can you dump getChildren() to a
trace to see what is in it? Where in Flex Builder 2 do I see the
output of a trace?

Thanks,
Don






Reply via email to