<?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>BetaDesigns( Blog ) &#187; Test Driven Design</title>
	<atom:link href="http://www.betadesigns.co.uk/Blog/category/test-driven-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.betadesigns.co.uk/Blog</link>
	<description>Flex and Component Development</description>
	<lastBuildDate>Sat, 31 Dec 2011 13:04:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Adobe Max, Debugging, Profiling and TDD</title>
		<link>http://www.betadesigns.co.uk/Blog/2010/11/18/adobe-max-debugging-profiling-and-tdd/</link>
		<comments>http://www.betadesigns.co.uk/Blog/2010/11/18/adobe-max-debugging-profiling-and-tdd/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 13:39:37 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[Test Driven Design]]></category>
		<category><![CDATA[AdobeMax]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Profling]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.betadesigns.co.uk/Blog/?p=324</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="256"><param name="movie" value="http://images.tv.adobe.com/swf/player.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="FlashVars" value="fileID=8239&context=648&embeded=true&environment=production"></param><embed src="http://images.tv.adobe.com/swf/player.swf" flashvars="fileID=8239&context=648&embeded=true&environment=production" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="256"></embed></object></p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fwww.betadesigns.co.uk%2FBlog%2F%3Fp%3D324&count=horizontal&related=&text=Adobe%20Max%2C%20Debugging%2C%20Profiling%20and%20TDD' class='twitter-share-button' data-text='Adobe Max, Debugging, Profiling and TDD' data-url='http://www.betadesigns.co.uk/Blog/?p=324' data-counturl='http://www.betadesigns.co.uk/Blog/2010/11/18/adobe-max-debugging-profiling-and-tdd/' data-count='horizontal' data-via='Omnipitence'></a>]]></content:encoded>
			<wfw:commentRss>http://www.betadesigns.co.uk/Blog/2010/11/18/adobe-max-debugging-profiling-and-tdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting a MX component to a Spark Component.</title>
		<link>http://www.betadesigns.co.uk/Blog/2010/06/10/converting-a-mx-component-to-a-spark-component/</link>
		<comments>http://www.betadesigns.co.uk/Blog/2010/06/10/converting-a-mx-component-to-a-spark-component/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 23:27:56 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Test Driven Design]]></category>
		<category><![CDATA[Advanced Component Development]]></category>
		<category><![CDATA[Color Picker]]></category>
		<category><![CDATA[colorPicker]]></category>
		<category><![CDATA[converting MX to Spark]]></category>
		<category><![CDATA[mx components]]></category>
		<category><![CDATA[mx:colorpicker]]></category>
		<category><![CDATA[spark component architecture]]></category>
		<category><![CDATA[spark components]]></category>

		<guid isPermaLink="false">http://www.betadesigns.co.uk/Blog/?p=237</guid>
		<description><![CDATA[In this brief set of posts I wanted to document how to convert a simple MX component over to a Spark component. I have chosen to convert the MX ColorPicker because it is one of the components that Adobe hasn't moved over to the Spark framework yet as well as being the component that I [...]]]></description>
			<content:encoded><![CDATA[<p>In this brief set of posts I wanted to document how to convert a simple MX component over to a Spark component. I have chosen to convert the MX ColorPicker because it is one of the components that Adobe hasn't moved over to the Spark framework yet as well as being the component that I used to learn the Flex3 Framework. You can see the outcome and view the source of that in my previous posts from a couple of years ago <a href="http://www.betadesigns.co.uk/Blog/2008/06/24/custom-color-picker-source/">here</a> and <a href="http://www.betadesigns.co.uk/Blog/2008/05/19/custom-kuler-style-color-picker/">here</a></p>
<p>Below you can see the three components.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ExampleProject_1744289458"
			class="flashmovie"
			width="500"
			height="350">
	<param name="movie" value="http://www.betadesigns.co.uk/Examples/posts/ConvertingMXtoSparkComponent/SparkColorPicker/ExampleProject.swf" />
	<param name="wmode" value="transparent" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.betadesigns.co.uk/Examples/posts/ConvertingMXtoSparkComponent/SparkColorPicker/ExampleProject.swf"
			name="fm_ExampleProject_1744289458"
			width="500"
			height="350">
		<param name="wmode" value="transparent" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
The Spark component does all the stuff the old MX one does like keyboard movement, selectedIndex, selectedColor, colorLabel, etc.. In addition I also added the ability to set/get the selectedItem and dispatching indexChange events.</p>
<p>To begin with lets look at what the current color picker does.<span id="more-237"></span></p>
<p>From the <a href="http://docs.brajeshwar.com/as3/mx/controls/ColorPicker.html">docs</a> we can see that the color picker has the following properties and events. We are ignoring the <b>Styles</b> because these will be handled by the skins and not the components. I have also decided that the TextField is part of the Skin and not the responsibility of the component so we will be ignoring the <b>showTextField</b> property.</p>
<pre class="flex">&nbsp;
&lt;mx:ColorPicker
    Properties
    colorField=<span style="color: #ff0000;">&quot;color&quot;</span>
    labelField=<span style="color: #ff0000;">&quot;label&quot;</span>
    selectedColor=<span style="color: #ff0000;">&quot;0x000000&quot;</span>
    selectedIndex=<span style="color: #ff0000;">&quot;0&quot;</span>
    showTextField=<span style="color: #ff0000;">&quot;true|false&quot;</span>
&nbsp;
    Styles...
&nbsp;
    <span style="color: #000000;">Events</span>
    change=<span style="color: #ff0000;">&quot;No default&quot;</span>
    close=<span style="color: #ff0000;">&quot;No default&quot;</span>
    enter=<span style="color: #ff0000;">&quot;No default&quot;</span>
    itemRollOut=<span style="color: #ff0000;">&quot;No default&quot;</span>
    itemRollOver=<span style="color: #ff0000;">&quot;No default&quot;</span>
    open=<span style="color: #ff0000;">&quot;No default&quot;</span>
    /&gt;
&nbsp;</pre>
<p>Next if we look at the default MX ColorPicker we can see that there appears to only be 2 visual elements the preview panel and the drop down panel. So we know we need two classes one for each of them and one more to hold them together the actual SparkColorPicker Class. This classes skin will simply hold the other skin parts together and be used for managing the other two classes.<br />
To begin with lets start by building the simplest item so that we can get something on the screen straight away.<br />
We know it should should take a data item and that we should probably pass the colorField and labelField properties to it from the main class incase they are required.<br />
So we have our simple ISparkColorPreviewPanel Interface ( comments omitted but are in the included files )</p>
<div class="scroll">
<pre class="flex">&nbsp;
<span style="color: #5b7bff; font-weight: bold;">public</span> interface ISparkColorPreviewPanel <span style="color: #5b7bff; font-weight: bold;">extends</span> IEventDispatcher
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> selectedColor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : uint;
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> selectedColor<span style="color: #000000;">&#40;</span> value : uint <span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>;
&nbsp;
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> colorField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : String;
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> colorField<span style="color: #000000;">&#40;</span> value : String <span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>;
&nbsp;
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> labelField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : String;
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> labelField<span style="color: #000000;">&#40;</span> value : String <span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>;
&nbsp;
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> data<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : Object;
	<span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> data<span style="color: #000000;">&#40;</span> value : Object <span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
</div>
<p>I would normally start writing unit tests for this interface now but as this is a rather small class that consists of only getters and setters I won't bother for this example. Lets just write the concrete class.</p>
<div class="scrolllarge">
<pre class="flex">&nbsp;
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #9e12cf; font-weight: bold;">class</span> SparkColorPickerPreviewPanel <span style="color: #5b7bff; font-weight: bold;">extends</span> SkinnableComponent
		<span style="color: #5b7bff; font-weight: bold;">implements</span> ISparkColorPreviewPanel
<span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> SparkColorPickerPreviewPanel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #5b7bff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		init<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">private</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> _selectedColor : uint = 0x000000;
&nbsp;
	<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
	<span style="color: #3f5fc4; font-style: italic;">/**
	 * @inheritDoc
	 */</span>
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> selectedColor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : uint
	<span style="color: #000000;">&#123;</span>
		<span style="color: #5b7bff; font-weight: bold;">return</span> _selectedColor;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> selectedColor<span style="color: #000000;">&#40;</span> value : uint <span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>
	<span style="color: #000000;">&#123;</span>
		_selectedColor = value;
		invalidateProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">private</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> _colorField : String;
&nbsp;
	<span style="color: #3f5fc4; font-style: italic;">/**
	 * @inheritDoc
	 */</span>
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> colorField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:String
	<span style="color: #000000;">&#123;</span>
		<span style="color: #5b7bff; font-weight: bold;">return</span> _colorField;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> colorField<span style="color: #000000;">&#40;</span>value:String<span style="color: #000000;">&#41;</span>:<span style="color: #5b7bff; font-weight: bold;">void</span>
	<span style="color: #000000;">&#123;</span>
		_colorField = value;
		invalidateProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">private</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> _labelField : String;
&nbsp;
	<span style="color: #3f5fc4; font-style: italic;">/**
	 * @inheritDoc
	 */</span>
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> labelField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:String
	<span style="color: #000000;">&#123;</span>
		<span style="color: #5b7bff; font-weight: bold;">return</span> _labelField;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> labelField<span style="color: #000000;">&#40;</span>value:String<span style="color: #000000;">&#41;</span>:<span style="color: #5b7bff; font-weight: bold;">void</span>
	<span style="color: #000000;">&#123;</span>
		_labelField = value;
		invalidateProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">private</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> _data : Object;
&nbsp;
	<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
	<span style="color: #3f5fc4; font-style: italic;">/**
	 * @inheritDoc
	 */</span>
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">get</span> data<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:Object
	<span style="color: #000000;">&#123;</span>
		<span style="color: #5b7bff; font-weight: bold;">return</span> _data;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> <span style="color: #5b7bff; font-weight: bold;">set</span> data<span style="color: #000000;">&#40;</span>value:Object<span style="color: #000000;">&#41;</span>:<span style="color: #5b7bff; font-weight: bold;">void</span>
	<span style="color: #000000;">&#123;</span>
		_data = value;
		invalidateProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//-------------------------------------------------------</span>
	<span style="color: #009900; font-style: italic;">// PRIVATE METHODS</span>
	<span style="color: #009900; font-style: italic;">//-------------------------------------------------------</span>
&nbsp;
	<span style="color: #5b7bff; font-weight: bold;">private</span> <span style="color: #009900; font-weight: bold;">function</span> init<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>
	<span style="color: #000000;">&#123;</span>
		buttonMode = <span style="color: #5b7bff; font-weight: bold;">true</span>;
		mouseEnabled = <span style="color: #5b7bff; font-weight: bold;">true</span>;
		useHandCursor = <span style="color: #5b7bff; font-weight: bold;">true</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
</div>
<p>This class doesn't really do anything except hold data and setup some default values so that it will act like a button it's all pretty self explanatory.</p>
<p>The next class we have to make is the default MX style preview panel as follows.</p>
<div class="scrolllarge" >
<pre class="flex"><ol start="2"><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;s:Skin xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	&lt;!-- host component --&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	&lt;fx:Metadata&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000;">&#91;</span>HostComponent<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;co.uk.betadesigns.components.colorpicker.SparkColorPickerPreviewPanel&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	&lt;/fx:Metadata&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	&lt;fx:Script&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		&lt;!<span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> borderWidth : Number = <span style="color: #000000;">3</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> arrowBorderWidth : Number = <span style="color: #000000;">2</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> panelWidth : Number = <span style="color: #000000;">22</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> panelHeight : Number = <span style="color: #000000;">22</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	&lt;/fx:Script&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	&lt;s:Group&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		&lt;s:Graphic x=<span style="color: #ff0000;">&quot;0&quot;</span> y=<span style="color: #ff0000;">&quot;0&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;!--BORDER--&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;s:Rect height=<span style="color: #ff0000;">&quot;{ panelWidth }&quot;</span> width=<span style="color: #ff0000;">&quot;{ panelHeight }&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;s:stroke&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;s:SolidColorStroke color=<span style="color: #ff0000;">&quot;0x000000&quot;</span> weight=<span style="color: #ff0000;">&quot;1&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;/s:stroke&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;s:LinearGradient rotation=<span style="color: #ff0000;">&quot;90&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">						&lt;s:entries&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">							&lt;s:GradientEntry color=<span style="color: #ff0000;">&quot;0xFFFFFF&quot;</span> ratio=<span style="color: #ff0000;">&quot;0.00&quot;</span> alpha=<span style="color: #ff0000;">&quot;1&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">							&lt;s:GradientEntry color=<span style="color: #ff0000;">&quot;0xCCCCCC&quot;</span> ratio=<span style="color: #ff0000;">&quot;0.33&quot;</span> alpha=<span style="color: #ff0000;">&quot;1&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">							&lt;s:GradientEntry color=<span style="color: #ff0000;">&quot;0x8E8E8E&quot;</span> ratio=<span style="color: #ff0000;">&quot;0.66&quot;</span> alpha=<span style="color: #ff0000;">&quot;1&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">						&lt;/s:entries&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;/s:LinearGradient&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;/s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;/s:Rect&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;!--INNER COLOR--&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;s:Rect</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				id=<span style="color: #ff0000;">&quot;innerColor&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				x=<span style="color: #ff0000;">&quot;{ borderWidth }&quot;</span> y=<span style="color: #ff0000;">&quot;{ borderWidth }&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				height=<span style="color: #ff0000;">&quot;{ panelHeight - ( borderWidth * 2 ) }&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				width=<span style="color: #ff0000;">&quot;{ panelWidth - ( borderWidth * 2 ) }&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;s:SolidColor color=<span style="color: #ff0000;">&quot;{ hostComponent.selectedColor }&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;/s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;/s:Rect&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;!--BOTTOM RIGHT ARROW BOX--&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;s:Rect</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				id=<span style="color: #ff0000;">&quot;arrowBox&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				x=<span style="color: #ff0000;">&quot;{ panelWidth - ( borderWidth * 3 ) }&quot;</span> y=<span style="color: #ff0000;">&quot;{ panelHeight - ( borderWidth * 3 ) }&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				height=<span style="color: #ff0000;">&quot;{ borderWidth * 3 }&quot;</span> width=<span style="color: #ff0000;">&quot;{ borderWidth * 3 }&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;s:LinearGradient rotation=<span style="color: #ff0000;">&quot;90&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">						&lt;s:entries&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">							&lt;s:GradientEntry color=<span style="color: #ff0000;">&quot;0xCCCCCC&quot;</span> ratio=<span style="color: #ff0000;">&quot;0.33&quot;</span> alpha=<span style="color: #ff0000;">&quot;1&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">							&lt;s:GradientEntry color=<span style="color: #ff0000;">&quot;0x8E8E8E&quot;</span> ratio=<span style="color: #ff0000;">&quot;0.66&quot;</span> alpha=<span style="color: #ff0000;">&quot;1&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">						&lt;/s:entries&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;/s:LinearGradient&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;/s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;/s:Rect&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;!--ARROW --&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;s:Path data=<span style="color: #ff0000;">&quot;M { arrowBox.x + arrowBorderWidth } { arrowBox.y + arrowBorderWidth }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { arrowBox.x + arrowBox.width - arrowBorderWidth } { arrowBox.y + arrowBorderWidth }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { arrowBox.x + ( arrowBox.width / 2 ) } { arrowBox.y + ( arrowBox.height - ( arrowBorderWidth * 1.5 ) ) }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { arrowBox.x + arrowBorderWidth } { arrowBox.y + arrowBorderWidth }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;s:stroke&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;s:SolidColorStroke id=<span style="color: #ff0000;">&quot;arrowStroke&quot;</span> color=<span style="color: #ff0000;">&quot;0x000000&quot;</span> weight=<span style="color: #ff0000;">&quot;1&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;/s:stroke&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;s:SolidColor color=<span style="color: #ff0000;">&quot;0x000000&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;/s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;/s:Path&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;!--INNER BORDER--&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;s:Path data=<span style="color: #ff0000;">&quot;M { innerColor.x } { innerColor.y }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { innerColor.x + innerColor.width } { innerColor.y }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { innerColor.x + innerColor.width } { arrowBox.y - arrowStroke.weight }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { arrowBox.x - arrowStroke.weight } { arrowBox.y - arrowStroke.weight }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { arrowBox.x - arrowStroke.weight } { innerColor.y + innerColor.height }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { innerColor.x } { innerColor.y + innerColor.height }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					L { innerColor.x } { innerColor.y }</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">					&quot;</span>&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;s:stroke&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">					&lt;s:SolidColorStroke color=<span style="color: #ff0000;">&quot;0x000000&quot;</span> weight=<span style="color: #ff0000;">&quot;1&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.5&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				&lt;/s:stroke&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;/s:Path&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		&lt;/s:Graphic&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		&lt;s:filters&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			&lt;s:DropShadowFilter</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				distance=<span style="color: #ff0000;">&quot;1&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		&lt;/s:filters&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	&lt;/s:Group&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/s:Skin&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
<p>In this class we are simply setting up the way in which the preview should look using the new Group and Graphic elements. The important things here are that we set the HostComponent to our custom SparkColorPickerPreview class. And that we link our Fill to our host component on the following line.</p>
<div class="scroll">
<pre class="flex"><ol start="51"><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    &lt;s:SolidColor color=<span style="color: #ff0000;">&quot;{ hostComponent.selectedColor }&quot;</span>/&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/s:fill&gt;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
<p>That allows our color to be updated everytime the color is set on the hostComponent.</p>
<p>We can test this by simply putting the following code in an example project.</p>
<div class="scroll">
<pre class="flex">&nbsp;
&lt;colorpicker:SparkColorPickerPreviewPanel selectedColor=<span style="color: #ff0000;">&quot;0xFF0000&quot;</span> /&gt;
&nbsp;</pre>
</div>
<p>I have set my version up with a default.css file and skin so I don't need to reference one here if you want to know how to do that then see this post on <a href="http://www.betadesigns.co.uk/Blog/2010/05/14/default-skin-for-custom-flashbuilder-components/">Default Skin for custom FlashBuilder components.</a> otherwise simply add the skin file as the skinClass like follows.</p>
<div class="scroll">
<pre class="flex">&nbsp;
&lt;colorpicker:SparkColorPickerPreviewPanel selectedColor=<span style="color: #ff0000;">&quot;0xFF0000&quot;</span>
skinClass=<span style="color: #ff0000;">&quot;co.uk.betadesigns.components.colorpicker.skins.mx.MXPreviewSkin&quot;</span>/&gt;
&nbsp;</pre>
</div>
<p>In the next post I will walk through testing and creating a SparkColorPickerDropDownPanel, after that we will look at creating the MxDropDownPanelSkin and a keyboardManager for handling input from the user to move around the dataprovider. Once we have our PreviewPanel and DropDownPanel complete we will then move onto creating the SparkColorPicker class to pull it all together with the skins. Or you can just download the source files here and work your way through them.<br />
I hope this post was useful and I appreciate any comments, suggestions or criticism.</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fwww.betadesigns.co.uk%2FBlog%2F%3Fp%3D237&count=horizontal&related=&text=Converting%20a%20MX%20component%20to%20a%20Spark%20Component.' class='twitter-share-button' data-text='Converting a MX component to a Spark Component.' data-url='http://www.betadesigns.co.uk/Blog/?p=237' data-counturl='http://www.betadesigns.co.uk/Blog/2010/06/10/converting-a-mx-component-to-a-spark-component/' data-count='horizontal' data-via='Omnipitence'></a>]]></content:encoded>
			<wfw:commentRss>http://www.betadesigns.co.uk/Blog/2010/06/10/converting-a-mx-component-to-a-spark-component/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FlexUnit4 &amp; Parsley</title>
		<link>http://www.betadesigns.co.uk/Blog/2010/04/29/flexunit4-parsley/</link>
		<comments>http://www.betadesigns.co.uk/Blog/2010/04/29/flexunit4-parsley/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 22:14:28 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Test Driven Design]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[flashbuilder]]></category>
		<category><![CDATA[FlexUnit]]></category>
		<category><![CDATA[FlexUnit4]]></category>
		<category><![CDATA[Parsley]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Test Driven Developement]]></category>
		<category><![CDATA[Unit Test]]></category>
		<category><![CDATA[UnitTest]]></category>
		<category><![CDATA[UnitTesting]]></category>

		<guid isPermaLink="false">http://www.betadesigns.co.uk/Blog/?p=177</guid>
		<description><![CDATA[For the last six months I have been working on a rather large enterprise application that uses parsley as it's main Dependency Injection Framework. This has led to many complex class' that contain multiple injected models, VO and other elements. Recreating these items inside test harness can become very cumbersome if you have to create [...]]]></description>
			<content:encoded><![CDATA[<p>For the last six months I have been working on a rather large enterprise application that uses parsley as it's main Dependency Injection Framework. This has led to many complex class' that contain multiple injected models, VO and other elements. Recreating these items inside test harness can become very cumbersome if you have to create a large injection heirarchy. Consider the following example.<span id="more-177"></span></p>
<pre class="flex"><span style="color: #5b7bff; font-weight: bold;">private</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> _testClass : MyTestPM;
&nbsp;
<span style="color: #000000;">&#91;</span>Before<span style="color: #000000;">&#93;</span>
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> setup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
   _testClass = <span style="color: #5b7bff; font-weight: bold;">new</span> MyTestPM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   _testClass.<span style="color: #000000;">myFirstInjectedItem</span> = <span style="color: #5b7bff; font-weight: bold;">new</span> MyFirstInjectedItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   _testClass.<span style="color: #000000;">mySecondInjectedItem</span> = <span style="color: #5b7bff; font-weight: bold;">new</span> MySecondInjectedItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   _testClass.<span style="color: #000000;">myFirstInjectedItem</span>.<span style="color: #000000;">mySecondInjectedItem</span> =
         _testClass.<span style="color: #000000;">mySecondInjectedItem</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre>
<p>As you can see this can become complicated with the more injected items you have that can then have references to other injected items!</p>
<p>However there is a way to use the Parsley DI Framework to do all that work for you!.</p>
<p>1. Create a TestContext File that contains all the Injectable objects your test class/suite needs.</p>
<pre class="flex">&nbsp;
&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?&gt;
&lt;fx:Object xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span>
    xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>
    xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span>
	xmlns:spicefactory=<span style="color: #ff0000;">&quot;http://www.spicefactory.org/parsley&quot;</span>&gt;
	&lt;fx:Script&gt;
		&lt;!<span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #5b7bff; font-weight: bold;">import</span> co.<span style="color: #000000;">uk</span>.<span style="color: #000000;">betadesigns</span>.<span style="color: #000000;">domain</span>.<span style="color: #000000;">TestModel</span>;
			<span style="color: #5b7bff; font-weight: bold;">import</span> co.<span style="color: #000000;">uk</span>.<span style="color: #000000;">betadesigns</span>.<span style="color: #000000;">domain</span>.<span style="color: #000000;">TestModel2</span>;
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span>&gt;
	&lt;/fx:Script&gt;
	&lt;fx:Declarations&gt;
		&lt;spicefactory:Object type=<span style="color: #ff0000;">&quot;{ TestModel }&quot;</span> /&gt;
		&lt;spicefactory:Object type=<span style="color: #ff0000;">&quot;{ TestModel2 }&quot;</span> /&gt;
	&lt;/fx:Declarations&gt;
&nbsp;
&lt;/fx:Object&gt;
&nbsp;</pre>
<p>2. Next Create your TestClass.</p>
<pre class="flex"><span style="color: #9e12cf; font-weight: bold;">package</span> flexUnitTests
<span style="color: #000000;">&#123;</span>
   <span style="color: #5b7bff; font-weight: bold;">import</span> co.<span style="color: #000000;">uk</span>.<span style="color: #000000;">betadesigns</span>.<span style="color: #000000;">domain</span>.<span style="color: #000000;">TestModel</span>;
   <span style="color: #5b7bff; font-weight: bold;">import</span> flexUnitTests.<span style="color: #000000;">context</span>.<span style="color: #000000;">TestContext</span>;
   <span style="color: #5b7bff; font-weight: bold;">import</span> flexunit.<span style="color: #000000;">framework</span>.<span style="color: #000000;">Assert</span>;
   <span style="color: #5b7bff; font-weight: bold;">import</span> org.<span style="color: #000000;">spicefactory</span>.<span style="color: #000000;">parsley</span>.<span style="color: #000000;">core</span>.<span style="color: #000000;">context</span>.<span style="color: #000000;">Context</span>;
   <span style="color: #5b7bff; font-weight: bold;">import</span> org.<span style="color: #000000;">spicefactory</span>.<span style="color: #000000;">parsley</span>.<span style="color: #000000;">flex</span>.<span style="color: #000000;">FlexContextBuilder</span>;
&nbsp;
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #9e12cf; font-weight: bold;">class</span> InjectableTestCase
<span style="color: #000000;">&#123;</span>
<span style="color: #009900; font-style: italic;">//Begin by injecting the class you want to test.</span>
<span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span>
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #b7cfe7; font-weight: bold;">var</span> model : TestModel;
&nbsp;
<span style="color: #000000;">&#91;</span>Before<span style="color: #000000;">&#93;</span>
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> setUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">//In the setup use the FlexContextBuilder to build</span>
	<span style="color: #009900; font-style: italic;">//your testContext that you created in step 1.</span>
	<span style="color: #b7cfe7; font-weight: bold;">var</span> cont : Context = FlexContextBuilder.<span style="color: #000000;">build</span><span style="color: #000000;">&#40;</span> TestContext <span style="color: #000000;">&#41;</span>;
	<span style="color: #009900; font-style: italic;">//Then add this test case to the context which will begin the</span>
	<span style="color: #009900; font-style: italic;">//Injection Process. This will be called before every test</span>
	<span style="color: #009900; font-style: italic;">//so your injected items will all be fresh and new.</span>
	cont.<span style="color: #000000;">createDynamicContext</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #000000;">addObject</span><span style="color: #000000;">&#40;</span> this <span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#91;</span>After<span style="color: #000000;">&#93;</span>
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> tearDown<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	model = <span style="color: #5b7bff; font-weight: bold;">null</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span>
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> AddMultipleModels1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">//Simple tests to show that the models are re-create</span>
	<span style="color: #009900; font-style: italic;">//every time a new test is run.</span>
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">counter</span>, <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>;
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">model2</span>.<span style="color: #000000;">counter</span>, <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>;
	model.<span style="color: #000000;">counter</span> ++;
	model.<span style="color: #000000;">model2</span>.<span style="color: #000000;">counter</span> ++;
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">counter</span>, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">model2</span>.<span style="color: #000000;">counter</span>, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span>
<span style="color: #5b7bff; font-weight: bold;">public</span> <span style="color: #009900; font-weight: bold;">function</span> AddMultipleModels2<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : <span style="color: #5b7bff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">//Simple tests to show that the models are re-create</span>
	<span style="color: #009900; font-style: italic;">//every time a new test is run.</span>
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">counter</span>, <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>;
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">model2</span>.<span style="color: #000000;">counter</span>, <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>;
	model.<span style="color: #000000;">counter</span> ++;
	model.<span style="color: #000000;">model2</span>.<span style="color: #000000;">counter</span> ++;
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">counter</span>, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;
	Assert.<span style="color: #000000;">assertEquals</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">&quot;Should only ever have one count.&quot;</span>,
		model.<span style="color: #000000;">model2</span>.<span style="color: #000000;">counter</span>, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
<p>Here is an <a href="http://www.betadesigns.co.uk/Examples/FlexUnit/FlexUnitParsleyExample.zip">example</a> FlashBuilder Project to show this in action.<br />
Hope this relives some stress when unit testing.</p>
<p>Of course you should remember that if you have hundreds or even thousands of tests that this probably isn't an ideal solution as parsley will parse the context file each and every time a test is run and although the overhead is minimal it will add up if you have soo many tests.</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fwww.betadesigns.co.uk%2FBlog%2F%3Fp%3D177&count=horizontal&related=&text=FlexUnit4%20%26amp%3B%20Parsley' class='twitter-share-button' data-text='FlexUnit4 &amp; Parsley' data-url='http://www.betadesigns.co.uk/Blog/?p=177' data-counturl='http://www.betadesigns.co.uk/Blog/2010/04/29/flexunit4-parsley/' data-count='horizontal' data-via='Omnipitence'></a>]]></content:encoded>
			<wfw:commentRss>http://www.betadesigns.co.uk/Blog/2010/04/29/flexunit4-parsley/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

