<?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>Nuclear Rooster &#187; Flex</title>
	<atom:link href="http://dev.nuclearrooster.com/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.nuclearrooster.com</link>
	<description></description>
	<lastBuildDate>Mon, 19 Jul 2010 03:48:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ExternalInterface.addCallback can cause IE JS Errors with certain keyworkds</title>
		<link>http://dev.nuclearrooster.com/2008/07/27/externalinterfaceaddcallback-can-cause-ie-js-errors-with-certain-keyworkds/</link>
		<comments>http://dev.nuclearrooster.com/2008/07/27/externalinterfaceaddcallback-can-cause-ie-js-errors-with-certain-keyworkds/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 05:17:48 +0000</pubDate>
		<dc:creator>nick.stielau</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[reserved words]]></category>

		<guid isPermaLink="false">http://dev.nuclearrooster.com/?p=54</guid>
		<description><![CDATA[After hide-and-go-seek-an-IE-javascript error, the solution proved to be delightfully easy, and completely inane (go figure IE). Apparently, you cannot adding an actionscript callback for a certain set of keywords ("play", "stop", ?) will break in IE and cause a javascript error. The Flash 9 ExternalInterface page notes this in a comment at the bottom. Turns [...]]]></description>
			<content:encoded><![CDATA[<p>After hide-and-go-seek-an-IE-javascript error, the solution proved to be delightfully easy, and completely inane (go figure IE). Apparently, you cannot adding an actionscript callback for a certain set of keywords ("play", "stop", ?) will break in IE and cause a javascript error.  </p>
<p>The <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html">Flash 9 ExternalInterface page</a> notes this in a comment at the bottom.</p>
<p>Turns out there is a whole bunch of 'special' words that break IE in different contexts, mostly DOM id's that will break IE.   Eric Meyer has a better explanation with demos <a href="http://meyerweb.com/eric/thoughts/2005/08/29/reserved-id-values/"> here<a/>.</p>
<p>Stay away from
<ul>
<li>play</li>
<li>stop</li>
<li>tags</li>
<li>tags</li>
<li>item</li>
<li>length</li>
</ul>
<p> and, no doubt, many more.</p>
<p>Again, IE, you</p>
<div align="center"><div id="attachment_57" class="wp-caption aligncenter" style="width: 310px"><a href="http://dev.nuclearrooster.com/wp-content/uploads/2008/07/fail.jpg"><img src="http://dev.nuclearrooster.com/wp-content/uploads/2008/07/fail-300x212.jpg" alt="Fail" title="fail" width="300" height="212" class="size-medium wp-image-57" /></a><p class="wp-caption-text">Fail</p></div></div>
]]></content:encoded>
			<wfw:commentRss>http://dev.nuclearrooster.com/2008/07/27/externalinterfaceaddcallback-can-cause-ie-js-errors-with-certain-keyworkds/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 Regex Test</title>
		<link>http://dev.nuclearrooster.com/2008/05/27/actionscript-3-regex-test/</link>
		<comments>http://dev.nuclearrooster.com/2008/05/27/actionscript-3-regex-test/#comments</comments>
		<pubDate>Wed, 28 May 2008 02:22:47 +0000</pubDate>
		<dc:creator>nick.stielau</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Regex]]></category>

		<guid isPermaLink="false">http://dev.nuclearrooster.com/?p=43</guid>
		<description><![CDATA[Regex's a powerful and well worthing knowing about and using. To me, the somewhat arcane syntax of regular expressions, and the language-specific intricacies borders on trivia. Luckily, there are tools to help you remember and apply regular expressions on the net. My recent favorite is G. Skinner's RegExr, which is a great ActionScript 3 regex [...]]]></description>
			<content:encoded><![CDATA[<p>Regex's a powerful and well worthing knowing about and using.  To me, the somewhat arcane syntax of regular expressions, and the language-specific intricacies borders on trivia.  Luckily, there are tools to help you remember and apply regular expressions on the net.  My recent favorite is G. Skinner's <a href="http://gskinner.com/RegExr/">RegExr</a>, which is a great ActionScript 3 regex text built in Flex.  Check it out. </p>
<div align="center">
<a href='http://gskinner.com/RegExr/'><img src="http://dev.nuclearrooster.com/wp-content/uploads/2008/05/firefoxscreensnapz003-300x155.png" alt="GSkinner\&#039;s RegExr" title="GSkinner's RegExr" width="300" height="155" class="aligncenter size-medium wp-image-44" /></a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dev.nuclearrooster.com/2008/05/27/actionscript-3-regex-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting ExternalInterface to work with IE7</title>
		<link>http://dev.nuclearrooster.com/2008/05/23/getting-externalinterface-to-work-with-ie7/</link>
		<comments>http://dev.nuclearrooster.com/2008/05/23/getting-externalinterface-to-work-with-ie7/#comments</comments>
		<pubDate>Sat, 24 May 2008 03:14:40 +0000</pubDate>
		<dc:creator>nick.stielau</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://dev.nuclearrooster.com/?p=40</guid>
		<description><![CDATA[Pretty much every blog post I have starts off with "The other day," or "Recently," so I decided to start this one off differently. Anyhoo, now that that is out of the way, we can get to the good stuff. So, recently, I was trying to determine the current page a SWF was loaded on [...]]]></description>
			<content:encoded><![CDATA[<p>Pretty much every blog post I have starts off with "The other day," or "Recently," so I decided to start this one off differently.  Anyhoo, now that that is out of the way, we can get to the good stuff.  So, recently, I was trying to determine the current page a SWF was loaded on using ActionScript's ExternalInterface class.  There are a few oddities around working with ExternalInterface, including the flash runtime's security sandboxing and the pain of cross-browser embedding.  </p>
<p>Everything works great, for instance, and then you export a release build and it doesn't work.  Or trouble going from a file:// to http://.  Anyway, after sufficient logging, I was well on my way.  And then, boom, IE drops the the ball again.</p>
<div align="center">
<img src="http://dev.nuclearrooster.com/wp-content/uploads/2008/05/epic_fail-224x300.jpg" alt="Internet Explorer 7: Epic fail" title="epic_fail" width="224" height="300" class="aligncenter size-medium wp-image-42" /></p>
<h2>IE, you epic fail</h2>
</div>
<p>Anyway, after much Parallels-ing and googling, I get an answer.  It wasn't giving the <a href="http://labs.hellokeita.com/2007/10/16/swfobject-externalinterface-bug-on-ie/">object tag an id</a< (not that I'm using swffix, though).  It was that IE needs the classid specified in order to communicate with the Flash runtime ActiveX control.  </p>
<pre>
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" .....
</pre>
<p>[HTML]<br />
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"<br />
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"<br />
WIDTH="550" HEIGHT="400" id="myMovieName"><PARAM NAME=movie VALUE="myFlashMovie.swf"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="/support/flash/ts/documents/myFlashMovie.swf" quality=high bgcolor=#FFFFFF WIDTH="550" HEIGHT="400"<br />
NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"<br />
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT><br />
[/HTML]</p>
<p>Here are some helpful links</p>
<p><a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_4150&#038;sliceId=1"> Flash OBJECT and EMBED tag syntax</a><br/>                                  </p>
<p><a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701                                              "> Flash OBJECT and EMBED tag attributes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.nuclearrooster.com/2008/05/23/getting-externalinterface-to-work-with-ie7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple Rails Uploader</title>
		<link>http://dev.nuclearrooster.com/2008/04/10/simple-rails-uploader/</link>
		<comments>http://dev.nuclearrooster.com/2008/04/10/simple-rails-uploader/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 16:26:27 +0000</pubDate>
		<dc:creator>nick.stielau</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Ruby/Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[stupid tricks]]></category>

		<guid isPermaLink="false">http://dev.nuclearrooster.com/?p=34</guid>
		<description><![CDATA[Simple Rails Uploader I was recently trying to implement an upload to Amazon S3, and it wasn't working. I couldn't tell if it was the Flex front end, or the S3 backend, or what, so I decided to Wear my ruby slippers to work, or rather my Rails slippers (so comfy and I just like [...]]]></description>
			<content:encoded><![CDATA[<h3>Simple Rails Uploader</h3>
<p>I was recently <a href="http://dev.nuclearrooster.com/2008/04/05/uploading-with-a-filereference-from-flex-3-on-os-x/">trying to implement an upload </a>to Amazon S3, and it wasn't working.  I couldn't tell if it was the Flex front end, or the S3 backend, or what, so I decided to <a href="http://whytheluckystiff.net/articles/wearingRubySlippersToWork.html">Wear my ruby slippers to work</a>, or rather my Rails slippers (so comfy and I just like them so much).</p>
<p>About 15 minutes and 15 lines of code later, I had a rails app running locally which accepted the upload from Flex and logged all the request parameters. I found the <a href="http://manuals.rubyonrails.com/read/chapter/77">Simplest upload that could possibly work</a> in the Rails Cookbook, and a <a href="http://wiki.rubyonrails.org/rails/pages/HowtoUploadFiles">Rails wiki page</a> to that purpose.  In the Rails Cookbook, note that you should use <code>params['file']</code> rather than the oldschool <code>@params['file']</code>.</p>
<p>To get a simple Rails (> 2.0) app for testing the uploads, try this</p>
<pre>
rails uploader
cd uploader
script/generate controller upload
</pre>
<p>Paste in some code from the Simplest Upload Possible article above.</p>
<pre class="brush: ruby;">
class UploadController &lt; ApplicationController
  def save_file
    logger.info(params.insect)

    if request.get?
    render :text =&gt; 'Please Upoad file'
    else
      # Use &quot;wb&quot; mode on windows.
      File.open(&quot;#{RAILS_ROOT}/public/files/#{Time.now.to_i}.jpg&quot;, &quot;w&quot;) do |f|
        f.write(params['file'].read)
      end
    render :text =&gt; 'Done'
    end
  end
end
</pre>
<p>Now, in Flex, have your FileReference upload to your server, and make sure to use the right field name.</p>
<p>[ActionScript]<br />
var urlRequest:URLRequest = new URLRequest("http://127.0.0.1:3000/upload/save_file");<br />
urlRequest.method = URLRequestMethod.POST;<br />
file.upload(urlRequest, "file");<br />
[/ActionScript]</p>
<p>Tails your logs, and look for the output.  One step closer.</p>
<p>I might try to clean up a simple uploader app and thow it up (blaagh) here.  Any interest?</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.nuclearrooster.com/2008/04/10/simple-rails-uploader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uploading to S3 with a FileReference from Flex 3 on OS X</title>
		<link>http://dev.nuclearrooster.com/2008/04/05/uploading-with-a-filereference-from-flex-3-on-os-x/</link>
		<comments>http://dev.nuclearrooster.com/2008/04/05/uploading-with-a-filereference-from-flex-3-on-os-x/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 19:23:14 +0000</pubDate>
		<dc:creator>nick.stielau</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Ruby/Rails]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://dev.nuclearrooster.com/?p=33</guid>
		<description><![CDATA[After working on a fairly simple upload from Flex to Amazon S3, a co-worker claimed it was "done". Ok. Then I tried uploading from from my mac. No dice. So this simple upload went from being "done" to "a significant OS X pain." Here are some of the things that helped. After much googling, Wiresharking, [...]]]></description>
			<content:encoded><![CDATA[<p>After working on a fairly simple upload from Flex to Amazon S3, a co-worker claimed it was "done". Ok.  Then I tried uploading from from my mac.  No dice. So this simple upload went from being "done" to "a significant OS X pain."  Here are some of the things that helped.</p>
<p>After much googling, Wiresharking, and general debuggation, a co-worker found <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/HTTPPOSTFlash.html">this Amazon S3 doc</a>, which notes:</p>
<blockquote><p>
Some versions of the Adobe Flash Player do not properly handle HTTP responses that have an empty body. To configure POST to return a response that does not have an empty body, set success_action_status to 201. When set, Amazon S3 returns an XML document with a 201 status code. For information on the content of the XML document, see ???. For information on form fields, see HTML Form Fields.
</p></blockquote>
<p>Interesting. And small; it is a tiny message, almost a footnote, on some Amazon page. I wish Adobe could get their docs together.  I particularly like "Some versions" and "???".  Anyway, lesson learned, or at least we have something to try.</p>
<h3>The S3/Flash interactions need a little massaging</h3>
<p>It seems like the OS X Flash runtime (9.0.115.0) requires a non-empty server response from its POST.  Amazon S3 conveniently has an additional parameter, <code>success_action_status</code> which can be set to "201" to have S3 respond to the post with a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">201 CREATED response code</a>.  If you are uploading to Apache or IIS, you could have the same problem.  Try to check the header response for your POST, and see it is is a) empty, or b) not a 201.</p>
<p>On S3, you can modify your upload policy to return the correct response.  Your policy should look something like this:</p>
<pre>
{
    'expiration': '2008-12-31T12:00:00.000Z',
    'conditions': [
        {'bucket': 'my_test_bucket'},
        {'key': 'test1.jpg'},
        ['starts-with', '$Filename', ''],
        ['eq', '$success_action_status', '201']
    ]
}
</pre>
<p>Note that the <code>success_action_status</code> is not an object property, but an [Operator, Operand, Operand] array.</p>
<p>Problem Solved?  Not quite: still not uploads.</p>
<h3>S3 Upload Example</h3>
<p>Someone at AWS posted a helpful <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1092">Flex -> S3 example</a>, or actually examples.  One Flex project creates and signs a policy, and the other uploads a file using the generated policy.  And whats more, they both work.  Also, took a look at the code to make sure it wasn't sending my AWS key/password off to some email! Ha. I think it was also posted by an AWS employee, so that is reassuring.</p>
<h3>#2038 FileIOError </h3>
<p>I kept getting a #2038 FileIOError on my mac.  Bummer. Taking a closer look at the working AWS example, I saw a funny comment.  Not funny roflcopter, but funny smelly bug-fixy.</p>
<pre>

            /*
             * FileReference.upload likes to send cryptic IOErrors when it doesn't get a status code that it likes.
             * If we already got an error HTTP status code, don't propagate this event since the HTTPStatusEvent
             * event handler dispatches an IOErrorEvent.
             */
</pre>
<p>As it turns out, I could NOT stop these #2038 FIleIOErrors.  They just kept coming. But, as the example code reminded me, if you are getting a successful server response, the file is already up there.  Sure enough, the file was there.</p>
<p>So you can pretty much ignore the FileIOError, although you should handle it, and just ignore it if you have a successful HTTP response, something like this:</p>
<pre>
        private function onIOError(event:IOErrorEvent):void
        {
            if(!recievedSuccessfulHTTPresponse)
            {
                this.dispatchEvent(event);
            }
        }
</pre>
<p>You get the idea.  Ok. Handle but ignore FileIOErrors. Done? Almost. Single uploads work, but I get an  "Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error" when doing multiple uploads, via a FileReferenceList.  Marvelous.  This turned out to be even more of a pain.  It wasn't anything to do with <a href="http://www.judahfrangipane.com/blog/?p=115">the server side upload script</a> as my google searches might have me believe.</p>
<p>After brainstorming with a co-worker, we came to a pretty good guess: Garbage Collection.  Maybe the FileReference was going out of scope before the IOError could be handled, or some such.  PC/OS X differences in the runtime could have different GC implementations.  Worth a shot.  I changed my event listeners from "weak" to "strong" references.  Shahooya.  Multiple file upload city. </p>
<h3>Other fixes</h3>
<p>Make sure you have a publicly accessable crossdomain policy on the server you are uploading to.</p>
<p>Also, S3 scales well but adds extra complexity. You might try uploading to somewhere else, like a simple rails uploader.</p>
<p>Hope that helps.  Also, please comment.  In fact, today only, every commenter gets a free XBox.  You know, its just a little lonely out here in the cloud sometimes.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.nuclearrooster.com/2008/04/05/uploading-with-a-filereference-from-flex-3-on-os-x/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
