Hidden component goodness: ObjectDumper

Get better results with the ObjectDumper! Try this out.

1. Add the DataBindingClasses to your Library (find it in the Classes common library).
2. Add the following ActionScript code to Frame 1 of the Timeline:

import mx.data.binding.ObjectDumper;
var my_dp:Array = new Array({name:’Grissom, M.’, avg:0.279}, {name:’Bonds, B.’, avg:0.362}, {name:’Cruz, D.’, avg:0.292}, {name:’Snow, J.’, avg:0.327});
trace(my_dp);

3. Test the SWF. Your output should be:

[object Object],[object Object],[object Object],[object Object]

Not very helpful.

4. Comment out this: trace(my_dp);

5. Now add the following line to the end of your code:

trace(ObjectDumper.toString(my_dp));

6. Test the SWF again, and marvel at the improved results:
[{avg: 0.279, name: “Grissom, M.”},
{avg: 0.362, name: “Bonds, B.”},
{avg: 0.292, name: “Cruz, D.”},
{avg: 0.327, name: “Snow, J.”}]

23 Responses to Hidden component goodness: ObjectDumper

  1. mikey says:

    that’s hot

  2. Brandon says:

    Nice!! very helpful Jen. Keep’em coming. 🙂

  3. Pablo says:

    Awesome :)This class will make flash debugging a little easier.I think it also comes with the Remoting Classes for AS 2.0

  4. he says:

    There are additional parameters you can provide:ObjectDumper.toString(obj, showFunctions, showUndefined, showXMLstructures, maxLineLength, indent)

  5. John Olson says:

    Completely awesome.

  6. solomon71 says:

    Very useful information. Thanks!

  7. iam says:

    very nice

  8. Really nice!!very useful in debugging application. I was using this till now my own.

  9. Really nice!!very useful in debugging application. I was using this till now my own.

  10. Anonymous says:

    Very useful, although adding the DataBinding classes add 18k to the swf. -A bit heavy. Is there anyway to get just the ObjectDumper class without adding all the DataBinding classes?

  11. matt wallace says:

    Very useful, although adding the DataBinding classes add 18k to the swf. -A bit heavy. Is there anyway to get just the ObjectDumper class without adding all the DataBinding classes?

  12. solomon71 says:

    I didn’t add the DataBindingClasses to my Library and it worked.

  13. ric landers says:

    Hi, Jen, Love your work.I want to design a vid-news site like this:http://tinyurl.com/48xzybut am unclear if it’s necessary to learn Dreamweaver or if I can do it with Flash MX alone.Suggestions …?

  14. ric landers says:

    Hi, Jen, Love your work.I want to design a vid-news site like this:http://tinyurl.com/48xzybut am unclear if it’s necessary to learn Dreamweaver or if I can do it with Flash MX alone.Suggestions …?

  15. jdehaan says:

    Hey ric,If you want to design the video news site (the brown area within the Washington Post HTML site), that appears to be done using Flash. You shouldn’t need to learn Dreamweaver/HTML (etc) to do that part.If you need the higher-end video compression capabilities and video controller components, then you’d need the Flash Professional 2004 version. (However, you don’t need Professional to complete a similar site).Hope that helps a little!Jen.

  16. peter says:

    There’s also another useful utility in the same class, ObjectDumper.replaceAll(), which does what the name implies, replaces all instances of a string with a replacement string.Before you can use this, you need to make sure you have an instance of the ObjectDumper class in your library, so drag a copy of the DataBindingClasses or UtilsClasses from the “Common Libraries > Classes” into the current document’s library.[ActionScript]var res:String = mx.data.binding.ObjectDumper.replaceAll(“Several components, such as the Accordion, ComboBox, and Tree components, provide animation to demonstrate the transition between component states.”, “e”, “3”);trace(res);/* S3v3ral compon3nts, such as th3 Accordion, ComboBox, and Tr33 compon3nts, provid3 animation to d3monstrat3 th3 transition b3tw33n compon3nt stat3s. */[/ActionScript]

  17. peter says:

    And on that note, here’s another tip. Excluding classes from being included in a SWF file.Say that you want to use the ObjectDumper class, but don’t need the other classes in the Compiled Clip. Well, by default the DataBindingClasses and UtilsClasses can add up to 18-20KB to your SWF file. If you’re already doing data binding, these classes will be added automatically but have a much smaller file size impact on your SWF.If you want to exclude the other classes in the clip, you can use the following XML file, which needs to be named after your FLA file. For example, if you had a Flash document named objdumper.fla, create a new XML file named objdumper_exclude.xml and save it to the same directory as the FLA. Add the following text to the XML file:<?xml version=”1.0″ encoding=”iso-8859-1″ ?><excludeAssets><asset name=”mx.data.binding.Binding” /><asset name=”mx.data.binding.ComponentMixins” /><asset name=”mx.data.binding.DataAccessor” /><asset name=”mx.data.binding.DataType” /><asset name=”mx.data.binding.EndPoint” /><asset name=”mx.data.binding.FieldAccessor” /><asset name=”mx.data.binding.Formatter” /><asset name=”mx.data.binding.Log” /><asset name=”mx.data.binding.TypedValue” /><asset name=”mx.data.kinds.Data” /><asset name=”mx.events.EventDispatcher” /><asset name=”mx.utils.ClassFinder” /><asset name=”mx.utils.Collection” /><asset name=”mx.utils.CollectionImpl” /><asset name=”mx.utils.ErrorStrings” /><asset name=”mx.utils.Iterator” /><asset name=”mx.utils.IteratorImpl” /><asset name=”mx.utils.ObjectCopy” /><asset name=”mx.utils.StringFormatter” /><asset name=”mx.utils.StringTokenParser” /><asset name=”mx.utils.Utils” /><asset name=”mx.utils.XMLString” /><asset name=”mx.xpath.FilterExpr” /><asset name=”mx.xpath.FilterStack” /><asset name=”mx.xpath.NodePathInfo” /><asset name=”mx.xpath.XPathAPI” /></excludeAssets>Save your XML and FLA and republish the SWF file. Now instead of the SWF being about 18kb, it should shrink down to about 2kb.

  18. albert says:

    do you happen to have the list of all the classes in the mx.services package? i want to have an exclude file for the service classes – but i think the package has more hidden classes than the Log, SoapCall, WebService, and PendingCall.

  19. peter says:

    albert,Try this:mx.services.ArrayProxymx.services.DataTypemx.services.ElementDeclmx.services.Logmx.services.Namespacemx.services.PendingCallmx.services.PrefixedQNamemx.services.QNamemx.services.RowSetProxymx.services.Schemamx.services.SchemaContextmx.services.SchemaVersionmx.services.SOAPCallmx.services.SOAPConstantsmx.services.SOAPFaultmx.services.SOAPHeadermx.services.SOAPParametermx.services.WebServicemx.services.WebServiceProxymx.services.WSDLmx.services.WSDLConstantsmx.services.WSDLDocumentmx.services.WSDLOperationNot sure if there are others, but thats what I found.

  20. jim says:

    http://printrmx.sourceforge.net/^^ much, much, much more scalable – but of course not included in stock Flash IDE. It’s a copy of the print_r() functionality some might recognize in PHP. It is “greatness” for debugging!

  21. KJ says:

    This is very useful 🙂 I have one question though… how would you access the individual elements from within the Object?

  22. orgicus says:

    Really nice stuff.Sweeeet.