<?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>DEfusion.org.uk &#187; Flex</title>
	<atom:link href="http://www.defusion.org.uk/archives/category/web-development/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.defusion.org.uk</link>
	<description>I too will force my opinions on you</description>
	<lastBuildDate>Mon, 04 Jul 2011 19:28:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Uploading Files and Images With Flex and Rails</title>
		<link>http://www.defusion.org.uk/archives/2008/04/21/uploading-files-and-images-with-flex-and-rails/</link>
		<comments>http://www.defusion.org.uk/archives/2008/04/21/uploading-files-and-images-with-flex-and-rails/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 21:23:58 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2008/04/21/uploading-files-and-images-with-flex-and-rails/</guid>
		<description><![CDATA[Having spent most of Saturday trying to get files to upload from a Flex application to a Rails backend, fighting against both Flex and Rails all the way, I thought I&#8217;d collect together some of the things that have helped me work through this in the hope that others don&#8217;t have to spend quite as [...]]]></description>
			<content:encoded><![CDATA[<p>Having spent most of Saturday trying to get files to upload from a Flex application to a Rails backend, fighting against both Flex and Rails all the way, I thought I&#8217;d collect together some of the things that have helped me work through this in the hope that others don&#8217;t have to spend quite as long battling through this. Note however that these are not necessarily best pratices, more a collection of tips that helped me in my situation, there are probably better ways to do some or all of the things that I&#8217;ll be writing about &#8211; and if you know of any improvements/alternatives I&#8217;d love to hear about them.<br />
<span id="more-165"></span><br />
In my situation I am uploading images to Rails which is using attachment_fu to handle the images and the thumbnail generation. Some of these tips will be relevant to all more generic issues, such as uploading files from Flex, and some will be more specific, such as making attachment_fu work with images uploaded from Flex.</p>
<p><strong>Uploading files with Flex</strong><br />
To upload files with flex you need to use either the <a href="<br />
http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html&#8221;>FileReference</a> or <a href="http://livedocs.adobe.com/flex/3/langref/flash/net/FileReferenceList.html">FileReferenceList</a> classes, the main difference between these two is that FileReference is for uploading single files and FileReferenceList allows multiple file uploads.</p>
<h2>Issue 1: How to send other data, such as meta/model data with the file upload:</h2>
<p>Say you want to upload an image and save that using Rails along with other model data for that image (such as a title etc.) then you&#8217;ll have to hack that into the request that FileReference sends. </p>
<p><a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=5534a12f&#038;sliceId=1">This Adobe tech note</a> recommends using the <span class="code">uploadDataFieldName</span> argument of the <span class="code">upload()</span> method, however to me this seems like a really awful hack as you&#8217;ll then have to parse the name/value pair string in your <span class="code">uploadDataFieldName</span> param at the backend. What you really want is separate parameters (ideally within the POST body).</p>
<p>The only viable solution I could come across was using the query string to pass the parameters through, your mileage may vary on this depending on the parameters you are sending, but I&#8217;m pretty sure that no modern browsers enforce the 255 character limit on a <acronym title="Uniform Resource Locator">URL</acronym> anymore.</p>
<h2>Issue 2: Session cookie not sent in Firefox:</h2>
<p>This problem is <a href="http://thanksmister.com/?p=59">explained really well over at Thanks Mister!</a>, it may apply to other browsers (probably the other gecko-based browsers work the same) but quite simply it means that if you&#8217;re relying on some data in your session during the upload you need to manually pass the session cookie through, however this raises further issues with Rails, so I&#8217;ll break it down further.</p>
<p><strong>Issue 2: Part 1 &#8212; Passing the cookie when uploading files with FileReference:</strong><br />
It&#8217;s fairly simple to get around this part of the problem, you just need to include your session identifier within the query string, the biggest issue with this is getting the cookie value &#8212; as Flash doesn&#8217;t have native access to the browsers cookies.<br />
To get the cookie you&#8217;ll need to use the <a href="http://livedocs.adobe.com/flex/3/langref/flash/external/ExternalInterface.html">ExternalInterface</a> to call some JavaScript to retrieve the cookie, this is <a href="http://www.restlessthinker.com/blog/?p=39">covered quite nicely in this post</a>. So when working with Rails we just need to retrieve the cookie that lives in whatever we&#8217;re using as the session ID and pass that through via the query string, but that brings us to another problem:</p>
<p><strong>Issue 2: Part 2 &#8212; Rails won&#8217;t let you pass session ids in the query string:</strong><br />
So now we need to tweak Rails to let us pass the session id via the query string, luckily there is <a href="http://blog.inquirylabs.com/2006/12/09/getting-the-_session_id-from-swfupload/">another great post on this</a>, however some of the Rails 2 security improvements require further workarounds which are in the comments on that post.</p>
<p>To quickly cover what you need to do is as follows:</p>
<ol>
<li>Add the patch (make sure you get the one for Mongrel/Apache linked at the bottom of the <a href="http://blog.inquirylabs.com/2006/12/09/getting-the-_session_id-from-swfupload/">post</a>) to the <span class="code">CGI::Session</span> class to your application &#8212; it really deserves to live in a plugin rather than the environment.rb file, which you&#8217;ll have to roll yourself.</li>
<li>For Rails 2 you have to add another override by adding <span class="code">session :cookie_only => false</span> at the controller level. I personally feel it is best to do this in just the controller that you&#8217;re using to upload the files with.</li>
<li>I still had issues with it not picking up my session &#8212; I was using the Rails 2 default of saving the session information in the cookie. There is probably another hack or change that I could make to get around this, but I chose to move (back to) Active Record sessions but this time using the <a href="http://blog.kovyrin.net/2008/02/06/fastsessions-rails-plugin-released/">Fast Sessions</a> plugin for a bit of a performance boost.
<p>I&#8217;ll probably look into this again at a later date, but right now I just wanted to get this part working and move on.
</li>
</ol>
<p>So now we&#8217;ve got our file uploading to the backend, within our session and our other model/meta data being sent as well. &#8220;Great we&#8217;re done, what else could go wrong now?&#8221; is just the kind of thought you&#8217;d be forgiven for having. Of course there was another issue that came up which needed to be handled.</p>
<h2>Issue 3: Attachment_fu and Flex file uploads</h2>
<p>FileReference uploads all files with the MIME type of <span class="code">application/octet-stream</span> which gives us a couple of problems:</p>
<ol>
<li>Your attachment_fu <span class="code">content-type</span> filter will probably reject all uploads out of hand &#8211; the easy hack would seem to be to add in the <span class="code">application/octet-stream</span> to your acceptable content-types, but that&#8217;s an awful hack that basically removes the content-type filtering and doesn&#8217;t address our second issue.</li>
<li>If using attachment_fu to create thumbnails and you do accept the <span class="code">application/octet-stream</span> MIME then you won&#8217;t have any thumbnails generated, because as far as attachment_fu is concerned your upload is not an image.</li>
</ol>
<p>Again the solution was only a few searches away, and the changes covered in <a href="http://blog.vixiom.com/2007/12/28/hacking-attachment_fu-to-work-with-flashflex-uploads-and-crop-square-images/">this post over at Vixiom Axioms</a> do fix the issue &#8212; although note that I had issues with that fix and had to apply my own changes &#8211; see the comment on that post.</p>
<h2>Conclusion</h2>
<p>So finally we have file uploads working from Flex to Rails, our session information is maintained, we&#8217;re passing along our model data and our images are being handled as they are supposed to.</p>
<p>This really shouldn&#8217;t have been this difficult, it should have been a simple case of using FileReference add some data to be POSTed and we&#8217;d be done but alas decisions made in/or issues with the Flash player lead to this merry dance of hacks, tweaks and workarounds to make everything sing to the same hymn-sheet.</p>
<p>Hopefully covering this and collecting together these links will save someone else from a wasted day of figuring out the solution to the myriad of problems that I encountered.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2008/04/21/uploading-files-and-images-with-flex-and-rails/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Code Update: FlexUnit Custom Test Runner v 0.2.0</title>
		<link>http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/</link>
		<comments>http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 18:35:08 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/</guid>
		<description><![CDATA[I&#8217;ve been doing quite a bit of unit testing on the Flex part of our new product lately and this has led me to fix a few issues and add some improvements to my FlexUnit Test Runner, I&#8217;ve been running with these fixes and improvements for a couple of weeks and finally took some time [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing quite a bit of unit testing on the Flex part of our new product lately and this has led me to fix a few issues and add some improvements to my <a href="/code/flexunit-custom-test-runner/">FlexUnit Test Runner</a>, I&#8217;ve been running with these fixes and improvements for a couple of weeks and finally took some time out yesterday evening to package them up so I could release them.</p>
<p>The key changes are:</p>
<ul>
<li>Release has two downloads &#8211; one compiled to Flex 2.0.1 and one to Flex 3 &#8211; as it appears changes to Flex internals meant you couldn&#8217;t use the Flex 2.0.1 compiled swc in a Flex 3 project.</li>
<li>Fixed: Issue where error thrown when no test results selected.</li>
<li>Fixed: Issue where resizing columns could cause the itemRenderer for the status to display horizontal scrollbar.</li>
<li>Added: Ability to choose whether to display test results live or wait until all tests complete (as displaying them live results in slower execution of tests, as it&#8217;s constantly updating the UI) &#8211; this is saved as a preference.</li>
<li>Added: Ability to toggle display of the class path for the test case &#8211; this is saved as a preference.</li>
<li>Added: Test result details now extract Expected &#038; Was from message string for failures and display in a manner that is easier to compare.</li>
<li>Changed: Test details now displayed on change rather than click event, to allow keyboard navigation of test results.</li>
</ul>
<p>Head over to the <a href="/code/flexunit-custom-test-runner/">FlexUnit Test Runner code page</a> for all the downloads and to see the updated demo.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Tip: Custom Component Not Lining Up With Label In Form Item?</title>
		<link>http://www.defusion.org.uk/archives/2007/11/26/flex-tip-custom-component-not-lining-up-with-label-in-form-item/</link>
		<comments>http://www.defusion.org.uk/archives/2007/11/26/flex-tip-custom-component-not-lining-up-with-label-in-form-item/#comments</comments>
		<pubDate>Mon, 26 Nov 2007 18:53:13 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/11/26/flex-tip-custom-component-not-lining-up-with-label-in-form-item/</guid>
		<description><![CDATA[Recently I was creating a set of in place editor custom components for our project at work and I noticed that when I placed them inside a FormItem that they didn't line up with the label of the FormItem. I left it when I first noticed it as I didn't have time to fix the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was creating a set of in place editor custom components for our project at work and I noticed that when I placed them inside a <a href="http://livedocs.adobe.com/flex/2/langref/mx/containers/FormItem.html"><span class="code">FormItem</span></a> that they didn't line up with the label of the <span class="code">FormItem</span>. I left it when I first noticed it as I didn't have time to fix the issue but when I returned to it I had to do plenty of digging to figure out the problem.<br />
<span id="more-151"></span><br />
My custom component consisted of (in it's default state) something like the following:</p>
<div class="igBar"><span id="lmxml-3"><a href="#" onclick="javascript:showPlainTxt('mxml-3'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-3">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span> verticalAlign=<span style="color: #ff0000;">"middle"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> id=<span style="color: #ff0000;">"textValue"</span> text=<span style="color: #ff0000;">"{this.textValue}"</span> ... <span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I was using the <a href="http://livedocs.adobe.com/flex/2/langref/mx/containers/HBox.html"><span class="code">HBox</span></a> as a wrapper as I wanted to be able to add other contents in there, such as and edit button and the actual editor and keep it all on one line.</p>
<p>Everything was working as expected, except for the fact that the <span class="code">FormItem</span>label would not line up with the text in the <span class="code">textValue</span>, I considered hacking it by adding some padding but decided to dig through the framework to figure out what was going on.</p>
<p>After lots of digging I found this in the <span class="code">FormItem</span>:</p>
<div class="igBar"><span id="lactionscript-4"><a href="#" onclick="javascript:showPlainTxt('actionscript-4'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-4">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>labelObj<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>n&gt; <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Center label with first child</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; child = IUIComponent<span style="color: #66cc66;">&#40;</span>getChildAt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; childBaseline = child.<span style="color: #006600;">baselinePosition</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>childBaseline<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;y += childBaseline - labelObj.<span style="color: #006600;">baselinePosition</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Set label size.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// snip ...</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So I did some investigating on my custom component and sure enough it didn't have a <span class="code">baselinePosition</span>, which didn't make too much sense too me. So I started paring down the component until it centred with the label, it turned out that setting the <span class="code">verticalAlign</span> property on the <span class="code">HBox</span> was the cause of it not having a <span class="code">baselinePosition</span> (I didn't dig into the reason why this was so).</p>
<p>So the moral of this tale is if you find your custom component doesn't line up with the label of a <span class="code">FormItem</span> check your component has a <span class="code">baselinePosition</span>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/11/26/flex-tip-custom-component-not-lining-up-with-label-in-form-item/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Link: Flex Creating Custom Components</title>
		<link>http://www.defusion.org.uk/archives/2007/11/25/quick-link-flex-creating-custom-components/</link>
		<comments>http://www.defusion.org.uk/archives/2007/11/25/quick-link-flex-creating-custom-components/#comments</comments>
		<pubDate>Sun, 25 Nov 2007 13:31:23 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/11/25/quick-link-flex-creating-custom-components/</guid>
		<description><![CDATA[A couple of weeks ago I was looking for some more examples of using the measure()  method in one of my custom Flex components and I found this series of excellent tutorials of how to create a custom component by Peter Ent:

Component Class - Part One
Component Class - Part Two
Component Class - Part Three
Component [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I was looking for some <a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&#038;file=ascomponents_advanced_148_13.html">more</a> examples of using the <a href="http://livedocs.macromedia.com/flex/201/langref/mx/core/UIComponent.html#measure()"><span class="code">measure()</span></a>  method in one of my custom Flex components and I found this series of excellent tutorials of how to create a custom component by <a href="http://weblogs.macromedia.com/pent/">Peter Ent</a>:</p>
<ul>
<li><a href="http://weblogs.macromedia.com/pent/archives/2007/10/component_class.cfm">Component Class - Part One</a></li>
<li><a href="http://weblogs.macromedia.com/pent/archives/2007/10/component_class_1.cfm">Component Class - Part Two</a></li>
<li><a href="http://weblogs.macromedia.com/pent/archives/2007/10/component_class_2.cfm">Component Class - Part Three</a></li>
<li><a href="http://weblogs.macromedia.com/pent/archives/2007/10/component_class_3.cfm">Component Class - Part Four</a></li>
<li><a href="http://weblogs.macromedia.com/pent/archives/2007/12/component_class_4.cfm">Component Class - Part Five(Skins vs Styles)</a>
</ul>
<p><span id="more-152"></span><br />
This series takes you through creating a custom component in Flex with actionscript and he takes you through all the possible options (from extending an existing component from the Flex framework to starting with a clean slate by extending the <a href="http://livedocs.macromedia.com/flex/201/langref/mx/core/UIComponent.html><span class="code">UIComponent</span></a>.)</p>
<p>As I'm still fairly new to Flex reading this exposed some new areas of Flex components to me, such as the <a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&#038;file=ascomponents_advanced_148_12.html"><span class="code">commitProperties()</span></a> and <a href="http://livedocs.adobe.com/flex/201/langref/mx/core/UIComponent.html#invalidateProperties()"><span class="code">invalidateProperties()</span></a> methods and also gave me more insight into the <a href="http://livedocs.adobe.com/flex/201/langref/mx/core/UIComponent.html#updateDisplayList()"><span class="code">updateDisplayList()</span></a> method. </p>
<p>This weekend I have been getting dirty at a low level with Flex creating some really customised components (and my first programmatic skins - which are really great to use once you get one under your belt) for a personal project and if I hadn't have read this series it wouldn't have half as easy as it has been. </p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/11/25/quick-link-flex-creating-custom-components/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Code: FlexUnit Custom Test Runner</title>
		<link>http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/</link>
		<comments>http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 22:09:32 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/</guid>
		<description><![CDATA[The FlexUnit Custom Test Runner is a customised FlexUnit test runner which aims to improve the presentation and ease of use of running FlexUnit tests.
I have used unit testing in a few different languages, so obviously when I started using Flex I wanted to start off on the right foot by using unit testing from [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.defusion.org.uk/code/flexunit-custom-test-runner/">FlexUnit Custom Test Runner</a> is a customised FlexUnit test runner which aims to improve the presentation and ease of use of running <a href="http://code.google.com/p/as3flexunitlib/">FlexUnit</a> tests.</p>
<p>I have used unit testing in a few different languages, so obviously when I started using Flex I wanted to start off on the right foot by using unit testing from the outset. However after a couple of days using the base runner which is provided with FlexUnit I found myself spending a lot more time than I thought I should just looking for the details of the problem in the flex runner.</p>
<p>So as usual I attempted to make something that would work a little better for my requirements, see the <a href="http://www.defusion.org.uk/code/flexunit-custom-test-runner/">FlexUnit Custom Test Runner code page</a> find the full details and the download. As usual any comments should be made on the <a href="http://www.defusion.org.uk/code/flexunit-custom-test-runner/">code page</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code: FoxyComboBox for Flex</title>
		<link>http://www.defusion.org.uk/archives/2007/10/16/code-foxycombobox-for-flex/</link>
		<comments>http://www.defusion.org.uk/archives/2007/10/16/code-foxycombobox-for-flex/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 20:28:36 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/10/16/code-foxycombobox-for-flex/</guid>
		<description><![CDATA[Towards the end of last week I spent quite a lot of time working with customisations of the ComboBox in Flex 2 for work, and it was really beginning to bug me how when I typed to select an item, the selection was only ever the first item that matched the letter I was typing. [...]]]></description>
			<content:encoded><![CDATA[<p>Towards the end of last week I spent quite a lot of time working with customisations of the <a href="http://livedocs.adobe.com/flex/2/langref/mx/controls/ComboBox.html"><span class="code">ComboBox</a></a> in <a href="http://www.adobe.com/products/flex/">Flex 2</a> for work, and it was really beginning to bug me how when I typed to select an item, the selection was only ever the first item that matched the letter I was typing. Having had it become second nature, since it's a feature of my browser of choice <a href="http://www.getfirefox.com/">Firefox</a>, that I can type the beginning of a word to jump to an option (e.g. &quot;United K&quot; to jump to &quot;United Kingdom&quot; in a list of countries) I now really missed it when using Flex.</p>
<p>I didn't have time to look at a work around during work hours as it really isn't a feature that is needed of our product, just something that annoyed me. So I decided that I would quickly knock a solution together at the weekend and then write up a short post of how it was done, in case other people wanted to find out how to do it. </p>
<p>However it didn't quite work out that way. </p>
<p>After a few frustrating hours I managed to get a fully working solution which I thought I'd share. You can read on for the story behind the component, or you can head straight to the <a href="/code/foxycombobox-for-flex/">FoxyComboBox code page</a> to view the results.<br />
<span id="more-146"></span><br />
So I sat down late Saturday afternoon and started poking through the source code for the ComboBox and its related classes (god bless Adobe for providing the source). I noticed that the <a href="http://livedocs.macromedia.com/flex/2/langref/mx/controls/listClasses/ListBase.html"><span class="code">listBase</span></a> class (which the <span class="code">ComboBox</span> uses for its drop down) has a method in there already to find an option by string, &quot;fantastic this will be a doddle&quot;, I thought.</p>
<p>So I figured all I needed was to created an new <a href="http://livedocs.adobe.com/flex/2/langref/mx/controls/List.html"><span class="code">List</span></a> which overrode the <span class="code">keyDownHandler</span> so we could build up a string to use as the search criteria (and reset it during a period of typing in-activity). Then it would be a simple case of using the new <span class="code">List</span> as the <span class="code">dropDownFactory</span> by extending the <span class="code">ComboBox</span>.</p>
<p>That took a while to figure out after looking through the source code, but not that long to implement - and it worked, <em>except</em> for one problem: it only worked while the <span class="code">ComboBox</span> option list was open.</p>
<p>This didn't make much sense, a bit of debugging and a lot of &quot;Huh, why would it do that?&quot;, it seems the <span class="code">ComboBox</span> gets a new drop down every time we try and change the selected index, <strong>unless</strong> the user has opened the drop down and selected an item. This wasn't going to work.</p>
<p>So my next attempt was to turn it on it's head, make the <span class="code">ComboBox</span> the controller for this functionality, this isn't the best solution (in my opinion) but it was the only workable one I could think of.</p>
<p>A bit of refactoring later it worked, <em>except</em> now whenever the drop down was open and the user typed it would close as soon as we changed the selected index. This made no sense, the normal <span class="code">ComboBox</span> wasn't doing this and I was calling the same <span class="code">findByString()</span> method to select the item. I spent a bit more time digging through the source code and in the debugger trying figure out where it was being closed and why.</p>
<p>It turned out (and I had seen this earlier but glossed over it) that the <span class="code">keyDownHandler()</span> in the <span class="code">ComboBox</span> was setting a private property called <span class="code">bInKeyDown</span> which if true stopped the <span class="code">dropdown_changeHandler()</span> method from closing the drop down. Phew, that was a whistle stop tour of the inner workings of the <span class="code">ComboBox</span>, hope you're still following along.</p>
<p>So I had to hack around further to emulate this functionality in as clean a way as possible in my custom <span class="code">ComboBox</span>, as <span class="code">bInKeyDown</span> is private. I did something very similar, but made my variable a bit more generic and protected rather than private - just in case I want to extend the FoxyComboBox later.</p>
<p>A bit of refactoring later it <strong>worked</strong>. </p>
<p>So what I thought would be a quick half an hour job turned out to be about 4 1/2 hours work and a new code release from me (as I don't want anyone else to have to suffer with this issue, either the end users of Flex or a developer digging through the <span class="code">ComboBox</span>to make a custom version with this functionality).</p>
<p>So if this is something you wish your Flex application could do, you can grab it now, I called it the <a href="/code/foxycombobox-for-flex">FoxyComboBox</a> (not very inspired, but my brain was a little fried by the end of it). </p>
<p>p.s. Those of you who have downloaded something of mine before will notice I've introduced a download page where I ask for a tip and give a suggested amount. In the case of the <a href="/code/foxycombobox-for-flex/">FoxyComboBox</a> that is a measly $2, so I ask if you download it and find it useful please consider if saving yourself a few hours of time is worth $2, or maybe more :). Okay, that's the begging over with, enjoy.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/10/16/code-foxycombobox-for-flex/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Code: MXML GeSHi Language File</title>
		<link>http://www.defusion.org.uk/archives/2007/10/04/code-mxml-geshi-language-file/</link>
		<comments>http://www.defusion.org.uk/archives/2007/10/04/code-mxml-geshi-language-file/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 22:57:02 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/10/04/code-mxml-geshi-language-file/</guid>
		<description><![CDATA[While just writing my first post about Flex which required some code examples in MXML, I found that currently GeSHi (Generic Syntax Highlighter) doesn't have a MXML language file, and I couldn't find one when I did a few searches.
So using the XML language file as a base I quickly knocked one together.]]></description>
			<content:encoded><![CDATA[<p>While just writing <a href="/archives/2007/10/04/flex-tip-be-careful-with-your-names/">my first post about Flex</a> which required some code examples in MXML, I found that currently <a href="http://qbnz.com/highlighter/">GeSHi</a> (Generic Syntax Highlighter) doesn't have a MXML language file, and I couldn't find one when I did a few searches.</p>
<p>So using the <acronym title="eXtensible Markup Language">XML</acronym> language file as a base I quickly <a href="/code/mxml-geshi-language-file/">knocked one together</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/10/04/code-mxml-geshi-language-file/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flex Tip: Be Careful With Your Names</title>
		<link>http://www.defusion.org.uk/archives/2007/10/04/flex-tip-be-careful-with-your-names/</link>
		<comments>http://www.defusion.org.uk/archives/2007/10/04/flex-tip-be-careful-with-your-names/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 22:34:59 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/10/04/flex-tip-be-careful-with-your-names/</guid>
		<description><![CDATA[Firstly, I know I've been very quiet recently, that's because a lot has happened recently - which I'll go into in more detail at another time. The upshot of these changes is I'm now working with Flex quite heavily (YAY!), hence the Flex Tip post.
So what do I mean about being careful with your names, [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly, I know I've been very quiet recently, that's because a lot has happened recently - which I'll go into in more detail at another time. The upshot of these changes is I'm now working with <a href="http://www.adobe.com/products/flex/">Flex</a> quite heavily (YAY!), hence the Flex Tip post.</p>
<p>So what do I mean about being careful with your names, well today I had the following:</p>
<div class="igBar"><span id="lmxml-7"><a href="#" onclick="javascript:showPlainTxt('mxml-7'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-7">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;testHelper:FunctionalTestHelper</span> id=<span style="color: #ff0000;">"testHelper"</span> testSteps=<span style="color: #ff0000;">"{testSteps}"</span> <span style="color: #7400FF;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Which seems reasonable enough, however the compiler hated it, throwing me a <a href="http://livedocs.adobe.com/flex/201/langref/compilerErrors.html#1202">1202 error</a> of &quot;Access of undefined property testSteps in package testHelper.&quot;.<br />
<span id="more-139"></span><br />
This seemed odd, the <span class="code">testSteps</span> property definitely was defined, although I triple checked and recompiled, I tried new properties which all did the same thing. The one thing I did find that worked was the following:</p>
<div class="igBar"><span id="lmxml-8"><a href="#" onclick="javascript:showPlainTxt('mxml-8'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-8">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;testHelper:FunctionalTestHelper</span> id=<span style="color: #ff0000;">"testHelper"</span> testSteps=<span style="color: #ff0000;">"new Array();"</span> <span style="color: #7400FF;">/&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This makes no sense, the compiler was telling me earlier that <span class="code">testSteps</span> was not a property now it's happy, I tried playing around with my binded variable <span class="code">testSteps</span> and declaring new variables (bindable and non-bindable) all to no avail.</p>
<p>I was at a loss, then I noticed that the <span class="code">id</span> of the instance I'd created (<span class="code">testHelper</span>) was the same as the package name that component lived in. Once I changed that everything compiled as expected.</p>
<p>This isn't the first time I've come across strangeness with naming in Flex, I suppose it makes some sense (although I'm not clear on why it only crapped out when using a bindable variable for one of the properties.</p>
<p>All-in-all I lost about 30 minutes to this issue so I thought it would be wise to share this to hopefully save others from the same issue.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/10/04/flex-tip-be-careful-with-your-names/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interview on Web Wire</title>
		<link>http://www.defusion.org.uk/archives/2006/08/05/interview-on-web-wire/</link>
		<comments>http://www.defusion.org.uk/archives/2006/08/05/interview-on-web-wire/#comments</comments>
		<pubDate>Sat, 05 Aug 2006 13:38:38 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Outer Monologue]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2006/08/05/interview-on-web-wire/</guid>
		<description><![CDATA[I was notified yesterday by a friend of mine Martin Laine that Ben Forta had blogged about a interview with me on Web Wire.
First of all, wow, Ben Forta - so it was just a passing mention, but for anyone working in the CF or Flex development fields Ben Forta is a very important and [...]]]></description>
			<content:encoded><![CDATA[<p>I was <a href="http://www.1pixelout.net/2006/08/04/dave-spurr-interview-on-webwire/">notified</a> yesterday by a friend of mine <a href="http://www.1pixelout.net/">Martin Laine</a> that <a href="http://www.forta.com/blog/">Ben Forta</a> had <a href="http://www.forta.com/blog/index.cfm/2006/8/3/Superbreak-Powered-By-ColdFusion">blogged</a> about a <a href="http://webwire.com/ViewPressRel.asp?aId=17886">interview with me on Web Wire</a>.</p>
<p>First of all, wow, Ben Forta - so it was just a passing mention, but for anyone working in the CF or Flex development fields Ben Forta is a very important and influential figure. Secondly, I still find it amazing how quickly the web moves, I received the final copy of the interview copy in my inbox on Thursday afternoon and by Friday morning it had been picked up by Ben Forta and relayed to myself via Martin.</p>
<p>Finally the interview on Web Wire appears to have been edited a little, I'll try and get my hands on the original and post it here.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2006/08/05/interview-on-web-wire/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Well Flex Me</title>
		<link>http://www.defusion.org.uk/archives/2006/04/28/well-flex-me/</link>
		<comments>http://www.defusion.org.uk/archives/2006/04/28/well-flex-me/#comments</comments>
		<pubDate>Fri, 28 Apr 2006 21:47:44 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Outer Monologue]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2006/04/28/well-flex-me/</guid>
		<description><![CDATA[A couple of weekends ago I took my first real look at Flex 2.0 Beta. To say that I loved it is an understatement, I've even added a Flex category to my site in anticipation of many future posts about it. 
I simply spent the weekend watching the demo videos &#038; running through all of [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weekends ago I took my first real look at <a href="http://labs.macromedia.com/flexproductline/">Flex 2.0 Beta</a>. To say that I loved it is an understatement, I've even added a <a href="/archives/category/web-development/flex/">Flex category</a> to my site in anticipation of many future posts about it. </p>
<p>I simply spent the weekend watching the demo videos &#038; running through all of the tutorials and then started to play around with the <a href="http://labs.macromedia.com/wiki/index.php/ColdFusion/Flex_Connectivity">Coldfusion/Flex connectivity</a> and believe I grasped a large amount of how to work with Flex 2.0 within that time.<br />
<span id="more-49"></span><br />
I had looked at the Flex 1.5 examples previously but never took a look at their implementation, I understand that there have been substantial changes between 1.5 &#038; 2.0 and the <a href="http://labs.macromedia.com/wiki/index.php/Flex_Builder">Flex Builder</a> alone is a beautiful example of the power of the <a href="http://www.eclipse.org/">Eclipse IDE</a>.</p>
<p>The power and simplicity of Flex itself is outstanding and I have 3 areas in mind at work where we could take advantage of Flex, combined with our existing Coldfusion domain models, and really see the benefits shine. Indeed I spent the following few days in work gushing about Flex 2.0 and all of it's benefits, which luckily was contagious with my colleagues, I guess this post is simply a continuation of that.</p>
<p>All I can say is I can't wait to get my hands on it for a full project, the potential of using Flex for a certain project that I have previously been apprehensive about has actually made me really excited about it.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2006/04/28/well-flex-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

