<?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>BrokenBlog</title>
	<atom:link href="http://blog.brokenfunction.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.brokenfunction.com</link>
	<description>I&#039;ll write a witty tagline later.</description>
	<lastBuildDate>Tue, 24 Aug 2010 08:10:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Flash and ExternalInterface don&#8217;t follow the same security rules</title>
		<link>http://blog.brokenfunction.com/2010/07/09/flash-and-externalinterface-dont-follow-the-same-security-rules/</link>
		<comments>http://blog.brokenfunction.com/2010/07/09/flash-and-externalinterface-dont-follow-the-same-security-rules/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 16:58:02 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[Actionscript / Flash]]></category>

		<guid isPermaLink="false">http://blog.brokenfunction.com/?p=452</guid>
		<description><![CDATA[I spent a large portion of yesterday caught up in a bug. Basically, Flash would make a call to Javascript, and a while later, get a call back. It worked something like this: ExternalInterface.addCallback("callback", function ():void { ... }); ExternalInterface.call("doSomething"); Unfortunately it didn&#8217;t work. I thought I did everything right, I set allowScriptAccess to &#8220;always&#8221;, and [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a large portion of yesterday caught up in a bug. Basically, Flash would make a call to Javascript, and a while later, get a call back. It worked something like this:</p>
<pre>ExternalInterface.addCallback("callback", function ():void { ... });
ExternalInterface.call("doSomething");</pre>
<p>Unfortunately it didn&#8217;t work. I thought I did everything right, I set allowScriptAccess to &#8220;always&#8221;, and since the swf and html page were hosted on different domains, I grant access to the swf via Security.allowDomain. But, whenever Javascript tried to call the &#8220;callback&#8221; function I would be stuck with this Javascript error:</p>
<pre>Error in Actionscript. Use a try/catch block to find error.</pre>
<p>So I tried putting it all in a try/catch of course, but that had no effect. Setting ExternalInterface.marshallExceptions to true changed the error message, but was no more helpful. I changed the function, but the error message didn&#8217;t go away. I had a hunch Flash itself was throwing the error, and I managed to figure it out.</p>
<p>The callback function itself was located in another swf that was loaded by the swf that set Security.allowDomain. I loaded it in the same ApplicationDomain and SecurityDomain, so for all intents and purposes I thought there were all the same blob of code. That&#8217;s not true, at least where ExternalInterface is concerned. Once I set the same Security.allowDomain for both swfs, the error stopped occurring. Flash was throwing a SecurityError the whole time, but I had no way of knowing that was the problem without guessing.</p>
<p>Hope that helps anyone else who encounters this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenfunction.com/2010/07/09/flash-and-externalinterface-dont-follow-the-same-security-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autobuilds on Linux</title>
		<link>http://blog.brokenfunction.com/2010/05/19/autobuilds-on-linux/</link>
		<comments>http://blog.brokenfunction.com/2010/05/19/autobuilds-on-linux/#comments</comments>
		<pubDate>Wed, 19 May 2010 06:59:53 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[MXNA]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.brokenfunction.com/?p=442</guid>
		<description><![CDATA[As a developer, I generally like very fast builds. I only managed to complete my recent port by using fcshctl to keep me from going insane waiting for the results of my work to show up. At my job however, fcshctl alone doesn&#8217;t seem good enough (although, not for lack of trying). A clever coworker reproduced [...]]]></description>
			<content:encoded><![CDATA[<p>As a developer, I generally like very fast builds. I only managed to complete my <a href="http://blog.brokenfunction.com/2009/12/29/mega-man-vs-brokenfunction/" target="_self">recent port</a> by using <a href="http://blog.brokenfunction.com/2009/06/24/compiling-as3-quickly/" target="_self">fcshctl</a> to keep me from going insane waiting for the results of my work to show up. At my job however, fcshctl alone doesn&#8217;t seem good enough (although, not for lack of trying).</p>
<p>A <a href="http://supernova-7.livejournal.com/" target="_blank">clever coworker</a> reproduced a cool feature of some <a href="http://www.djangoproject.com/" target="_blank">recent</a> <a href="http://pylonshq.com/" target="_blank">web</a> <a href="http://webpy.org/" target="_blank">frameworks</a> to make an autobuilder, a system that will automatically build projects when files related to the project change. But today I wondered if automatic Flash builds weren&#8217;t nearly fast enough! Turns out <em>they were not</em>.</p>
<p>Using some command line tools that make use of <a href="http://en.wikipedia.org/wiki/Inotify" target="_blank">inotify</a> (a Linux-only, file change notification system) I can have automatic builds that spend literally no time waiting to build when files are updated. Install <a href="http://wiki.github.com/rvoicilas/inotify-tools/" target="_blank">inotify-tools</a> and try this command:</p>
<p><code>inotifywait --monitor --recursive -e close_write -e moved_to -e create -e delete &lt;watch folders&gt; | while read line; do echo $line; &lt;build&gt;; done</code></p>
<p>Replace &#8220;&lt;watch folders&gt;&#8221; and &#8220;&lt;build&gt;&#8221; of course with the folders than need watching and the build command, respectively. inotifywait pipes changes to the files or folders you specify into the while loop, which then runs the &#8220;&lt;build&gt;&#8221; command upon each change. Combined with fcshctl, it creates blindingly fast Flash builds.</p>
<p>On a side note, I&#8217;ve been using <a href="http://en.wikipedia.org/wiki/Editor_war">vim</a> lately.  I&#8217;m growing pretty fond of it, but it (and gedit too) create temporary files. You&#8217;ll either need to modify the inotify command to ignore these files, make sure they&#8217;re not placed in the same location, or <a href="http://thehumblecoder.wordpress.com/2006/08/08/vim-swap-and-backup-files/" target="_blank">disable them entirely</a> as they will send unwarranted signals to inotify and trigger premature builds. This could apply to some version control software as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenfunction.com/2010/05/19/autobuilds-on-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Super Mario Crossover</title>
		<link>http://blog.brokenfunction.com/2010/04/28/super-mario-crossover/</link>
		<comments>http://blog.brokenfunction.com/2010/04/28/super-mario-crossover/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 16:23:47 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[Gaming]]></category>

		<guid isPermaLink="false">http://blog.brokenfunction.com/?p=439</guid>
		<description><![CDATA[I spotted this game today. Yeah, I got a huge kick out of it.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.newgrounds.com/portal/view/534416" target="_blank">I spotted this game today</a>. Yeah, I got a huge kick out of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenfunction.com/2010/04/28/super-mario-crossover/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The world is moving to HTML 5</title>
		<link>http://blog.brokenfunction.com/2010/02/07/the-world-is-moving-to-html-5/</link>
		<comments>http://blog.brokenfunction.com/2010/02/07/the-world-is-moving-to-html-5/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 17:12:18 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[Actionscript / Flash]]></category>
		<category><![CDATA[MXNA]]></category>

		<guid isPermaLink="false">http://blog.brokenfunction.com/?p=434</guid>
		<description><![CDATA[I&#8217;ve always been annoyed by the hatred of Flash by the development world. I&#8217;d prefer to see it hated for real reasons (there are plenty) and replaced by genuinely better technologies, but the hatred comes from people who often don&#8217;t care to understand Flash and support poor solutions as the answer. Lately this hatred has [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been annoyed by the hatred of Flash by the development world. I&#8217;d prefer to see it hated for real reasons (there are plenty) and replaced by genuinely better technologies, but the hatred comes from people who often don&#8217;t care to understand Flash and support poor solutions as the answer. Lately this hatred has been getting louder, and from a PR perspective Flash couldn&#8217;t be worse off.</p>
<p>I&#8217;ve tried to fully describe why this anti-Flash movement is, in so many ways, wasted energy, but I found another post instead. Here&#8217;s the best description of what role Flash plays on the Internet that I&#8217;ve read since the first Flash ad pissed off a JavaScript developer.</p>
<p><a href="http://richardleggett.co.uk/blog/index.php/2010/02/01/the-world-is-moving-to-html5">&#8220;The World is Moving to HTML 5&#8243; and Other Flights of Fancy by Richard Leggett</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenfunction.com/2010/02/07/the-world-is-moving-to-html-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mega Man vs Adobe AIR</title>
		<link>http://blog.brokenfunction.com/2010/01/06/mega-man-vs-air/</link>
		<comments>http://blog.brokenfunction.com/2010/01/06/mega-man-vs-air/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 16:10:25 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[Actionscript / Flash]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[MXNA]]></category>

		<guid isPermaLink="false">http://blog.brokenfunction.com/?p=382</guid>
		<description><![CDATA[I&#8217;ve got downloadable versions of Mega Man vs Metroid and Mega Man vs Ghosts &#8216;n Goblins available here. They require Adobe AIR to be installed in order to work. Mega Man vs Metroid Mega Man vs Ghosts &#8216;n Goblins I couldn&#8217;t test them on OS X, so if anyone can try them and tell me [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got downloadable versions of Mega Man vs Metroid and Mega Man vs Ghosts &#8216;n Goblins available here. They require <a href="http://get.adobe.com/air/" target="_blank">Adobe AIR</a> to be installed in order to work.</p>
<ul>
<li><a href="http://www.brokenfunction.com/air/mmvsmetroid2/mmvsmetroid.air">Mega Man vs Metroid</a></li>
<li><a href="http://www.brokenfunction.com/air/mmvsgng2/mmvsgng.air">Mega Man vs Ghosts &#8216;n Goblins</a></li>
</ul>
<p>I couldn&#8217;t test them on OS X, so if anyone can try them and tell me if they work I would be grateful.</p>
<p>If you have any problems please email me or leave a comment. Be sure to include your OS.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenfunction.com/2010/01/06/mega-man-vs-air/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adobe AIR and shared objects that aren&#8217;t shared</title>
		<link>http://blog.brokenfunction.com/2010/01/02/adobe-air-and-shared-objects-that-arent-shared/</link>
		<comments>http://blog.brokenfunction.com/2010/01/02/adobe-air-and-shared-objects-that-arent-shared/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 16:02:27 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[Actionscript / Flash]]></category>
		<category><![CDATA[MXNA]]></category>

		<guid isPermaLink="false">http://blog.brokenfunction.com/?p=373</guid>
		<description><![CDATA[I have been using shared objects to share data between swf files, so that changes in one can affect the other. On a website it works great as long as they share the same localPath and name, but this model doesn&#8217;t quite apply to AIR applications. Despite the name &#8220;shared objects&#8221; when you&#8217;re using them [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html" target="_blank">shared objects</a> to share data between swf files, so that changes in one can affect the other. On a website it works great as long as they share the same localPath and name, but this model doesn&#8217;t quite apply to AIR applications. Despite the name &#8220;shared objects&#8221; when you&#8217;re using them with AIR they&#8217;re private to each application, making sharing data using shared objects impossible as far as I know.</p>
<p>I&#8217;m a little surprised each application gets its own shared objects folder. I&#8217;m guessing it&#8217;s because there&#8217;s no domain to keep things properly separated, but I&#8217;m disappointed with the alternative. The localPath of a local shared object could default to a path containing the id of the application instead. This would keep local shared objects separate by default while still allowing more freedom. Treating each application as it&#8217;s own domain instead of the computer itself is frustrating. The best solution I&#8217;ve found is to create a shared application storage directory, then save any files to that.</p>
<p>These are the usual application storage directories (I&#8217;m not sure about the Mac OS X one, since I can&#8217;t test it, but it appears to be correct):</p>
<pre>Windows: %APPDATA%\Local Store\&lt;application id&gt;
Mac OS X: ~/Library/Preferences/Local Store/&lt;application id&gt;
Linux: ~/.appdata/Local Store/&lt;application id&gt;</pre>
<p>So, if we resolve the directory up two levels (&#8220;../../&#8221;), we get the following directories:</p>
<pre>Windows: %APPDATA%\
Mac OS X: ~/Library/Preferences/
Linux: ~/.appdata/</pre>
<p>Which is probably the best place to put the shared application storage directory. When creating this folder I would recommend using the same naming convention as your program id (which generally is similar to package names, e.g. &#8220;com.somewebsite.project&#8221;). <strong>It should not be the same id as another application</strong>.</p>
<p>Here&#8217;s the code in action&#8230;</p>
<pre>var appStorageDir:File = new File(File.applicationStorageDirectory.nativePath);
var saveFolder:File = appStorageDir.resolvePath("../../com.somewebsite.shared");

saveFolder.createDirectory(); // ensure the save folder exists
var fileStream:FileStream = new FileStream();
fileStream.open(saveFolder.resolvePath("savedata.bin"), FileMode.WRITE);
fileStream.writeObject(obj);
fileStream.close();</pre>
<p>I create a duplicate of File.applicationStorageDirectory because it doesn&#8217;t allow you to resolve paths beyond the root of the directory.</p>
<p>It&#8217;s important to realize that this is ultimately a hack. If the application directory changes it could save the file somewhere unexpected. Still, it&#8217;s unlikely to change in the current version of AIR and it&#8217;s the best way I&#8217;ve found to share data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brokenfunction.com/2010/01/02/adobe-air-and-shared-objects-that-arent-shared/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
