<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flex Example: Populating Value Objects with web service XML</title>
	<atom:link href="http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/</link>
	<description>excerpts from the mind of a platform evangelist</description>
	<lastBuildDate>Wed, 11 Jan 2012 16:24:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Gregory Web Services</title>
		<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/comment-page-1/#comment-75700</link>
		<dc:creator>Gregory Web Services</dc:creator>
		<pubDate>Sun, 18 Dec 2011 00:00:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.chuckstar.com/blog/?p=617#comment-75700</guid>
		<description>You&#039;ve got great insights about Web Services, keep up the good work!</description>
		<content:encoded><![CDATA[<p>You&#8217;ve got great insights about Web Services, keep up the good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tink</title>
		<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/comment-page-1/#comment-67731</link>
		<dc:creator>Tink</dc:creator>
		<pubDate>Mon, 15 Feb 2010 13:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.chuckstar.com/blog/?p=617#comment-67731</guid>
		<description>&quot;Can you explain why this solution might be slower? I don’t disagree, but are we talking long periods of time? Running this in my AIR app, I don’t see any lag.&quot;

Just for clarification from the horses mouth...

http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c3a0f5f19124318fc87b-7ffc.html

&quot;Avoid using the square bracket operator, when possible.

Using the square bracket operator can slow down performance. You can avoid using it by storing your reference in a local variable. The following code example demonstrates inefficient use of the square bracket operator:&quot;</description>
		<content:encoded><![CDATA[<p>&#8220;Can you explain why this solution might be slower? I don’t disagree, but are we talking long periods of time? Running this in my AIR app, I don’t see any lag.&#8221;</p>
<p>Just for clarification from the horses mouth&#8230;</p>
<p><a href="http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c3a0f5f19124318fc87b-7ffc.html" rel="nofollow">http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c3a0f5f19124318fc87b-7ffc.html</a></p>
<p>&#8220;Avoid using the square bracket operator, when possible.</p>
<p>Using the square bracket operator can slow down performance. You can avoid using it by storing your reference in a local variable. The following code example demonstrates inefficient use of the square bracket operator:&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evan Gifford</title>
		<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/comment-page-1/#comment-67518</link>
		<dc:creator>Evan Gifford</dc:creator>
		<pubDate>Mon, 25 Jan 2010 18:47:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.chuckstar.com/blog/?p=617#comment-67518</guid>
		<description>Oh, and also check out our benchmarks of using this technique. I find it very fast!</description>
		<content:encoded><![CDATA[<p>Oh, and also check out our benchmarks of using this technique. I find it very fast!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evan Gifford</title>
		<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/comment-page-1/#comment-67517</link>
		<dc:creator>Evan Gifford</dc:creator>
		<pubDate>Mon, 25 Jan 2010 18:45:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.chuckstar.com/blog/?p=617#comment-67517</guid>
		<description>To parse your example above using the open source AS3Commons serialization you can do this:

  var converter:XMLConverter = new XMLConverter();
  converter.register(&quot;item&quot;ItemVO);

  var items:ArrayCollection = new ArrayCollection( converter.fromXML( inXML ) );

and back to XML:

  var outXML:XML = converter.arrayToXML( items,&quot;items&quot; );


I want to bring attention to a project we developed and released open source with the AS3Commons project. It takes the concept of &quot;fully automated XML deserialization&quot; and provides a set of easy to use Classes to parse large XML files with a few lines.

The first issue we addressed is how to coerce string values in XML to native Actionscript types. The typical example is converting &quot;true&quot; to a Boolean - true, or &quot;3.1415&quot; to a Number - 3.1415. This is accomplished using code reflection and the AS3Commons Reflect package. The class will inspect the Actionscript Class and use a set of rules to coerce string values into the native values of the properties on the Object.

Other issues are - when converting AS3 value objects back to XML - which is accomplished with a couple lines of code - all attributes and CDATA are persisted from the original parsed XML structure. 

Also, it is easy to create and register your own custom converters using the converter registery. For instance, there is one &quot;extended&quot; converter which will encode a ByteArray inline in XML using Base64 encoding. (Great for sending images/thumbnails along with a service call)

Spread the word!! :)

Example project to jump in:
http://as3-commons.googlecode.com/files/AS3C_XMLSerializationExample.zip

Project Links:
http://code.google.com/p/as3-commons/
http://www.as3commons.org/

-Evan</description>
		<content:encoded><![CDATA[<p>To parse your example above using the open source AS3Commons serialization you can do this:</p>
<p>  var converter:XMLConverter = new XMLConverter();<br />
  converter.register(&#8220;item&#8221;ItemVO);</p>
<p>  var items:ArrayCollection = new ArrayCollection( converter.fromXML( inXML ) );</p>
<p>and back to XML:</p>
<p>  var outXML:XML = converter.arrayToXML( items,&#8221;items&#8221; );</p>
<p>I want to bring attention to a project we developed and released open source with the AS3Commons project. It takes the concept of &#8220;fully automated XML deserialization&#8221; and provides a set of easy to use Classes to parse large XML files with a few lines.</p>
<p>The first issue we addressed is how to coerce string values in XML to native Actionscript types. The typical example is converting &#8220;true&#8221; to a Boolean &#8211; true, or &#8220;3.1415&#8243; to a Number &#8211; 3.1415. This is accomplished using code reflection and the AS3Commons Reflect package. The class will inspect the Actionscript Class and use a set of rules to coerce string values into the native values of the properties on the Object.</p>
<p>Other issues are &#8211; when converting AS3 value objects back to XML &#8211; which is accomplished with a couple lines of code &#8211; all attributes and CDATA are persisted from the original parsed XML structure. </p>
<p>Also, it is easy to create and register your own custom converters using the converter registery. For instance, there is one &#8220;extended&#8221; converter which will encode a ByteArray inline in XML using Base64 encoding. (Great for sending images/thumbnails along with a service call)</p>
<p>Spread the word!! <img src='http://www.chuckstar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Example project to jump in:<br />
<a href="http://as3-commons.googlecode.com/files/AS3C_XMLSerializationExample.zip" rel="nofollow">http://as3-commons.googlecode.com/files/AS3C_XMLSerializationExample.zip</a></p>
<p>Project Links:<br />
<a href="http://code.google.com/p/as3-commons/" rel="nofollow">http://code.google.com/p/as3-commons/</a><br />
<a href="http://www.as3commons.org/" rel="nofollow">http://www.as3commons.org/</a></p>
<p>-Evan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tink</title>
		<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/comment-page-1/#comment-67395</link>
		<dc:creator>Tink</dc:creator>
		<pubDate>Thu, 14 Jan 2010 12:10:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.chuckstar.com/blog/?p=617#comment-67395</guid>
		<description>I&#039;m, not definite, but I think it would be a little slower due to the code having to be evaluated (i.e. string to property). If I&#039;m correct it would still be minor, you&#039;d need huge datasets to see any diff.

still think something like this is much tidier


var resultXML:XML = XML(e.target.data);
var items:Array = new Array();

for each(var itemXML:XML in resultXML.item)
{
       items.push( new ItemsVO( itemXML ) );	
}

var itemsCollection:ArrayCollection = new ArrayCollection( items );


I&#039;d then get rid or the setter if the data wasn&#039;t editable</description>
		<content:encoded><![CDATA[<p>I&#8217;m, not definite, but I think it would be a little slower due to the code having to be evaluated (i.e. string to property). If I&#8217;m correct it would still be minor, you&#8217;d need huge datasets to see any diff.</p>
<p>still think something like this is much tidier</p>
<p>var resultXML:XML = XML(e.target.data);<br />
var items:Array = new Array();</p>
<p>for each(var itemXML:XML in resultXML.item)<br />
{<br />
       items.push( new ItemsVO( itemXML ) );<br />
}</p>
<p>var itemsCollection:ArrayCollection = new ArrayCollection( items );</p>
<p>I&#8217;d then get rid or the setter if the data wasn&#8217;t editable</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chuckstar22</title>
		<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/comment-page-1/#comment-67363</link>
		<dc:creator>chuckstar22</dc:creator>
		<pubDate>Wed, 13 Jan 2010 13:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.chuckstar.com/blog/?p=617#comment-67363</guid>
		<description>@Tink,

Thanks for your comments.

I know this solution breaks a few rules, but I was surprised it worked so well for me. I think it should only be used when the developer has FULL control of both the XML and AS code, assuring the available vo props always matches the node names. The properties of the vo are set through implicit getters/setters.

Can you explain why this solution might be slower? I don&#039;t disagree, but are we talking long periods of time? Running this in my AIR app, I don&#039;t see any lag.</description>
		<content:encoded><![CDATA[<p>@Tink,</p>
<p>Thanks for your comments.</p>
<p>I know this solution breaks a few rules, but I was surprised it worked so well for me. I think it should only be used when the developer has FULL control of both the XML and AS code, assuring the available vo props always matches the node names. The properties of the vo are set through implicit getters/setters.</p>
<p>Can you explain why this solution might be slower? I don&#8217;t disagree, but are we talking long periods of time? Running this in my AIR app, I don&#8217;t see any lag.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tink</title>
		<link>http://www.chuckstar.com/blog/technology/flex-sample-populating-value-objects-with-web-service-xml/comment-page-1/#comment-67357</link>
		<dc:creator>Tink</dc:creator>
		<pubDate>Wed, 13 Jan 2010 09:35:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.chuckstar.com/blog/?p=617#comment-67357</guid>
		<description>I&#039;d set the properties individually to avoid any errors if the vo doesn&#039;t match the node.

&#039;item[itemProp.name()]&#039;  is a little flakey IMO, and I believe would be a little slower.

Generally I try and seal my vo&#039;s up from the outside world to (i.e. views etc). If i knew it didn&#039;t need to change I would pass the node into the constructor and assign the properties internally, only exposing them through getters.</description>
		<content:encoded><![CDATA[<p>I&#8217;d set the properties individually to avoid any errors if the vo doesn&#8217;t match the node.</p>
<p>&#8216;item[itemProp.name()]&#8216;  is a little flakey IMO, and I believe would be a little slower.</p>
<p>Generally I try and seal my vo&#8217;s up from the outside world to (i.e. views etc). If i knew it didn&#8217;t need to change I would pass the node into the constructor and assign the properties internally, only exposing them through getters.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

