<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Parallelcoding.com &#187; Flex</title>
	<atom:link href="http://www.parallelcoding.com/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.parallelcoding.com</link>
	<description></description>
	<lastBuildDate>Mon, 16 Aug 2010 11:55:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Sorting a XMLListCollection in Flex</title>
		<link>http://www.parallelcoding.com/2008/10/20/sorting-a-xmllistcollection-in-flex/</link>
		<comments>http://www.parallelcoding.com/2008/10/20/sorting-a-xmllistcollection-in-flex/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 17:58:26 +0000</pubDate>
		<dc:creator>manatarms</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Sorting]]></category>

		<guid isPermaLink="false">http://www.parallelcoding.com/?p=35</guid>
		<description><![CDATA[Recently I had the need to sort and XMLListCollection in Flex. This seems to be a rather straightforward task. I had a XMLList where each item had an element called &#8216;Image&#8217;. I wanted to sort by the value of the &#8216;Image&#8217; node in descending order. The original code was as follows: 1 2 3 4 [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had the need to sort and XMLListCollection in Flex. This seems to be a rather straightforward task. I had a XMLList where each item had an element called &#8216;Image&#8217;. I wanted to sort by the value of the &#8216;Image&#8217; node in descending order.</p>
<p>The original code was as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> z<span style="color: #000000; font-weight: bold;">:</span>XMLListCollection = <span style="color: #0033ff; font-weight: bold;">new</span> XMLListCollection<span style="color: #000000;">&#40;</span>xmlList<span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> mySort<span style="color: #000000; font-weight: bold;">:</span>Sort = <span style="color: #0033ff; font-weight: bold;">new</span> Sort<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
mySort.fields = <span style="color: #000000;">&#91;</span><span style="color: #0033ff; font-weight: bold;">new</span> SortField<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Image&quot;</span>,<span style="color: #0033ff; font-weight: bold;">false</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>;
z.<span style="color: #004993;">sort</span> = mySort;
z.refresh<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>This seemed to work fine for some time. Eventually, the client came back and alerted us that values were now be returned incorrectly. In fact, the set of values being returned was simply a repetition of the value of the first node of the first element. How can this be corrected? Quite simply actually. I first decided not to use the built in sorting capabilities of ActionScript. I found a function and modified the code as follows (the code I modified can be found &lt;a href=&#8221;http://www.nuff-respec.com/technology/sort-xml-by-attribute-in-actionscript-3&#8243;&gt;here&lt;/a&gt;):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> sortXMLByAttribute<span style="color: #000000;">&#40;</span>$xml<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XMLList</span>, $element<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>, $options<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XMLList</span><span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #009900;">//store in array to sort on</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> xmlArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> item<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> <span style="color: #0033ff; font-weight: bold;">in</span> $xml<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> object<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">data</span>	<span style="color: #000000; font-weight: bold;">:</span> item,
			order	<span style="color: #000000; font-weight: bold;">:</span> item.<span style="color: #004993;">elements</span><span style="color: #000000;">&#40;</span>$element<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#125;</span>;
		xmlArray.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>object<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #009900;">//sort using the power of Array.sortOn()</span>
	xmlArray.<span style="color: #004993;">sortOn</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'order'</span>,$options<span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #009900;">//create a new XMLList with sorted XML</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> sortedXmlList<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XMLList</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XMLList</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> xmlObject<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #0033ff; font-weight: bold;">in</span> xmlArray <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		sortedXmlList <span style="color: #000000; font-weight: bold;">+</span>= xmlObject.<span style="color: #004993;">data</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">return</span> sortedXmlList.<span style="color: #004993;">copy</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The I changed my original code to the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> z<span style="color: #000000; font-weight: bold;">:</span>XMLListCollection = <span style="color: #0033ff; font-weight: bold;">new</span> XMLListCollection<span style="color: #000000;">&#40;</span>sortXMLByAttribute<span style="color: #000000;">&#40;</span>xmlList,<span style="color: #990000;">&quot;Image&quot;</span>,<span style="color: #004993;">Array</span>.<span style="color: #004993;">DESCENDING</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>And that solved the problem. So why the issue in the first place? I&#8217;m not really 100% sure at the moment, but I&#8217;m looking into it. Maybe someone else out there has some input?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.parallelcoding.com/2008/10/20/sorting-a-xmllistcollection-in-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex Security Error Accessing URL or Channel.Security.Error</title>
		<link>http://www.parallelcoding.com/2008/08/11/flex-security-error-accessing-url-or-channelsecurityerror/</link>
		<comments>http://www.parallelcoding.com/2008/08/11/flex-security-error-accessing-url-or-channelsecurityerror/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 22:09:14 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://dotanything.wordpress.com/?p=20</guid>
		<description><![CDATA[I had this wonderful error in a Flex Application that I couldn&#8217;t figure out.  Every time the app attempted to access the Web Service it returned the error &#8220;Security Error Accessing URL&#8221;. Well, thanks to this helpful site &#8211; http://talsma.tv/post.cfm/flash-9-0-124-and-webservice-over-https-channel-security-error &#8211; my problems have been solved. Apparently there is a security issue with Flash 9.0.124 [...]]]></description>
			<content:encoded><![CDATA[<p>I had this wonderful error in a Flex Application that I couldn&#8217;t figure out.  Every time the app attempted to access the Web Service it returned the error &#8220;Security Error Accessing URL&#8221;. Well, thanks to this helpful site &#8211; <a title="http://talsma.tv/post.cfm/flash-9-0-124-and-webservice-over-https-channel-security-error" href="http://talsma.tv/post.cfm/flash-9-0-124-and-webservice-over-https-channel-security-error" target="_blank">http://talsma.tv/post.cfm/flash-9-0-124-and-webservice-over-https-channel-security-error</a> &#8211; my problems have been solved.</p>
<p>Apparently there is a security issue with Flash 9.0.124 that requires the following line to be added to the CrossDomain.xml file:</p>
<p>[sourcecode='xml']<br />
<allow-http-request-headers-from domain="*" headers="SOAPAction"/><br />
[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.parallelcoding.com/2008/08/11/flex-security-error-accessing-url-or-channelsecurityerror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
