Sunday, July 06, 2008    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< Feb 2006 >>
S M T W T F S
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28        

Search

Categories
 • Adobe (63) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (10) [RSS]
 • AIR (108) [RSS]
 • Appearances (112) [RSS]
 • Books (66) [RSS]
 • CFEclipse (14) [RSS]
 • ColdFusion (1105) [RSS]
 • Data Services (6) [RSS]
 • Flash (94) [RSS]
 • Flex (334) [RSS]
 • Jobs (86) [RSS]
 • JRun (12) [RSS]
 • Labs (27) [RSS]
 • LiveCycle (16) [RSS]
 • MAX (145) [RSS]
 • Regular Expressions (12) [RSS]
 • SQL (36) [RSS]
 • Stuff (496) [RSS]
 • Tips (CF Studio) (80) [RSS]
 • Tips (CF) (795) [RSS]
 • Tips (Dreamweaver) (91) [RSS]
 • Tips (Flex Builder) (2) [RSS]
 • Using CF (132) [RSS]
 • Wireless (96) [RSS]

Other BLOGs
 • Ray Camden
 • Tim Buntel
 • Sean Corfield
 • John Dowdell
 • Steven Erat
 • Brandon Purcell
 • Charlie Arehart
 • Full As A Goog

RSS Feeds
 • Feed
 • Subscribe

Join my mailing list and find out about new books and other topics of interest.

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.

Viewing By Day : February 8, 2006 / Main
February 8, 2006

Dumping Flex Objects

No, there is no <cfdump> 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)

TrackBacks
There are no trackbacks for this entry.

No trackback URL. Trackbacks are only allowed via interactive form.

Comments
and there's nothing like cfdump in ASP.NET either....
...boy have I been spoiled!
# Posted By barry.b | 2/8/06 7:57 PM
I tried like below
mx.utils.ObjectUtil.toString(event_object)

then InternetExplorer shutdowned...
# Posted By Shigeru | 2/8/06 8:51 PM
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?
# Posted By James Lyon | 2/8/06 9:35 PM
Please file bug reports on this, with reproducable examples if possible.
# Posted By Ben Forta | 2/8/06 9:39 PM
Xray and LuminicBox are 2 excellent tools for examining objects.
# Posted By Chris Velevitch | 2/8/06 10:28 PM
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.
# Posted By James Lyon | 2/10/06 4:44 PM
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";
      }
# Posted By Mike Collins | 2/12/06 6:06 PM
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>
# Posted By Mike Collins | 2/12/06 6:39 PM
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.
# Posted By Shigeru | 2/13/06 2:37 AM
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.
# Posted By James Lyon | 2/13/06 11:39 AM
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>
# Posted By James Lyon | 2/13/06 11:43 AM
AWESOME! This just saved me a ton of time! Thx Ben!
# Posted By Phillip Molaro | 1/8/08 9:24 AM

  © Copyright 1997-2008 Ben Forta, All Rights Reserved