<?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; Code</title>
	<atom:link href="http://www.defusion.org.uk/archives/category/code/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>Update : JavaScript Image Cropper UI using Prototype v 1.2.1</title>
		<link>http://www.defusion.org.uk/archives/2009/10/06/update-javascript-image-cropper-ui-using-prototype-v-121/</link>
		<comments>http://www.defusion.org.uk/archives/2009/10/06/update-javascript-image-cropper-ui-using-prototype-v-121/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 19:45:16 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2009/10/06/update-javascript-image-cropper-ui-using-prototype-v-121/</guid>
		<description><![CDATA[It&#8217;s been a long time since I released an update to the JavaScript Image Cropper UI (for reference v1.2.0 was released on 30th Oct 2006!).
However it is still going strong and a couple of things prompted me to release this update to bring it to v1.2.1.
The first thing was Tom Hirashima (sorry Tom, wasn&#8217;t sure [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since I released an update to the <a href="/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI</a> (for reference v1.2.0 was released on 30th Oct 2006!).</p>
<p>However it is still going strong and a couple of things prompted me to release this update to bring it to v1.2.1.</p>
<p>The first thing was <a href="http://straightnochaser.org/">Tom Hirashima</a> <del datetime="2009-10-06T22:52:08+00:00">(sorry Tom, wasn&#8217;t sure if you have a site you want me to link to)</del> sent me an email last week with an update to the code to allow it to work with the latest versions of Prototype &#038; script.aculo.us out of the box (1.6.1.0 &#038; 1.8.2 respectively). Although the last time I tried the cropper with the latest versions of them both it worked fine, you just had to change the bundles that script.aculo.us included, Tom has made some further changes. This is a good thing as for the past couple of years I&#8217;ve pretty much been out of the prototype &#038; script.aculo.us loop having moved to MooTools and now jQuery (which I hated at first, but that&#8217;s another story).</p>
<p>The second thing was that the cropper was mentioned (and my how old does this site design look to me now) in the latest (and as usual excellent) <a href="http://railscasts.com/">Railscast</a>, <a href="http://railscasts.com/episodes/182-cropping-images">Cropping Images</a>.</p>
<p>As a part of integrating Tom&#8217;s changes I decided to tackle a load of bugs from the bug list to try and reduce the list so I can keep on top of it better going forward (a long list of open bugs is never conducive to getting any of them fixed).<br />
<span id="more-197"></span><br />
Here&#8217;s a full list of the changes:</p>
<ul>
<li>Added support for latest versions of Prototype &#038; script.aculo.us (1.6.1.0 &#038; 1.8.2 respectively). Changes provided by Tom Hirashima.</li>
<li>No-longer package prototype &#038; script.aculo.us with the release</li>
<li>Changed tests to use google ajax libraries <acronym title="Application Programming Interface">API</acronym> to load prototype &#038; script.aculo.us</li>
<li>Added option to not auto include the cropper <acronym title="Cascading Style Sheets">CSS</acronym> file</li>
<li><span class="code">#00008</span> &#8211; Fixed bug: Dynamic include of cropper <acronym title="Cascading Style Sheets">CSS</acronym> expected cropper.js and failed when using cropper.uncompressed.js</li>
<li><span class="code">#00028</span> &#8211; Fixed bug: Doesn&#8217;t work with latest script.aculo.us &#8211; Fix by Tom Hirashima</li>
<li><span class="code">#00030</span> &#8211; Fixed bug: Doesn&#8217;t work in Firefox 3.5 (<acronym title="Cascading Style Sheets">CSS</acronym> include issue)</li>
<li><span class="code">#00007</span> &#8211; Fixed bug: onEndCrop isn&#8217;t called when moving with keys</li>
<li><span class="code">#00011</span> &#8211; Fixed bug: The image that is to be cropped does not show in IE6.0 &#8212; included <acronym title="Cascading Style Sheets">CSS</acronym> fix</li>
<li>Tidied up source code &#038; fixed issues that jslint found so it will compress better</li>
</ul>
<p>Finally as usual, please use the bug reporting link or discussion list mentioned on <a href="/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI code page</a> rather than leaving comments to report bugs.</p>
<p>Head over to the <a href="/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI code page</a> for download and documentation.
<p><strong><em>Advertisement</em></strong>:  <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI</a><em> </em>Download my feature-rich JavaScript Image Cropper.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2009/10/06/update-javascript-image-cropper-ui-using-prototype-v-121/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Coding Clarity Over Cleverness</title>
		<link>http://www.defusion.org.uk/archives/2008/10/14/coding-clarity-over-cleverness/</link>
		<comments>http://www.defusion.org.uk/archives/2008/10/14/coding-clarity-over-cleverness/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 20:02:29 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Outer Monologue]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2008/10/14/coding-clarity-over-cleverness/</guid>
		<description><![CDATA[I was asked a question a while back over IM. The question and my subsequent answer made me think about my coding style, decision making process and evolution over the years and I decided that I would share those thoughts with you (aren&#8217;t you lucky).

The initial conversation went something like this, I&#8217;m paraphrasing here (but [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked a question a while back over <acronym title="Instant Message">IM</acronym>. The question and my subsequent answer made me think about my coding style, decision making process and evolution over the years and I decided that I would share those thoughts with you (aren&#8217;t you lucky).<br />
<span id="more-179"></span><br />
The initial conversation went something like this, I&#8217;m paraphrasing here (but at least I&#8217;m not <a href="/archives/2007/02/11/donations-make-me-warm-and-fuzzy/">filling it with &#8220;dude&#8221;&#8217;s</a>):</p>
<blockquote><p>M: I was thinking about the <span class="code">event.setArg()</span> method, and thought it would be nice if you could have it set the variable to session or cookies within the same call, e.g. <span class="code">event.setArg(&#8216;name&#8217;,'value&#8217;,true,true)</span>, what do you think?</p></blockquote>
<blockquote><p>Me: I see what you&#8217;re thinking, but I don&#8217;t like it. I think that your code should be clear to you and others what it is doing and those true arguments don&#8217;t give you much insight into what they&#8217;re doing.</p>
<p>You&#8217;ve got to think about someone else coming to maintain your code, would they be able to see what it was doing without digging through to find the definition of <span class="code">event.setArg()</span>? </p>
<p>Also how many times will you use it, and if not many, will you have to check the definition yourself to remind you which one is setting the cookie and which the session next time you see it?</p></blockquote>
<p>So in the end I proposed 3 methods, the original setArg() method and two for setting cookie values &#038; session values, basically a couple of cookie and session faÃ§ades, and I think that&#8217;s what he went for in the end.</p>
<p>In my view the few times you&#8217;d want to set the same value to cookie and or session is very rare and the following example shows the worst case scenario where you want the value in all 3 places:</p>
<p><span class="code">event.setArg( &#8216;myArg&#8217;, myVal );</span><br />
<span class="code">cookie.set( &#8216;myArg&#8217;, myVal );</span><br />
<span class="code">session.set( &#8216;myArg&#8217;, myVal );</span></p>
<p>It&#8217;s not the driest piece of code, but in my opinion much better than being presented with <span class="code">event.setArg(&#8216;myArg&#8217;, myVal, false, true)</span>.</p>
<p>So that brings me to the title of this post, &#8220;Coding Clarity Over Cleverness&#8221;, the example with the extra faÃ§ades for the session &#038; cookie can&#8217;t really be any clearer in my opinion, it&#8217;s not the cleverest or driest solution but as far as readability and future maintenance in my opinion it&#8217;s much better. Presented with that code you probably wouldn&#8217;t even dig into the documentation or code to see what cookie.set() and session.set() are doing as it&#8217;s pretty clear.</p>
<p>The clarity over cleverness argument goes for any coding situation, you might hide some really clever code behind a method or function, but it&#8217;s name and signature should clearly show what it&#8217;s doing.</p>
<p>So the next time you come up with a clever solution, ask yourself if it&#8217;s clear what the code is doing if not then re-factor it so that it is.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2008/10/14/coding-clarity-over-cleverness/feed/</wfw:commentRss>
		<slash:comments>2</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>245 tests, 2094 assertions, 0 failures, 0 errors &#8211; yippie!</title>
		<link>http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/</link>
		<comments>http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 19:37:39 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[My Sites]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/</guid>
		<description><![CDATA[Sorry for the rather pointless post, I&#8217;ve just finished ensuring our test coverage is up to scratch on our project (as I mentioned in the last post). This means that I can get on with the next stage.
Which also means we&#8217;re one step closer to releasing it.
Which also means I&#8217;m one step closer to being [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry for the rather pointless post, I&#8217;ve just finished ensuring our test coverage is up to scratch on our project (as I <a href="/archives/2008/02/20/how-i-increased-my-ruby-on-rails-productivity-on-windows/">mentioned in the last post</a>). This means that I can get on with the next stage.</p>
<p>Which also means we&#8217;re one step closer to releasing it.</p>
<p>Which also means I&#8217;m one step closer to being able to tell you all about it, ohhhhh it&#8217;s so exciting!</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Image Cropper V2 Details and Fund Raising</title>
		<link>http://www.defusion.org.uk/archives/2007/12/24/javascript-image-cropper-v2-fund-raising/</link>
		<comments>http://www.defusion.org.uk/archives/2007/12/24/javascript-image-cropper-v2-fund-raising/#comments</comments>
		<pubDate>Mon, 24 Dec 2007 14:56:26 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/12/24/javascript-image-cropper-v2-fund-raising/</guid>
		<description><![CDATA[I&#8217;ve had a list of changes and updates to apply to the JavaScript Image Cropper for quite a while now and I have been thinking of these in a lot more detail recently. There are lots of changes that I plan to make that would bring the cropper up to V2 level and ensure that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a list of changes and updates to apply to the <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper</a> for quite a while now and I have been thinking of these in a lot more detail recently. There are lots of changes that I plan to make that would bring the cropper up to V2 level and ensure that it remains a viable cropping solution for the future.<br />
<span id="more-154"></span><br />
These changes include (but are not limited to) the following:</p>
<ul>
<li>Fix as many bugs as possible, if not all.</li>
<li>Add a couple of new features to the base cropper.</li>
<li>Core architectural changes to improve flexibility of the cropper, read alternative framework support.</li>
<li>Improved documentation and support network.</li>
<li>Improvements to maintenance and updates, read more regular updates.</li>
<li>Any performance improvements that can be made (a fresh look at the code always seems to reveal areas that can be improved).</li>
</ul>
<p>Over the past couple of evenings I have documented and investigated my plans and the architectural changes that I would need to implement to take the cropper to the next level and these have provided me with a rough timeframe for completion of V2.</p>
<p>However I am incredibly busy at the moment and other commitments are taking priority, but I also do not want the cropper codebase to stagnate as I understand the popularity of the cropper &#8212; it&#8217;s the main traffic driver on my site and has had nearly 32,000 downloads so far and is averaging over 1,000 per month.</p>
<p>But as I say my other commitments are taking priority and a lot of my spare time, so I thought I would try an experiment, fund raising.</p>
<p><strong>Why fund raising?</strong><br />
Firstly I must state that this is not about the money, if it were I would not release my code for free (and this will continue for version 2 of the cropper). But it is the only thing I could think of that could give me a clear indication of the desire for an updated version of the cropper. It is all well and good having the odd comments praising the cropper and/or mentioning the desire for feature x or bug fix y, but it is something different to put your money towards achieving that.</p>
<p>So far the cropper donation ratio is about  0.04% of all downloads result in a donation (that&#8217;s 14 donations out of around 32,000 downloads), so the fund raising activity should really test the reaction of the version 2 plans &#8212; thus the target figure I&#8217;ve entered and the timeframe are not as important to me the reaction.</p>
<p><strong>So when will version 2 be released?</strong><br />
That is partly down to the results of the fund raising, I do seriously want to implement all my plans, but whether that&#8217;s this month, next month, next June etc. I cannot specify right now due to my current commitments, all I can say is that if the reaction to the fund raising is successful then it will help me prioritise the cropper appropriately and will result in version 2 being released sooner rather than later.</p>
<p><strong>Okay, enough of the sales patter, how do I donate?</strong><br />
I&#8217;ve setup <a href="http://www.pledgie.com/campaigns/459">a campaign on Pledgie</a>, which you can use your existing PayPal account (or credit card if you don&#8217;t have a PayPal account) to make a donation.</p>
<div style="text-align: center;">
<a href='http://www.pledgie.com/campaigns/459'><img alt='Click here to lend your support to: JavaScript Image Cropper V2 fund raising and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/459.png?skin_name=chrome' border='0' /></a>
</div>
<p>I look forward to your help and support and the changes that V2 will bring to the cropper.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/12/24/javascript-image-cropper-v2-fund-raising/feed/</wfw:commentRss>
		<slash:comments>46</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&#8217;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&#8217;t have time to look at a work around during work hours as it really isn&#8217;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&#8217;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&#8217;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 &#8211; 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&#8217;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&#8217;t going to work.</p>
<p>So my next attempt was to turn it on it&#8217;s head, make the <span class="code">ComboBox</span> the controller for this functionality, this isn&#8217;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&#8217;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&#8217;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 &#8211; 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&#8217;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&#8217;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&#8217;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&#8217;t have a MXML language file, and I couldn&#8217;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&#8217;t have a MXML language file, and I couldn&#8217;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>Code: CFStatShot Yahoo Widget</title>
		<link>http://www.defusion.org.uk/archives/2007/08/02/code-cfstatshot-yahoo-widget/</link>
		<comments>http://www.defusion.org.uk/archives/2007/08/02/code-cfstatshot-yahoo-widget/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 21:00:53 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/08/02/code-cfstatshot-yahoo-widget/</guid>
		<description><![CDATA[
I&#8217;m releasing a Yahoo Widget that I created a long time ago and have been meaning to release for quite a while too.
The story all begins when I took over the Coldfusion platform support for, I started to find myself spending a bit of time watching cfstat on the servers to get a feel for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/code/cfstatshot-cfstat-yahoo-desktop-widget/"><img class="featureImg" src="/wp-content/uploads/2007/08/cfstatshot.png" alt="CFStatShot watching multiple Coldfusion servers" /></a><br />
I&#8217;m releasing a <a href="http://widgets.yahoo.com/">Yahoo Widget</a> that I created a long time ago and have been meaning to release for quite a while too.</p>
<p>The story all begins when I took over the Coldfusion platform support for, I started to find myself spending a bit of time watching <span class="code">cfstat</span> on the servers to get a feel for the current status of the machines. As we had multiple servers (then 4, now 6) and only being able to get to cfstat directly on the machine, this was not really practicable.</p>
<p>What I really wanted was a little desktop application that could give me the headlines of <span class="code">cfstat</span> for as many servers as we had, all in an easy to digest format, the result is the <a href="/code/cfstatshot-cfstat-yahoo-desktop-widget/">CFStatShot Yahoo Desktop Widget</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/08/02/code-cfstatshot-yahoo-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pseudo Code Insult</title>
		<link>http://www.defusion.org.uk/archives/2007/06/12/pseudo-code-insult/</link>
		<comments>http://www.defusion.org.uk/archives/2007/06/12/pseudo-code-insult/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 11:51:30 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Outer Monologue]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/06/12/pseudo-code-insult/</guid>
		<description><![CDATA[A recent tradition in our inter-office messenger chat has been to talk in pseudo-code, usually just because it makes a statement a lot more funnier. Yes it's a little (ok, a lot) geeky.
Today I received this message:
Display code as plain text
PHP:




if&#40; time&#40;&#41; == $dave-&#62;getBirthday&#40;&#41; &#41; &#123;


&#160; &#160; $dave-&#62;setAge&#40; $dave-&#62;getAge&#40;&#41; + 1 &#41;;


&#160;


&#160;&#160; &#160;if&#40; $dave-&#62;getAge&#40;&#41;&#62; $michael-&#62;getAge&#40;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>A recent tradition in our inter-office messenger chat has been to talk in pseudo-code, usually just because it makes a statement a lot more funnier. Yes it's a little (ok, a lot) geeky.</p>
<p>Today I received this message:</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<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:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span> <a href="http://www.php.net/time"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#0000FF;">$dave</span>-&gt;<span style="color:#006600;">getBirthday</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</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:#0000FF;">$dave</span>-&gt;<span style="color:#006600;">setAge</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$dave</span>-&gt;<span style="color:#006600;">getAge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">1</span> <span style="color:#006600; font-weight:bold;">&#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;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;<span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$dave</span>-&gt;<span style="color:#006600;">getAge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt; <span style="color:#0000FF;">$michael</span>-&gt;<span style="color:#006600;">getAge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#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; &nbsp; &nbsp; michael-&gt;<span style="color:#006600;">laugh</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/die"><span style="color:#000066;">die</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$laughing</span><span style="color:#006600; font-weight:bold;">&#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; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I think someone's trying to say I'm old.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/06/12/pseudo-code-insult/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

