No, there is no tag in Flex, but if you do need to dump objects, use the following code (replacing obj with the appropriate object name): mx.utils.ObjectUtil.toString(obj)
Dumping Flex Objects
·
12 Comments
C
Chris Velevitch
Xray and LuminicBox are 2 excellent tools for examining objects.
B
Ben Forta
Please file bug reports on this, with reproducable examples if possible.
J
James Lyon
Shigeru, that can happen when attempting to use ObjectUtil.toString() on complex objects or on some core classes. I haven't tried to find a pattern among the different cases we've seen. Does anyone know if certain methods or class definitions cause that ObjectUtil method to crash?
S
Shigeru
I tried like below
mx.utils.ObjectUtil.toString(event_object)
then InternetExplorer shutdowned...
B
barry.b
and there's nothing like cfdump in ASP.NET either....
...boy have I been spoiled!
J
James Lyon
Bug submitted.
I created a FlexDump component during some free time today. It's really basic, but works, and I'll send it along to whomever wants to test it more.
M
Mike Collins
Another technique I have used is to save the error to a file using cfdocument, then load it with getURL from FlexBuilder.
<cfset reportdir = getdirectoryfrompath(getbasetemplatepath())>
<cfdocument filename="#reportdir#test.swf" format="flashpaper" overwrite="yes" >
<cfoutput>
Incoming parms:<br />
<cfdump var="#form#">
Error occurred at #now()#<br />
<cfdump var="#cfcatch#">
</cfoutput>
</cfdocument>
M
Mike Collins
Here is one I use as well, error is a textarea. Simply send in the object you wish to see expanded. I tried doing this recursively as well, but objects have circular references at times.
You can change this to use trace as well.
function showme(o) {
error.text = error.text + "**************************" + "r";
for (var prop in o) {
error.text = error.text + "prop: " + prop + " value: " + o[prop] + "r";
}
error.text = error.text + "**************************" + "r";
}
J
James Lyon
Here's the FlexDump component:
<?xml version="1.0" encoding="utf-8"?>
<mx:TextArea xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">
<mx:Script>
<![CDATA[
import mx.utils.ObjectUtil;
private var _dump:Object;
private var _dumpString:String = '';
function get dump():String
{
return _dumpString;
}
public function set dump(value:Object):void
{
_dump = value;
setDump(value);
}
private function setDump(newDump:Object):void
{
//trace(newDump);
_dumpString = ObjectUtil.toString(newDump);
//trace(_dumpString);
this.text = _dumpString;
}
]]>
</mx:Script>
</mx:TextArea>
And here's an example app:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" layout="absolute">
<mx:Array id="arr1" >
<mx:Object label="{Math.random()}" />
<mx:Object label="{Math.random()}" />
<mx:Object label="{Math.random()}" />
<mx:Object label="{Math.random()}" />
<mx:Object label="{Math.random()}" />
<mx:Object label="{Math.random()}" />
<mx:Object label="{Math.random()}" />
</mx:Array>
<FlexDump width="100%" height="100%" id="dump1" dump="{arr1}" />
</mx:Application>
J
James Lyon
Shigeru,
Again, the problem is the complex class objects that are being output. Since there will be a target property which will be a class object and also the bubbling 'effect', ObjectUtil.toString() takes much longer than the VM is willing to wait.
S
Shigeru
I may be stupid.
I tried to dump Loder's Complete Event Object.
And the Loder component load SWF.
it must be huge...
it's like below.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" layout="absolute">
<mx:Script>
<![CDATA[
private function loadComponent():void
{
swfLd.source = "./swfComponent01.swf";
}
private function loadCompetedEvent(evt:Event):void
{
txtDump.text = mx.utils.ObjectUtil.toString(evt);
}
]]>
</mx:Script>
<mx:Button x="10" y="10" label="Load" click="loadComponent()"/>
<!-- <mx:Loader id="swfLd" x="10" y="42" complete="loadCompetedEvent(event)" /> -->
<mx:Loader id="swfLd" x="10" y="42" source="./swfComponent01.swf" complete="loadCompetedEvent(event)" />
<mx:TextArea id="txtDump" x="10" y="290" width="610" height="360"/>
</mx:Application>
If Loader load SWF on clicking button, InternetExplorer didn't shutdown and FlashPlayer output runtime error like below.
StackOverflowError: Error #1023: Stack overflow.
at mx.utils::ObjectUtil$/getClassInfo()
...
But Loader load SWF on loading, InternetExplorer shutdowned.
P
Phillip Molaro
AWESOME! This just saved me a ton of time! Thx Ben!