« [OT] Playstation PSP | Main | Macromedia MAX 2005 in Anaheim »
April 06, 2005
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."}]
Posted by jdehaan at April 6, 2005 12:22 PM
Comments
that's hot
Posted by: mikey at April 6, 2005 12:45 PM
Nice!! very helpful Jen. Keep'em coming. :)
Posted by: Brandon at April 6, 2005 01:26 PM
Awesome :)
This class will make flash debugging a little easier.
I think it also comes with the Remoting Classes for AS 2.0
Posted by: Pablo at April 6, 2005 02:04 PM
There are additional parameters you can provide:
ObjectDumper.toString(obj, showFunctions, showUndefined, showXMLstructures, maxLineLength, indent)
Posted by: he at April 6, 2005 02:58 PM
Completely awesome.
Posted by: John Olson at April 6, 2005 07:26 PM
Very useful information. Thanks!
Posted by: solomon71 at April 6, 2005 09:21 PM
very nice
Posted by: iam at April 7, 2005 02:01 AM
Really nice!!
very useful in debugging application. I was using this till now my own.
Posted by: Ashvin Savani at April 7, 2005 03:15 AM
Really nice!!
very useful in debugging application. I was using this till now my own.
Posted by: Ashvin Savani at April 7, 2005 03:17 AM
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?
Posted by: Anonymous at April 7, 2005 08:59 AM
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?
Posted by: matt wallace at April 7, 2005 09:00 AM
I didn't add the DataBindingClasses to my Library and it worked.
Posted by: solomon71 at April 7, 2005 11:02 AM
Posted by: Mirko at April 11, 2005 04:02 AM
Hi, Jen, Love your work.
I want to design a vid-news site like this:
http://tinyurl.com/48xzy
but am unclear if it's necessary to learn Dreamweaver or if I can do it with Flash MX alone.
Suggestions ...?
Posted by: ric landers at April 11, 2005 08:14 AM
Hi, Jen, Love your work.
I want to design a vid-news site like this:
http://tinyurl.com/48xzy
but am unclear if it's necessary to learn Dreamweaver or if I can do it with Flash MX alone.
Suggestions ...?
Posted by: ric landers at April 11, 2005 08:14 AM
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.
Posted by: jdehaan at April 11, 2005 04:59 PM
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]
Posted by: peter at May 24, 2005 11:31 AM
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.
Posted by: peter at May 24, 2005 11:41 AM
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.
Posted by: albert at July 22, 2005 09:59 AM
albert,
Try this:
mx.services.ArrayProxy
mx.services.DataType
mx.services.ElementDecl
mx.services.Log
mx.services.Namespace
mx.services.PendingCall
mx.services.PrefixedQName
mx.services.QName
mx.services.RowSetProxy
mx.services.Schema
mx.services.SchemaContext
mx.services.SchemaVersion
mx.services.SOAPCall
mx.services.SOAPConstants
mx.services.SOAPFault
mx.services.SOAPHeader
mx.services.SOAPParameter
mx.services.WebService
mx.services.WebServiceProxy
mx.services.WSDL
mx.services.WSDLConstants
mx.services.WSDLDocument
mx.services.WSDLOperation
Not sure if there are others, but thats what I found.
Posted by: peter at July 22, 2005 09:15 PM
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!
Posted by: jim at July 12, 2006 10:03 AM
This is very useful :) I have one question though... how would you access the individual elements from within the Object?
Posted by: KJ at July 13, 2007 04:52 AM
Really nice stuff.Sweeeet.
Posted by: orgicus at October 7, 2007 06:22 AM