The following example shows how you can debug your Flex applications using the describeType() method (in the flash.utils package), as well as the static ObjectUtil.toString() method to display information about objects in Flex.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="traceObj(progressBar);">
<mx:Script>
<![CDATA[
import mx.utils.ObjectUtil;
private function traceObj(target:Object):void {
textArea1.text = ObjectUtil.toString(target);
textArea2.text = describeType(target).toXMLString();
}
]]>
</mx:Script>
<mx:Form width="100%" height="100%">
<mx:FormItem label="target:">
<mx:ProgressBar id="progressBar"
labelPlacement="center"
indeterminate="true" />
</mx:FormItem>
<mx:FormItem label="ObjectUtil.toString(...):"
width="100%"
height="50%">
<mx:TextArea id="textArea1"
editable="false"
width="100%"
height="100%" />
</mx:FormItem>
<mx:FormItem label="describeType.toXMLString(...):"
width="100%"
height="50%">
<mx:TextArea id="textArea2"
editable="false"
width="100%"
height="100%" />
</mx:FormItem>
</mx:Form>
</mx:Application>
View source is enabled in the following example.
There was an enhancement to the ObjectUtil class in Flex 3 (SDK build 187815 or later), where you can now use the ObjectUtil.toString() method on all display objects without getting a run time error.




Hi Peter rconceiver here again :)
I tried the above code but it gives error on Flex 2 ad Flex 3 as well the error is
“1061: Call to a possibly undefined method toString through a reference with static type Class.”
Is there any way to see the structure of “Array of Object”
i.e. var myArr:Array = new Array()
for(var i:Number=0; i
rconceiver,
Odd, I got a different error in Flex 2 (”Error: Error #2099: The loading object is not sufficiently loaded to provide this information.”).
But this worked for me in Flex 3 (Version 3.0 build 191831).
Peter
Thanks Peterd,
I tried that in Flex 3. Its working fone with data object the moment you add DisplayList reference in the object it doesn’t work.
here is the link for more information.
http://bugs.adobe.com/jira/browse/SDK-13419
I still don’t understand how to solve this issue.. :(
Ah yes, I filed that bug. :)
The bug was fixed in Flex 3 beta. What version of the SDK are you using? (Try typing “mxmlc -version” in your Flex SDK’s /bin/ directory.)
Peter
Thanks Peterd,
I have updated flex sdk. the issue is no more there. I can see the structure of Object Array now. Thanks for that. :) I could see the try catch in file.
But can we see some specific properties of DisplayList Object.?
rconceiver