<?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>Thoughts from Mads Sülau Jørgensen &#187; Actionscript</title> <atom:link href="http://madssj.com/blog/category/actionscript/feed/" rel="self" type="application/rss+xml" /><link>http://madssj.com/blog</link> <description>Various articles about programming and systems administration.</description> <lastBuildDate>Mon, 27 Jun 2011 08:54:43 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Using mercurial with eclipse to edit actionscript files on os x</title><link>http://madssj.com/blog/2009/03/11/using-mercurial-with-eclipse-to-edit-actionscript-files-on-os-x/</link> <comments>http://madssj.com/blog/2009/03/11/using-mercurial-with-eclipse-to-edit-actionscript-files-on-os-x/#comments</comments> <pubDate>Wed, 11 Mar 2009 09:38:33 +0000</pubDate> <dc:creator>Mads Sülau Jørgensen</dc:creator> <category><![CDATA[Actionscript]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Work]]></category> <category><![CDATA[Mercurial]]></category> <guid
isPermaLink="false">http://swag.dk/blog/2009/03/11/using-mercurial-with-eclipse-to-edit-actionscript-files-on-os-x/</guid> <description><![CDATA[We have recently switched to use mercurial as our DVCS. We&#8217;re hosting our many repositories on bitbucket. I love it. When it comes to actionscript files, flash has always had odd newlines. For some reason, it has always used r &#8230; <a
href="http://madssj.com/blog/2009/03/11/using-mercurial-with-eclipse-to-edit-actionscript-files-on-os-x/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a
href="http://www.konstellation.dk/">We</a> have recently switched to use <a
href="http://www.selenic.com/mercurial/wiki/">mercurial</a> as our DVCS. We&#8217;re hosting our many repositories on <a
href="http://bitbucket.org/">bitbucket</a>.</p><p>I love it.</p><p>When it comes to actionscript files, flash has always had odd newlines. For some reason, it has always used <code>r</code> as it&#8217;s newline. Mercurial, beeing a unix tool, likes it&#8217;s newlines to be <code>n</code>. So what better to do, than to make mercurial encode/decode the files for us.</p><p>To do that, we can simply add the following to our <code>.hgrc</code> file:</p><pre>
[encode]
*.as = perl -pe 's/r/n/g'
[decode]
*.as = perl -pe 's/r/n/g'
</pre><p>I don&#8217;t really know wether the decode part is necessary, but I like to keep it around (if someone should commit poison).</p> ]]></content:encoded> <wfw:commentRss>http://madssj.com/blog/2009/03/11/using-mercurial-with-eclipse-to-edit-actionscript-files-on-os-x/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Actionscript 3 &#8211; posting XML data with URLLoader</title><link>http://madssj.com/blog/2008/07/30/actionscript-3-posting-xml-data-with-urlloader/</link> <comments>http://madssj.com/blog/2008/07/30/actionscript-3-posting-xml-data-with-urlloader/#comments</comments> <pubDate>Wed, 30 Jul 2008 13:33:34 +0000</pubDate> <dc:creator>Mads Sülau Jørgensen</dc:creator> <category><![CDATA[Actionscript]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Work]]></category> <guid
isPermaLink="false">http://swag.dk/blog/?p=32</guid> <description><![CDATA[So, you want to POST some XML data to a web service. Let&#8217;s for the fun of it say, that we would like to POST the following piece of XML to a PHP script: 1 &#60;request command=&#34;run-command&#34; /&#62; Now, the &#8230; <a
href="http://madssj.com/blog/2008/07/30/actionscript-3-posting-xml-data-with-urlloader/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>So, you want to POST some XML data to a web service.</p><p>Let&#8217;s for the fun of it say, that we would like to POST the following piece of XML to a PHP script:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;request</span> <span style="color: #000066;">command</span>=<span style="color: #ff0000;">&quot;run-command&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div><p><span
id="more-32"></span></p><p>Now, the way I&#8217;d do that in Actionscript 3, is like this:</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
</pre></td><td
class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> a<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000066; font-weight: bold;">&lt;</span>request command=<span style="color: #990000;">&quot;run-command&quot;</span> <span style="color: #000066; font-weight: bold;">/&gt;;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> r<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://localhost/service.php&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
r<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> = a<span style="color: #000066; font-weight: bold;">;</span>
r<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">method</span> = <span style="color: #004993;">URLRequestMethod</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">POST</span><span style="color: #000066; font-weight: bold;">;</span>
r<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentType</span> = <span style="color: #990000;">&quot;text/xml&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;success&quot;</span><span style="color: #000066; font-weight: bold;">,</span> l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">IO_ERROR</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;failed&quot;</span><span style="color: #000066; font-weight: bold;">,</span> e<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>r<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div><p>But it seems, that older flash players (&lt;= 9,0,45,0) does not call the XML&#8217;s toString() or something. The result is, that the URLLoader makes a GET request, which is a bit hard to debug as version 9,0,115,0 does send the XML correctly.</p><p>Anyway, the correct way to do it, seems to be to manually call the XML&#8217;s .toXMLString() method, like so:</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
</pre></td><td
class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> a<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000066; font-weight: bold;">&lt;</span>request command=<span style="color: #990000;">&quot;run-command&quot;</span> <span style="color: #000066; font-weight: bold;">/&gt;;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> r<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://localhost/service.php&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
r<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> = a<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toXMLString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
r<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">method</span> = <span style="color: #004993;">URLRequestMethod</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">POST</span><span style="color: #000066; font-weight: bold;">;</span>
r<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentType</span> = <span style="color: #990000;">&quot;text/xml&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;success&quot;</span><span style="color: #000066; font-weight: bold;">,</span> l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">IO_ERROR</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;failed&quot;</span><span style="color: #000066; font-weight: bold;">,</span> e<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>r<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div> ]]></content:encoded> <wfw:commentRss>http://madssj.com/blog/2008/07/30/actionscript-3-posting-xml-data-with-urlloader/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
