<?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"
	>

<channel>
	<title>Richard Willis</title>
	<atom:link href="http://richtextformat.co.uk/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://richtextformat.co.uk/blog</link>
	<description>: Freelance Flash &#38; Flex Developer</description>
	<pubDate>Tue, 24 Jan 2012 13:24:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>An internal build error has occurred. See the error log for more information.</title>
		<link>http://richtextformat.co.uk/blog/?p=506</link>
		<comments>http://richtextformat.co.uk/blog/?p=506#comments</comments>
		<pubDate>Tue, 24 Jan 2012 13:24:24 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Bugs]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=506</guid>
		<description><![CDATA[ONE of the reasons this might happen is because of the following:

public static function compareStrings &#40; firstString:String, secondString:String &#41;:String
&#123;
	firstString:String = tidySpace&#40; firstString &#41;;
	...
&#125;

You see that firstString:String = etc there? That&#8217;s the fella. DON&#8217;T EVER strongly type your vars more than once, unless you wanna lose an hour of dev like I have this morning.
]]></description>
			<content:encoded><![CDATA[<p>ONE of the reasons this might happen is because of the following:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> compareStrings <span style="color: #66cc66;">&#40;</span> firstString:<span style="color: #0066CC;">String</span>, secondString:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
	firstString:<span style="color: #0066CC;">String</span> = tidySpace<span style="color: #66cc66;">&#40;</span> firstString <span style="color: #66cc66;">&#41;</span>;
	...
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>You see that <b>firstString:String = etc</b> there? That&#8217;s the fella. DON&#8217;T EVER strongly type your vars more than once, unless you wanna lose an hour of dev like I have this morning.</p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=506</wfw:commentRss>
		</item>
		<item>
		<title>AIR Apps Need Planning</title>
		<link>http://richtextformat.co.uk/blog/?p=496</link>
		<comments>http://richtextformat.co.uk/blog/?p=496#comments</comments>
		<pubDate>Thu, 12 Aug 2010 11:58:06 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[AIR]]></category>

		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Theory]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=496</guid>
		<description><![CDATA[
[click the image to see a larger version]
This diagram outlines an XML load procedure. Complicated, no? That&#8217;s because it&#8217;s for an AIR app, and therefore has to cope with situations other Flash &#38; Flex apps don&#8217;t. I&#8217;m showing it to make the case for planning AIR apps in advance as much as possible.

Let&#8217;s go through [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://richtextformat.co.uk/blog/wp-content/uploads/2010/08/xmlloadprocedure.jpg"><img class="alignnone size-medium wp-image-497" title="xmlloadprocedure" src="http://richtextformat.co.uk/blog/wp-content/uploads/2010/08/xmlloadprocedure-450x322.jpg" alt="" width="450" height="322" /></a></p>
<p><span style="font-size: 9px; font-style: italic; color: #999999;">[click the image to see a larger version]</span></p>
<p>This diagram outlines an XML load procedure. Complicated, no? That&#8217;s because it&#8217;s for an AIR app, and therefore has to cope with situations other Flash &amp; Flex apps don&#8217;t. I&#8217;m showing it to make the case for planning AIR apps in advance as much as possible.</p>
<p><span id="more-496"></span></p>
<p>Let&#8217;s go through the diagram&#8217;s logic. There are only two possible outcomes, either &#8216;XML DOC!&#8217; (bottom left) or &#8216;FATAL ERROR!&#8217; (bottom right) There are ten possible routes, three failures, one restart and six successes. I&#8217;ll go through them all, from worst to best.</p>
<p>The first three steps always occur. The app queries a web service  for  new data, and if it finds some it asks the user if she wants it and  saves  her answer. The fourth step is the first query of the loop.</p>
<ol>
<li>NEW DATA?</li>
<li>USER WANTS IT?</li>
<li>GET FIRST XML DOC</li>
<li>IN MEMORY?</li>
</ol>
<p>Has the XML already been loaded? Every load starts with this question. Thereafter&#8230;</p>
<p><strong>Scenario A: App offline on first run - FAIL<br />
</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>YES. ONLINE?</li>
<li>NO. ALERT END -&gt; FATAL ERROR!</li>
</ol>
<p>The XML document is not in local memory, it&#8217;s the app&#8217;s first ever run and it&#8217;s not online. This is a fatal error because some of the app&#8217;s mandatory data lives necessarily online, and without it the app will break.</p>
<p><strong>Scenario B: App online on first run - RESTART</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>YES. ONLINE?</li>
<li>YES. ALERT START -&gt; IN MEMORY?</li>
</ol>
<p>The XML document is not in local memory, and it&#8217;s the app&#8217;s first ever run, but it is online, meaning it can obtain it&#8217;s  mandatory data. We set FIRST RUN to &#8216;false&#8217; and restart the loop.</p>
<p><strong>Scenario C: App offline on subsequent run - FAIL</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>NO. LOCAL VERSION?</li>
<li>NO. ONLINE?</li>
<li>NO -&gt; FATAL ERROR!</li>
</ol>
<p>The XML document is not stored locally, the app has run before, but there is no &#8216;local version&#8217;. If the app had previously downloaded the XML document it would have stored it locally, so that if in future it was offline, it would have a back-up copy. Being offline means it can&#8217;t obtain the document in the first place, and will therefore break.</p>
<p><strong>Scenario D: App cannot load mandatory XML at first attempt - FAIL</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>NO. LOCAL VERSION?</li>
<li>NO. ONLINE?</li>
<li>YES. LOAD TERR LANG</li>
<li>NO (load error). BACK UP DOC? (PROB. US-EN)</li>
<li>NO -&gt; FATAL ERROR!</li>
</ol>
<p>The XML document is not stored locally, the app has run before, and  there is no local version, but we are online, meaning we can &#8216;LOAD TERR LANG&#8217;. This is shorthand for &#8216;Territory &amp; Language&#8217;. When the user logs in they choose a global region (Europe, America, Africa) and a preferred language, and each XML document has different versions to reflect this. If the user&#8217;s preferred choice - European data in Spanish, say - fails we load a back-up document, usually American data in English. If this equally fails, again the app will break.</p>
<p><strong>Scenario E: App loads back-up XML - SUCCESS</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>NO. LOCAL VERSION?</li>
<li>NO. ONLINE?</li>
<li>YES. LOAD TERR LANG</li>
<li>NO (load error). BACK UP DOC? (PROB. US-EN)</li>
<li>YES. LOAD BACK UP DOC</li>
<li>YES -&gt; XML DOC!</li>
</ol>
<p>The XML document is not stored locally, the app has run before, and  there is no local version, but we are online, meaning we can load &#8216;Territory &amp; Language&#8217;. If that fails we load the back-up document. That loads successfully, meaning we at least have usable data.</p>
<p>This is the worst of the six successful outcomes.</p>
<p><strong>Scenario F: App loads and stores requested XML - SUCCESS</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>NO. LOCAL VERSION?</li>
<li>NO. ONLINE?</li>
<li>YES. LOAD TERR LANG</li>
<li>YES -&gt; XML DOC!</li>
</ol>
<p>The XML document is not stored locally, the app has run before, and  there is no local version, but we are online, meaning we can load  &#8216;Territory &amp; Language&#8217;. And it loads! It&#8217;s then stored locally should it be needed it whilst offline in future.</p>
<p><strong>Scenario G: App has locally stored XML - SUCCESS</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>NO. LOCAL VERSION?</li>
<li>YES. OUT OF DATE? USER WANTS NEW DATA? ONLINE?</li>
<li>NO. USE EXISTING LOCAL VERSION -&gt; XML DOC!</li>
</ol>
<p>The XML document is stored locally! It must have been downloaded before. But is the online version newer? And has the user signaled that she wants the latest data (see step 2 above)? And are we online? If the answer to any of these questions is &#8216;no&#8217; we should use the local version.</p>
<p><strong>Scenario H: App falls back on locally stored XML - SUCCESS</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>NO. LOCAL VERSION?</li>
<li>YES. OUT OF DATE? USER WANTS NEW DATA? ONLINE?</li>
<li>YES. LOAD TERR LANG</li>
<li>NO (load error). USE EXISTING LOCAL VERSION -&gt; XML DOC!</li>
</ol>
<p>The XML document is stored locally, but newer data is available, the user wants it, and we are online, meaning we should load  &#8216;Territory &amp; Language&#8217;. That fails though, so we use the old back-up version.</p>
<p><strong>Scenario I: App loads and stores updated XML - SUCCESS</strong></p>
<ol>
<li>NO (not in memory). FIRST RUN?</li>
<li>NO. LOCAL VERSION?</li>
<li>YES. OUT OF DATE? USER WANTS NEW DATA? ONLINE?</li>
<li>YES. LOAD TERR LANG</li>
<li>YES -&gt; XML DOC!</li>
</ol>
<p>The XML document is stored locally, but newer data is available, the user wants it, and we are online, meaning we should load  &#8216;Territory &amp; Language&#8217;. And we get it!</p>
<p><strong>Scenario J: App already has XML in memory - SUCCESS</strong></p>
<ol>
<li>YES (in memory) -&gt; XML DOC!</li>
</ol>
<p>The XML document exists in the app&#8217;s runtime memory! This happens if the user has logged in, loaded her XML, logged out, and then logged in again without closing the app.</p>
<p>This is the best of the six successful outcomes.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p><strong>Scenario K: Post-load assessment<br />
</strong></p>
<ol>
<li>XML DOC!</li>
<li>MORE XML TO LOAD?</li>
<li>YES. IN MEMORY?</li>
</ol>
<p>After every successful journey through the loop we check for further XML documents, and load them if required.</p>
<ol>
<li>NO (no more XML documents to load). START APP&#8230;</li>
</ol>
<p>Or if not, we just start the app.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p><strong>Conclusion</strong></p>
<p>The above procedure is only about loading XML documents. Getting data, one of the simplest aspects of any app. If something so straightforward can become so complex, imagine how other parts of your app will end up if you don&#8217;t think them through in advance.</p>
<p>If you are building AIR apps: plan, plan, plan!</p>
<p>ps: There is a logical error in the diagram. I&#8217;m offering £1 to anyone who can tell me what it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=496</wfw:commentRss>
		</item>
		<item>
		<title>Flex Carousel Component</title>
		<link>http://richtextformat.co.uk/blog/?p=470</link>
		<comments>http://richtextformat.co.uk/blog/?p=470#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:03:59 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Components]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[MXML]]></category>

		<category><![CDATA[Carousel]]></category>

		<category><![CDATA[component]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=470</guid>
		<description><![CDATA[I recently made this Carousel component for Flex

<object	type="application/x-shockwave-flash"
			data="http://richtextformat.co.uk/blog/wp-content/uploads/2010/01/carouseltest.swf"
			width="450"
			height="300">
	<param name="movie" value="http://richtextformat.co.uk/blog/wp-content/uploads/2010/01/carouseltest.swf" />
</object>

As it&#8217;s basically just a slightly jazzier way of selecting a single item, I made it in the same way one would create a List component: with properties like selectedIndex, selectedItem, dataProvider, itemRenderer etc. etc. Basically, just hand it a dataProvider and it&#8217;ll lay [...]]]></description>
			<content:encoded><![CDATA[<p>I recently made this <a href="http://github.com/richtextformat/RichTextFormat-Classes/tree/master/uk/co/richtextformat/flex/view/components/carousel/">Carousel component</a> for Flex</p>

<object	type="application/x-shockwave-flash"
			data="http://richtextformat.co.uk/blog/wp-content/uploads/2010/01/carouseltest.swf"
			width="450"
			height="300">
	<param name="movie" value="http://richtextformat.co.uk/blog/wp-content/uploads/2010/01/carouseltest.swf" />
</object>
<p><span id="more-470"></span></p>
<p>As it&#8217;s basically just a slightly jazzier way of selecting a single item, I made it in the same way one would create a List component: with properties like selectedIndex, selectedItem, dataProvider, itemRenderer etc. etc. Basically, just hand it a dataProvider and it&#8217;ll lay it all out for you. &#8216;Should play ball, but hasn&#8217;t been exhaustively tested so you might get some bugs, dunno.</p>
<p>The Carousel can be controlled in various ways. Clicking the slider will tween it to that position. Dragging the slider point will tween it to the slider&#8217;s current position. Clicking a renderer will tween that renderer into the centre. </p>
<p>I&#8217;ll explain further down this post how to use it but first some documentation. I haven&#8217;t had - and probably won&#8217;t get - the time to document it properly, with ASDocs or whatever, so here is a scrappily thrown together lists of it&#8217;s various properties.</p>
<p><strong>CONSTANTS</strong></p>
<p><strong>MIN_</strong><strong>DIAMETER</strong>:int = 1024;<br />
The minimum width of the circle the renderers sit on.</p>
<p><strong>MAX_DIAMETER</strong>:int = 8192;<br />
The maximum width of the circle the renderers sit on.</p>
<p><strong>PROPERTIES</strong></p>
<p><strong>container</strong>:Canvas<br />
The bounding box that contains the renderers (read-only).</p>
<p><strong>dataProvider</strong>:Object<br />
The data for the component. Currently only Arrays are accepted.</p>
<p><strong>diameter</strong>:int<br />
The width of the circle. Value must be between MIN_DIAMETER and MAX_DIAMETER. The default is half MAX_DIAMETER.</p>
<p><strong>focusFrame</strong>:CarouselFocusFrame<br />
The grey box that frames the selected renderer. The value of this property must be a DisplayObject that extends <a href="http://github.com/richtextformat/RichTextFormat-Classes/blob/master/uk/co/richtextformat/flex/view/components/carousel/CarouselFocusFrame.as">CarouselFocusFrame</a> and implements <a href="http://github.com/richtextformat/RichTextFormat-Classes/blob/master/uk/co/richtextformat/flex/view/components/carousel/ICarouselFocusFrame.as">ICarouselFocusFrame</a>.</p>
<p><strong>focusFrameDisplaysConstantly</strong>:Boolean<br />
A flag that indicates whether the focusFrame should display permanently (true) or disappears whilst the Carousel is spinning (false). The default is true.</p>
<p><strong>itemRenderer</strong>:IFactory<br />
The itemRenderer for the Carousel. The &#8216;generator&#8217; for this property must implement <a href="http://github.com/richtextformat/RichTextFormat-Classes/blob/master/uk/co/richtextformat/flex/view/components/carousel/ICarouselRenderer.as">ICarouselRenderer</a>.</p>
<p><strong>labelField</strong>:String<br />
The name of the property on the dataProvider objects used to populate the text labels on the renderers. The default is &#8216;label&#8217;.</p>
<p><strong>rendererGap</strong>:uint<br />
The distance in pixels between each renderer. The default is 50.</p>
<p><strong>rendererHeight</strong>:int<br />
The height in pixels of each renderer. The default is 190.</p>
<p><strong>rendererWidth</strong>:int<br />
The width in pixels of each renderer. The default is 150.</p>
<p><strong>selectedIndex</strong>:int<br />
The index of the currently selected item. Setting selectedIndex moves the Carousel to that point directly, setting targetIndex tweens it there.</p>
<p><strong>selectedItem</strong>:Object<br />
The currently selected item.</p>
<p><strong>slider</strong>:HSlider (read-only)<br />
The HSlider instance that controls the Carousel (read-only).</p>
<p><strong>sliderIntervalGap</strong>:int<br />
The length in pixels to set the slider for every renderer it controls. The default is 50.</p>
<p><strong>smoothing</strong>:Boolean<br />
The smoothing to be used on the renderer images. The default is true.</p>
<p><strong>sourceField</strong>:Object<br />
The name of the property on the dataProvider objects used to populate the images in the renderers. The default is &#8217;source&#8217;.</p>
<p><strong>targetIndex</strong>:int<br />
The currently requested index for the Carousel to tween to. Setting targetIndex tweens the Carousel to that point, setting selectedIndex moves it there directly.</p>
<p><strong>STYLES</strong></p>
<p>The component also has a couple of styles: &#8216;carouselColor&#8217; and &#8216;carouselPaddingTop&#8217;.</p>
<p><strong>carouselColor</strong>:int<br />
Sets the colour of the container Canvas that holds the renderers.</p>
<p><strong>carouselPaddingTop</strong>:Number<br />
Sets the padding between the top of the component and the top of the container Canvas that holds the renderers.</p>
<p><strong>Using the Carousel Component</strong></p>
<p>This should be pretty straightforward.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> </span>
<span style="color: #000000;">	xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> </span>
<span style="color: #000000;">	xmlns:carousel=<span style="color: #ff0000;">&quot;uk.co.richtextformat.flex.view.components.carousel.*&quot;</span></span>
<span style="color: #000000;">	layout=<span style="color: #ff0000;">&quot;absolute&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;carousel:Carousel</span> id=<span style="color: #ff0000;">&quot;myCarousel&quot;</span> </span>
<span style="color: #000000;">		width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;">		focusFrameDisplaysConstantly=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #000000;">		carouselPaddingTop=<span style="color: #ff0000;">&quot;20&quot;</span></span>
<span style="color: #000000;">	<span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Setting the dataProvider should be all you need to do to get it rolling.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> dataProvider:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span> 
	<span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">'Tobias'</span>, source:<span style="color: #ff0000;">'img1.jpg'</span><span style="color: #66cc66;">&#125;</span>,
	<span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">'Cynthia'</span>, source:<span style="color: #ff0000;">'img2.jpg'</span><span style="color: #66cc66;">&#125;</span>,
	<span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">'Walter'</span>, source:<span style="color: #ff0000;">'img3.jpg'</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#93;</span>;
myCarousel.<span style="color: #006600;">dataProvider</span> = dataProvider;</pre></div></div>

<p>And if your data is bespoke and you needed to change the property names, that should be straightforward too.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">myCarousel.<span style="color: #006600;">labelField</span> = <span style="color: #ff0000;">'name'</span>;
myCarousel.<span style="color: #006600;">sourceField</span> = <span style="color: #ff0000;">'imgURL'</span>;
<span style="color: #000000; font-weight: bold;">var</span> dataProvider:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span> 
	<span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">'Tobias'</span>, imgURL:<span style="color: #ff0000;">'img1.jpg'</span><span style="color: #66cc66;">&#125;</span>,
	<span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">'Cynthia'</span>, imgURL:<span style="color: #ff0000;">'img2.jpg'</span><span style="color: #66cc66;">&#125;</span>,
	<span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">'Walter'</span>, imgURL:<span style="color: #ff0000;">'img3.jpg'</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#93;</span>;
myCarousel.<span style="color: #006600;">dataProvider</span> = dataProvider;</pre></div></div>

<p>The &#8217;source&#8217; property of your data objects can either be a valid URL to an image online (a default blue &#8216;No Image Available&#8217; image will be used where the URL is invalid) or a Bitmap instance.</p>
<p>The component is free for use and can be downloaded <a href="http://github.com/richtextformat/RichTextFormat-Classes/tree/master/uk/co/richtextformat/flex/view/components/carousel/">here</a> from <a href="http://github.com/richtextformat/RichTextFormat-Classes">my repo on Github</a>. I think and hope so anyway. I&#8217;m new to Github (only signed up today) and am not really familiar with the way it works yet, so if you get any probs getting hold of it from there leave a message for me somewhere and I&#8217;ll see what I can do to help.</p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=470</wfw:commentRss>
		</item>
		<item>
		<title>RobotSignals: Combining RobotLegs with Robert Penner&#8217;s Signals</title>
		<link>http://richtextformat.co.uk/blog/?p=445</link>
		<comments>http://richtextformat.co.uk/blog/?p=445#comments</comments>
		<pubDate>Sun, 20 Dec 2009 17:30:47 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Default]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[MXML]]></category>

		<category><![CDATA[OOP]]></category>

		<category><![CDATA[RobotLegs]]></category>

		<category><![CDATA[Signals]]></category>

		<category><![CDATA[Theory]]></category>

		<category><![CDATA[as3signals]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=445</guid>
		<description><![CDATA[Robotlegs is an AS3 dependency injection micro-framework.
Signals is a new approach for AS3 events, inspired by C# events and signals/slots in Qt.
Put them together and you&#8217;ve got an elegant, simple &#38; completely decoupled  solution to the problem of Flex &#38; AIR development.
I&#8217;ve thrown together a really quick example (which you can download below) based [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.robotlegs.org/"><strong>Robotlegs</strong></a> is an AS3 <a href="http://knowledge.robotlegs.org/faqs/dependency-injection/what-is-dependency-injection">dependency injection</a> micro-framework.</p>
<p><a href="http://robertpenner.com/flashblog/2009/09/my-new-as3-event-system-signals.html"><strong>Signals</strong></a> is a new approach for AS3 events, inspired by C# events and signals/slots in Qt.</p>
<p>Put them together and you&#8217;ve got an elegant, simple &amp; <em>completely</em> decoupled  solution to the problem of Flex &amp; AIR development.</p>
<p>I&#8217;ve thrown together a really quick example (which you can download below) based upon a couple of things I&#8217;ve seen recently; firstly <a href="http://www.bigroom.co.uk/">Richard Lord</a>&#8217;s <a href="http://flashbrighton.org/?p=406">framework comparison talk</a> at <a href="http://flashbrighton.org/">FlashBrighton</a> a couple of weeks ago, and secondly, <a href="http://blog.steamboy.co.uk/">Owen Bennett</a>&#8217;s  blend of RobotLegs and Signals he showed me last week. Seeing what Owen had put together inspired me to have a go myself. I wondered whether it was possible to create a RobotLegs/Signals hybrid that was even more decoupled than the system Owen was working on. So I created a short (less then 100 lines) class called &#8216;SignalBox&#8217;, named after a similarly named class in Owen&#8217;s system.</p>
<p><span id="more-445"></span></p>
<p>RobotLegs &amp; Signals are great bits of work but I won&#8217;t discuss them here, because you can either go <a href="http://knowledge.robotlegs.org/">here</a> &amp; <a href="http://github.com/robertpenner/as3-signals">here</a> to do that, or if you&#8217;re feeling confident - or just plain impatient - download the <a href="http://richtextformat.co.uk/blog/wp-content/uploads/2009/12/robotsignals.zip">RobotSignals example here</a> and just have a play with it. It&#8217;s a FlexBuilder project that contains both the <a href="http://www.robotlegs.org/">Robotlegs</a> &amp; <a href="http://robertpenner.com/flashblog/2009/09/my-new-as3-event-system-signals.html">Signals</a> source code (from mid-December 2009), so should contain all you need.</p>
<p>The following swf is what the example project compiles down to:</p>

<object	type="application/x-shockwave-flash"
			data="http://richtextformat.co.uk/blog/wp-content/uploads/2009/12/robotsignals.swf"
			width="450"
			height="450">
	<param name="movie" value="http://richtextformat.co.uk/blog/wp-content/uploads/2009/12/robotsignals.swf" />
</object>
<p>As simple an example I could conceive of. This Flex app conatins two View elements - the TextInput &amp; Button to the left, and the TextArea to the right - both of which are controlled by their own <a href="http://knowledge.robotlegs.org/faqs/reference-mvcs-implementation/what-is-the-function-of-the-mediator-class">Mediators</a> and an <a href="http://knowledge.robotlegs.org/faqs/reference-mvcs-implementation/what-is-the-function-of-the-mediator-class">Actor</a> based Proxy Model class in the background. These three elements are entirely decoupled from each other but communicate through the SignalBox class in the following way:</p>
<ol>
<li>The TextSubmit component dispatches user input into the Signalbox;</li>
<li>The TextProxy Model instance hears the Signal and stores said user input, before dispatching it again into the SignalBox;</li>
<li>The TextDisplay component instance hears the signal and displays the user input in its TextArea component</li>
</ol>
<p>The decoupling is extreme, to the point that the only public method they definitely require is the <strong>onRegister();</strong> method they use to register with the RobotLegs framework. All communications go through the SignalBox. RobotLeg&#8217;s <a href="http://knowledge.robotlegs.org/faqs/framework-core/what-is-the-context-class">Context</a> class injects the SignalBox into every class in you application, meaning they all have access to the same single instance of said SignalBox, meaning that it&#8217;s Signals can propigate through every part of the application at will. This is an example of a singleton-with-a-small-s pattern; as in a single instance and not a global property.</p>
<p>The ISignalBox interface defines the following seven, reasonably self-explanatory methods:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">addListener</span> <span style="color: #66cc66;">&#40;</span>signalName:<span style="color: #0066CC;">String</span>, listener:<span style="color: #000000; font-weight: bold;">Function</span>, valueClass:<span style="color: #000000; font-weight: bold;">Class</span> = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
<span style="color: #000000; font-weight: bold;">function</span> addListenerOnce <span style="color: #66cc66;">&#40;</span>signalName:<span style="color: #0066CC;">String</span>, listener:<span style="color: #000000; font-weight: bold;">Function</span>, valueClass:<span style="color: #000000; font-weight: bold;">Class</span> = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
<span style="color: #000000; font-weight: bold;">function</span> deleteSignal <span style="color: #66cc66;">&#40;</span>signalName:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
<span style="color: #000000; font-weight: bold;">function</span> dispatchSignal <span style="color: #66cc66;">&#40;</span>signalName:<span style="color: #0066CC;">String</span>, valueObject:<span style="color: #0066CC;">Object</span>, andDeleteIfLastListener:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
<span style="color: #000000; font-weight: bold;">function</span> hasSignal <span style="color: #66cc66;">&#40;</span>signalName:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>;
<span style="color: #000000; font-weight: bold;">function</span> removeAllListeners <span style="color: #66cc66;">&#40;</span>signalName:<span style="color: #0066CC;">String</span>, andDelete:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">removeListener</span> <span style="color: #66cc66;">&#40;</span>signalName:<span style="color: #0066CC;">String</span>, listener:<span style="color: #000000; font-weight: bold;">Function</span>, andDeleteIfLastListener:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;</pre></div></div>

<p>SignalBox keeps a private collection of Signals, meaning that Robert Penner&#8217;s Signals themselves are abstracted away and you never interect with them. By calling <strong>addListener</strong> or <strong>addListenerOnce</strong> you can listen for a Signal, and calling <strong>dispatchSignal</strong> from elsewhere sends that listened for Signal. All seven methods in SignalBox take the following param as their first parameter:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">signalName:<span style="color: #0066CC;">String</span></pre></div></div>

<p>Calling either <strong>addListener</strong> or <strong>addListenerOnce</strong> ensures that a Signal with the passed <strong>signalName</strong> is created, if it doesn&#8217;t already exist. Each <strong>signalName</strong> must be unique. Calling <strong>addListener</strong> or <strong>addListenerOnce</strong> multiple times with the same signal name results in additional listeners being added to a single Signal:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">signalBox.<span style="color: #0066CC;">addListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;UserInput&quot;</span>, someMethodName<span style="color: #66cc66;">&#41;</span>;
signalBox.<span style="color: #0066CC;">addListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;UserInput&quot;</span>, anotherMethodName<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Once you&#8217;ve created a Signal like this, you can dispatch signals through it:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">signalBox.<span style="color: #006600;">dispatchSignal</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;UserInput&quot;</span>, <span style="color: #ff0000;">&quot;A Message&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Calling <strong>dispatchSignal</strong> on a signal that has yet to be created results in an error being thrown.</p>
<p>Adding a Class as the optional third parameter of either <strong>addListener</strong> or <strong>addListenerOnce</strong> results in listeners to that Signal expecting instances of that type:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">signalBox.<span style="color: #0066CC;">addListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;LoginAttempt&quot;</span>, handleLogin, <span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>;
signalBox.<span style="color: #006600;">dispatchSignal</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;LoginAttempt&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>If this third parameter is left undefined, the class String is used by default.</p>
<p>I want to keep this post as short and simple as possible so I&#8217;ll stop here and if you&#8217;ve got any questions please fire away. You can download the <a href="http://richtextformat.co.uk/blog/wp-content/uploads/2009/12/robotsignals.zip">RobotSignals example here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=445</wfw:commentRss>
		</item>
		<item>
		<title>HowTo: Improve your workflow with Snippets, comments and &#8216;dormant&#8217; variables</title>
		<link>http://richtextformat.co.uk/blog/?p=358</link>
		<comments>http://richtextformat.co.uk/blog/?p=358#comments</comments>
		<pubDate>Sun, 25 Jan 2009 12:30:03 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Optimisation]]></category>

		<category><![CDATA[Tutorial]]></category>

		<category><![CDATA[ActionScript3]]></category>

		<category><![CDATA[comments]]></category>

		<category><![CDATA[snippets]]></category>

		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=358</guid>
		<description><![CDATA[I use FlexBuilder. I used to use FDT but the code-completion, hover-over links and - most importantly - ability to compile from MXML that FlexBuilder offers eventually tempted me away. Still, there&#8217;s one thing about FDT I miss: it wrote  A LOT of code for me. Nothing complicated, stuff like getters &#38; setters that [...]]]></description>
			<content:encoded><![CDATA[<p>I use FlexBuilder. I used to use FDT but the code-completion, hover-over links and - most importantly - ability to compile from MXML that FlexBuilder offers eventually tempted me away. Still, there&#8217;s one thing about FDT I miss: it wrote  A LOT of code for me. Nothing complicated, stuff like getters &amp; setters that are tedious and time consuming. It was great that FDT could take that off my hands.</p>
<p>These days, with FlexBuilder, I don&#8217;t have that any longer. Which isn&#8217;t great but I&#8217;ve managed to concoct a  workaround using &#8216;Snippets&#8217;, comments and &#8216;dormant&#8217; variables, which has sped things up for me and which could do the same for you.</p>
<p>Let me explain&#8230;</p>
<p><span id="more-358"></span></p>
<p><strong>Snippets</strong></p>
<p>These, for those of you that don&#8217;t know, are sections of reusable code that you can insert into a file. Putting your cursor in the place you want a snippet to appear and clicking on its name (in a &#8216;Snippets&#8217; dialog box) will insert the snippet at that position. They&#8217;re simple to use and save time rewriting repetitious things like for loops. <a href="http://www.insideria.com/">Insideria</a> have <a href="http://www.insideria.com/2008/04/flex-builder-enhancements-snippets-and-todo.html">a great little tutorial here</a> that will show you how to install a &#8216;Snippets&#8217; plugin for FlexBuilder and I recommend you do just that. That link also details a little &#8216;ToDo&#8217; FlexBuilder plugin that I&#8217;ve found really helps too. Go do that first then come back here and read on.</p>
<p><strong>Comments and &#8216;Dormant&#8217; Variables</strong></p>
<p>When I say &#8216;dormant&#8217; I mean variables that are added to your code but never instantiated. A class&#8217; various properties appear in FlexBuilder&#8217;s &#8216;Outline&#8217; dialog when FlexBuilder is focused on that file. Here&#8217;s a boilerplate &#8216;SomeClass&#8217; example, followed by its representation in the &#8216;Outline&#8217; dialog:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SomeClass
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _someVar:<span style="color: #0066CC;">int</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SomeClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><img class="alignnone size-medium wp-image-363" title="outlinedialog1" src="http://richtextformat.co.uk/blog/wp-content/uploads/2008/11/outlinedialog1.gif" alt="" width="379" height="134" /></p>
<p>You can see that both the constructor method and the &#8216;_someVar&#8217; variable appear in the dialog. Clicking on either of them will take you to that point in the code, so it really helps with navigating around.</p>
<p>What we can do with this is to create a snippet that contains only comments and some potentially &#8216;dormant&#8217; variables and utilise this &#8216;Outline&#8217; functionality to make the class easier and quicker to work with. Here&#8217;s the snippet we&#8217;ll use:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #808080; font-style: italic;">// INIT METHODS</span>
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ____________________initMethods:<span style="color: #0066CC;">int</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #808080; font-style: italic;">// PUBLIC METHODS</span>
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ____________________publicMethods:<span style="color: #0066CC;">int</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #808080; font-style: italic;">// PROTECTED METHODS</span>
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ____________________protectedMethods:<span style="color: #0066CC;">int</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #808080; font-style: italic;">// PRIVATE METHODS</span>
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ____________________privateMethods:<span style="color: #0066CC;">int</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #808080; font-style: italic;">// LISTENER METHODS</span>
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ____________________listenerMethods:<span style="color: #0066CC;">int</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #808080; font-style: italic;">// GETTERS / SETTERS</span>
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ____________________gettersSetters:<span style="color: #0066CC;">int</span>;</pre></div></div>

<p>Under each comment i&#8217;ve added an int variable whose name is formed of two distinct parts: a prefix made up of a whole line of underscore characters, and a suffix describing what each section contains. The comments are there for when you are looking at the file itself, the &#8216;dormant&#8217; variables are there for the &#8216;Outline&#8217; dialog. I&#8217;ll hereafter add my various properties and functions to the class in the relevant places. These two private methods, for instance, they&#8217;ll go directly under the &#8216;____________________privateMethods&#8217; variable:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #808080; font-style: italic;">// PRIVATE METHODS</span>
		<span style="color: #808080; font-style: italic;">// ------------------------------------------------------------------------------------------------------------------------------</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ____________________privateMethods:<span style="color: #0066CC;">int</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _doSomething <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;_doSomething&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _doSomethingElse <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;_doSomethingElse&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>You can see how i like to organise my methods. Under each &#8216;heading&#8217; I list my various methods alphabetically, making them dead easy to navigate to. More importantly though, I split the methods up into &#8216;init&#8217;, &#8216;public&#8217;, &#8216;protected&#8217;, &#8216;private&#8217;, &#8216;listeners&#8217; and &#8216;getters/setters&#8217;. This forms just five groups of methods and that guards against your classes becoming too bloated. Let me explain:</p>
<p>Sometimes a class can get so long and overloaded with methods that organising it becomes a case of grouping functionality instead of method types together. For instance, instead of saying &#8216;this group contains my private functions&#8217; you might say &#8216;this group controls the appearance of textfields&#8217;. If that happens it&#8217;s a sure sign that your class is doing too much; you should just have a seperate, single class for the &#8216;control of the appearance of your textfields&#8217;. if you use the &#8216;public, &#8216;protected&#8217; etc method of organisation and one of your five groups of methods starts to get too full up and slightly confusing, its a sure sign that what you need to do is move some of the functionality over to a new class. because:</p>
<p><strong>one class = one job</strong></p>
<p>Now that&#8217;s all fine and dandy, but why do this? If you look back at the &#8216;Outline&#8217; dialog now, you&#8217;ll see why:</p>
<p><img class="alignnone size-medium wp-image-362" title="outlinedialog2" src="http://richtextformat.co.uk/blog/wp-content/uploads/2008/11/outlinedialog2.gif" alt="" width="379" height="330" /></p>
<p>The &#8216;dormant&#8217; variables and the two new methods have now appeared in the &#8216;Outline&#8217; dialog and the &#8216;dormant&#8217; variables have split the dialog up into small, manageable sections with their long, underscore-based prefixes serving visually to easily differentiate between them and genuine methods and properties. The only role of the &#8216;dormant&#8217; variables is to act as headers and spacers for the &#8216;Outline&#8217; dialog box.</p>
<p>I&#8217;ve also added a getter and a setter method so you can see how clearly this view separates out the whole thing and makes it much quicker and easier to work with.</p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=358</wfw:commentRss>
		</item>
		<item>
		<title>HowTo: Embed fonts in a FlexBuilder AS3 project</title>
		<link>http://richtextformat.co.uk/blog/?p=398</link>
		<comments>http://richtextformat.co.uk/blog/?p=398#comments</comments>
		<pubDate>Thu, 08 Jan 2009 22:15:56 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Tutorial]]></category>

		<category><![CDATA[ActionScript3]]></category>

		<category><![CDATA[embed fonts]]></category>

		<category><![CDATA[FlexBuilder]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=398</guid>
		<description><![CDATA[A subject particularly far away from my heart; I have always loathed font embedding, because there are so many ways of doing it and they don&#8217;t always work and when they do it feels like some weird voodoo that could inexplicably disappear at any moment is part of it! Which is why I&#8217;m very grateful [...]]]></description>
			<content:encoded><![CDATA[<p>A subject <em>particularly</em> far away from my heart; I have always loathed font embedding, because there are so many ways of doing it and they don&#8217;t always work and when they do it feels like some weird voodoo that could inexplicably disappear at any moment is part of it! Which is why I&#8217;m very grateful to have recently been shown a method of achieving this by <a href="http://unwrong.com/">Unwrong</a>&#8217;s marvellous Flash Developer <a href="http://jonathanpace.wordpress.com/">Jonathon Pace</a>. Jon&#8217;s method is simple, relatively error-free and seems to work for all font types - the ones I&#8217;ve tried thus far, at least - which was always the biggest bugbear for me; it sometimes felt like you had to know a different embedding method for each different font type!</p>
<p>So, using Jon&#8217;s method what you have to do is:</p>
<ol>
<li><a href="/blog/?p=398#step1">Create a fonts swc</a>;</li>
<li><a href="/blog/?p=398#step2">Ensure your compiler includes every font in your swc</a>; and</li>
<li>That&#8217;s it! <a href="/blog/?p=398#step3">Use your embedded fonts</a></li>
</ol>
<p><span id="more-398"></span></p>
<p><strong><a name="step1">1. Create a fonts swc</a></strong></p>
<p>Open Flash, create a new document, right-click on the Library panel and select &#8216;New Font&#8230;&#8217;</p>
<p><a href="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/newfont.gif"><img class="alignnone size-medium wp-image-401" title="newfont" src="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/newfont.gif" alt="" width="307" height="382" /></a></p>
<p>In the resulting &#8216;Font Properties&#8217; dialog choose the font you want using the dropdown, uncheck all the checkboxes and ensure that the &#8216;Name&#8217; field exactly matches the &#8216;Font&#8217; dropdown. (just to explain: you don&#8217;t have to make them match but it makes things easier for you. FlexBuilder will take the name of the font from the &#8216;Font&#8217; dropdown and not the &#8216;Name&#8217;, which is counter-intuitive and confusing, so making them both match avoids this confusion)</p>
<p><a href="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/fontproperties.gif"><img class="alignnone size-medium wp-image-402" title="fontproperties" src="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/fontproperties-450x175.gif" alt="" width="450" height="175" /></a></p>
<p>Repeat this process until you&#8217;ve got all the fonts you want in the library. Then ensure that &#8216;Export SWC&#8217; is checked in your &#8216;Publish Settings&#8217; and you&#8217;re good to go!</p>
<p><a href="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/exportswc.gif"><img class="alignnone size-medium wp-image-402" title="exportswc" src="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/exportswc-450x119.gif" alt="" width="450" height="119" /></a></p>
<p>Export the swc to wherever you want it to live - which would be somewhere in your FlexBuilder project, ideally - and compile that puppy!</p>
<p><strong><a name="step2">2. Ensure your compiler includes every font in your swc</a></strong></p>
<p>Now, over in FlexBuilder open your project&#8217;s &#8216;Properties&#8217; dialog, go to the &#8216;ActionScript Compiler&#8217; tab and add something like the following to the &#8216;Additional compiler arguments:&#8217; textfield:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;">-include-libraries path<span style="color: #66cc66;">/</span>to<span style="color: #66cc66;">/</span>your<span style="color: #66cc66;">/</span>fonts.<span style="color: #006600;">swc</span></pre></div></div>

<p>Where &#8216;path/to/your/fonts.swc&#8217; is the actual path to the fonts swc you just created (this will always be a relative path, relative to your project&#8217;s source directory). &#8216;-include-libraries&#8217; will ensure that you include every last font in the swc.</p>
<p><a href="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/includelibraries.gif"><img class="alignnone size-medium wp-image-404" title="includelibraries" src="http://richtextformat.co.uk/blog/wp-content/uploads/2009/01/includelibraries-450x107.gif" alt="" width="450" height="107" /></a></p>
<p><strong><a name="step3">3. Use your embedded fonts</a></strong></p>
<p>That&#8217;s all there is to it! You can now simply access your fonts by the name you gave them in the swc:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">textFormat</span>:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;BetonCross-Light&quot;</span>, <span style="color: #cc66cc;">12</span>, 0x000000<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=398</wfw:commentRss>
		</item>
		<item>
		<title>Christmas eCard</title>
		<link>http://richtextformat.co.uk/blog/?p=396</link>
		<comments>http://richtextformat.co.uk/blog/?p=396#comments</comments>
		<pubDate>Sat, 20 Dec 2008 17:07:58 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=396</guid>
		<description><![CDATA[I made an eCard for my friends and clients yesterday. With the exception of those who actually make half-decent ones - like my old client TripleTruth - eCards are usually pretty lousy so i just wanted to mess about for a laugh really and make a really amateur effort.
You can find my bad eCard here. [...]]]></description>
			<content:encoded><![CDATA[<p>I made an eCard for my friends and clients yesterday. With the exception of those who actually make half-decent ones - like my old client <a href="http://www.tripletruth.co.uk">TripleTruth</a> - eCards are usually pretty lousy so i just wanted to mess about for a laugh really and make a really amateur effort.</p>
<p>You can find my bad eCard <a href="http://richtextformat.co.uk/proofs/ecard/ecard.swf">here</a>. The misspelling in it was a genuine mistake that I thought I&#8217;d keep. I hope it makes you smile and I wish you a merry Christmas and a happy new year.</p>
<p><i>See you in 2009!</i></p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=396</wfw:commentRss>
		</item>
		<item>
		<title>Tile Designer</title>
		<link>http://richtextformat.co.uk/blog/?p=160</link>
		<comments>http://richtextformat.co.uk/blog/?p=160#comments</comments>
		<pubDate>Wed, 17 Dec 2008 22:45:22 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[BarCampBrighton2]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[genetic algorithm]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=160</guid>
		<description><![CDATA[Over the summer of 2008 I decorated my bathroom. I knew from doing my kitchen the year before that the most painstaking and time-consuming part of the job would be tiling and I wondered if there was anyway it could be made less so?
I had just come back from BarCampBrighton, where I was inspired by [...]]]></description>
			<content:encoded><![CDATA[<p>Over the summer of 2008 I decorated my bathroom. I knew from doing my kitchen the year before that the most painstaking and time-consuming part of the job would be tiling and I wondered if there was anyway it could be made less so?</p>
<p>I had just come back from <a href="http://barcampbrighton.org/">BarCampBrighton</a>, where I was inspired by <a href="http://ollieglass.com/">Ollie Glass</a>&#8216; workshop on writing genetic algorithms; something that turned out to be really simple. So I sat down, chucked some code together and produced this Tile Designer swf, built on a genetic algorithm:</p>

<object	type="application/x-shockwave-flash"
			data="http://richtextformat.co.uk/blog/wp-content/uploads/2008/08/tiledesigner.swf"
			width="450"
			height="450">
	<param name="movie" value="http://richtextformat.co.uk/blog/wp-content/uploads/2008/08/tiledesigner.swf" />
</object>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=160</wfw:commentRss>
		</item>
		<item>
		<title>We won at the DiMAs !!!</title>
		<link>http://richtextformat.co.uk/blog/?p=383</link>
		<comments>http://richtextformat.co.uk/blog/?p=383#comments</comments>
		<pubDate>Sat, 29 Nov 2008 10:20:07 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[Events]]></category>

		<category><![CDATA[FlashBrighton]]></category>

		<category><![CDATA[News]]></category>

		<category><![CDATA[DIMAs]]></category>

		<category><![CDATA[DiMAs2008]]></category>

		<category><![CDATA[Rider Spoke]]></category>

		<category><![CDATA[zenbullets]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=383</guid>
		<description><![CDATA[On Thursday 27th of November - two days ago - a handful of other FlashBrighton members and I were at the DiMAs awards in Hove&#8217;s All Saints Church. In a previous blogpost I said, amongst other things, that FlashBrighton was a shoe-in for the &#8220;Strongest Community&#8221; award at the DiMAs. I really felt that it [...]]]></description>
			<content:encoded><![CDATA[<p>On Thursday 27th of November - two days ago - a handful of other FlashBrighton members and I were at the DiMAs awards in Hove&#8217;s All Saints Church. In <a href="http://richtextformat.co.uk/blog/?p=346">a previous blogpost</a> I said, amongst other things, that FlashBrighton was a shoe-in for the &#8220;Strongest Community&#8221; award at the DiMAs. I really felt that it was a done-deal, not because of any weakness on the part of the opposition, but because of <a href="http://richtextformat.co.uk/blog/?p=346#achievements">all the great things we&#8217;ve achieved</a>.</p>
<p><img class="alignnone size-medium wp-image-386" title="dimas" src="http://richtextformat.co.uk/blog/wp-content/uploads/2008/11/dimas.jpg" alt="" width="450" height="219" /></p>
<p>And I was right, WE WON !!! It&#8217;s fantastic but I&#8217;m not going to say too much about it because Matt Pearson&#8217;s has already a great job of that <a href="http://actionscripter.co.uk/blog/?p=185">here</a>. Instead let me say this:</p>
<p>I was REALLY, REALLY pleased to see Matt Pearson pick the &#8216;Best Blog&#8217; award for his <a href="http://zenbullets.com/blog/">zenbullets blog</a>. I really admire good writing and zenbullets certainly has that. The delivery and content are excellent, and his documentation of the victimisation Sussex Police have only-just ceased to put him through is just captivating. For these reasons I also felt that Matt would be a shoe-in in his category, and was pleased to see that I was right again.</p>
<p>Obviously I had a hand in the FlashBrighton award but what might not be so obvious is that I also had a hand in a second award. <a href="http://www.blasttheory.co.uk/">Blast Theory</a> were nominated in the &#8220;Digital Collaberation&#8221; category. Now, I thought that it was Blast Theory as a whole that was nominated but it turned out that it was specifically their &#8216;Rider Spoke&#8217; project. In <a href="http://www.blasttheory.co.uk/bt/work_rider_spoke.html">the words of Blast Theory</a>, &#8216;Rider Spoke is a work for cyclists combining theatre with          game play and state of the art technology&#8217;. Part of the work was a Flash front-end for a console cyclists had attached to the handlebars of their bikes (you can see some images of that in action <a href="http://richtextformat.co.uk/riderSpoke1.php">here</a>). Twas I wot made that Flash front-end.</p>
<p>And &#8216;Rider Spoke&#8217; won too !!! So as Flash coder and copywriter, I came away from the night feeling like I had an important hand in not-one-but-two awards! I also came away from the night feeling quite drunk.</p>
<p>Finally, I would like to mention that Brightonian Flash agencies <a href="http://www.littleloud.com/">LittleLoud</a> &amp; <a href="http://www.kerb.co.uk/">Kerb</a>, freelancer <a href="http://www.animnation.co.uk/">Sarah Bird</a> and my former employer <a href="http://www.dbeducation.co.uk/home">DigitalBrain</a> were also nominated in other categories but sadly failed to pick up awards. FlashBrighton members were nominated in so many categories that it was inevitable that some of us weren&#8217;t going to get our just desserts. And anyway, LittleLoud are up for a BAFTA this weekend, so things aren&#8217;t really too bad for them. Maybe next year guys?</p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=383</wfw:commentRss>
		</item>
		<item>
		<title>Flash &#038; Flex Freelancers in Brighton</title>
		<link>http://richtextformat.co.uk/blog/?p=369</link>
		<comments>http://richtextformat.co.uk/blog/?p=369#comments</comments>
		<pubDate>Fri, 21 Nov 2008 09:05:53 +0000</pubDate>
		<dc:creator>rich</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[News]]></category>

		<category><![CDATA[OOP]]></category>

		<category><![CDATA[Brighton]]></category>

		<category><![CDATA[Designer]]></category>

		<category><![CDATA[Developer]]></category>

		<category><![CDATA[Freelancer]]></category>

		<category><![CDATA[Freelancers]]></category>

		<category><![CDATA[Sussex]]></category>

		<guid isPermaLink="false">http://richtextformat.co.uk/blog/?p=369</guid>
		<description><![CDATA[Spurred on by this page on Kristen Akermans&#8217;s site and this blog post on Matt Pearson&#8217;s blog - which both list freelancers available in Brighton and which both link kindly to me - I decided I should return the favour. So what follows is a list of those people I recommend if you&#8217;re looking for [...]]]></description>
			<content:encoded><![CDATA[<p>Spurred on by <a href="http://www.sting.co.uk/links.htm">this page</a> on <a href="http://www.sting.co.uk/">Kristen Akermans&#8217;s site</a> and this <a href="http://actionscripter.co.uk/blog/?p=168">blog post</a> on <a href="http://actionscripter.co.uk/blog/">Matt Pearson&#8217;s blog</a> - which both list freelancers available in Brighton and which both link kindly to me - I decided I should return the favour. So what follows is a list of those people I recommend if you&#8217;re looking for a freelancer. Obviously I top my own list - I&#8217;ll be wanting the work first, thank you :) - but if I&#8217;m busy I thorougly recommend the other guys and gals (listed alphabetically)  here:</p>
<p><strong>Designers</strong></p>
<p>Charis Mystakidou: <a href="http://www.wiredportfolio.com/">wiredportfolio.com</a><br />
Kristen Akerman: <a href="http://www.sting.co.uk/">sting.co.uk</a><br />
Luke Hornsby: <a href="http://www.flamingpixels.co.uk">flamingpixels.co.uk</a><br />
Tim Frost: <a href="http://www.bullandgate.com">bullandgate.com</a></p>
<p><strong>Developers</strong></p>
<p>Richard Willis: <a href="http://www.richtextformat.co.uk/">richtextformat.co.uk</a><br />
Matt Pearson: <a href="http://www.actionscripter.co.uk/">actionscripter.co.uk</a><br />
Matt Sayers: <a href="http://www.soplausable.com/">soplausable.com</a><br />
Neil Manuell: <a href="http://www.revisual.co.uk/">revisual.co.uk</a><br />
Nikos Chagialas: <a href="http://nikos.devgallery.com/">devgallery.com</a><br />
Owen Bennett: <a href="http://www.steamboy.co.uk/">steamboy.co.uk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://richtextformat.co.uk/blog/?feed=rss2&amp;p=369</wfw:commentRss>
		</item>
	</channel>
</rss>

