<?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>Cylinder Studio &#187; Actionscript</title>
	<atom:link href="http://cylinderstudio.com/category/blog/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://cylinderstudio.com</link>
	<description>Seattle Flash &#38; Flex application, iPad/iPhone app, and ExpressionEngine website design and development - Cylinder Studio</description>
	<lastBuildDate>Tue, 13 Mar 2012 18:44:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using Public APIs with Flash but no crossdomain.xml</title>
		<link>http://cylinderstudio.com/blog/actionscript/using-public-apis-with-flash-but-no-crossdomain-xml/</link>
		<comments>http://cylinderstudio.com/blog/actionscript/using-public-apis-with-flash-but-no-crossdomain-xml/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 00:03:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://cylinderstudio.com/?p=278</guid>
		<description><![CDATA[A lot of the Flash and Flex applications I build are dynamically driven by XML. As many ActionScript devs know, a crossdomain.xml file is required to pull XML from a server that&#8217;s separate from the one where the SWF resides. Until now, I&#8217;ve always used local XML documents, had access to the server where the [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of the Flash and Flex applications I build are dynamically driven by XML. As many ActionScript devs know, <a onclick="window.open('http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html','blank','scrollbars=yes,toolbar=no'); return false" href="#">a crossdomain.xml file is required </a>to pull XML from a server that&#8217;s separate from the one where the SWF resides.</p>
<p>Until now, I&#8217;ve always used local XML documents, had access to the server where the XML was being served and could put a crossdomain.xml file in place, or had access to a public API that provided an XML feed and had a crossdomain.xml file already in place. But an application I&#8217;m working on now uses XML from a server where I have no access or ability to put a crossdomain.xml file.</p>
<p>Enter the PHP proxy and the <a onclick="window.open('http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package.html#escape()','blank','scrollbars=yes,toolbar=no'); return false" href="#">ActionScript escape method</a>. A PHP script handles the URL for the API call, but you have to encode that URL with its arguments before handing off to the proxy.</p>
<p>Example:</p>
<p>Here&#8217;s the code for the PHP proxy file, which goes on the same server as your SWF.<br />
<code><br />
$post_data = $HTTP_RAW_POST_DATA;</p>
<p>$header[] = "Content-type: text/xml";<br />
$header[] = "Content-length: ".strlen($post_data);</p>
<p>$ch = curl_init( $_GET['url'] );<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
curl_setopt($ch, CURLOPT_TIMEOUT, 10);<br />
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);</p>
<p>if ( strlen($post_data)>0 ){<br />
    curl_setopt($ch, CURLOPT_POST, 1);<br />
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);<br />
}</p>
<p>$response = curl_exec($ch);<br />
$response_headers = curl_getinfo($ch);     </p>
<p>if (curl_errno($ch)) {<br />
    print curl_error($ch);<br />
} else {<br />
    curl_close($ch);<br />
    header( 'Content-type: ' . $response_headers['content-type']);<br />
    print $response;<br />
}<br />
</code></p>
<blockquote><p>(Thanks to <a onclick="window.open('http://xmlrpcflash.mattism.com/proxy_info.php','blank','scrollbars=yes,toolbar=no'); return false" href="#">xmlrpcflash.mattism.com</a> for the PHP script.)</p></blockquote>
<p>Now, assuming you are using a Loader with a URLRequest to pull XML into your application, and your xml_proxy.php file is in the same directory as your SWF, you have to escape( ) on the URL call to the API server, then tack that on to the end of your URLRequest to the PHP proxy, like this:</p>
<p><code>var myXMLLoader:URLLoader = new URLLoader();</p>
<p>var API_URL:String = escape("http://theAPIServer.com?app_id=d57&#038;app_key=e9409&#038;format=xml");</p>
<p>myXMLLoader.load(new URLRequest("xml_proxy.php?url="+API_URL));</code></p>
<p>Voila! No security sandbox error from Flash Player.</p>
]]></content:encoded>
			<wfw:commentRss>http://cylinderstudio.com/blog/actionscript/using-public-apis-with-flash-but-no-crossdomain-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display Objects and Memory Management</title>
		<link>http://cylinderstudio.com/blog/flash/display-objects-and-memory-management/</link>
		<comments>http://cylinderstudio.com/blog/flash/display-objects-and-memory-management/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 21:45:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://cylinderstudio.com/?p=77</guid>
		<description><![CDATA[There&#8217;s a good article on InsideRIA.com describing the key differences between the &#8220;visible&#8221; variable, the &#8220;alpha&#8221; variable and the removeChild( ) method when managing memory in your Flash applications.]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a <a href="#" onclick="window.open('http://www.insideria.com/2008/11/visible-false-versus-removechi.html','blank','scrollbars=yes,toolbar=no'); return false">good article on InsideRIA.com</a> describing the key differences between the &#8220;visible&#8221; variable, the &#8220;alpha&#8221; variable and the removeChild( ) method when managing memory in your Flash applications. </p>
]]></content:encoded>
			<wfw:commentRss>http://cylinderstudio.com/blog/flash/display-objects-and-memory-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

