<?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>FlexOOP &#187; Component</title>
	<atom:link href="http://flexoop.com/category/flex/component/feed/" rel="self" type="application/rss+xml" />
	<link>http://flexoop.com</link>
	<description>Flex, AIR, ColdFusion, and everything in between</description>
	<lastBuildDate>Tue, 13 Jul 2010 03:56:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adding colspan to a datagrid</title>
		<link>http://flexoop.com/2009/03/adding-colspan-to-a-datagrid/</link>
		<comments>http://flexoop.com/2009/03/adding-colspan-to-a-datagrid/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 11:05:51 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[colspan]]></category>
		<category><![CDATA[DataGrid]]></category>

		<guid isPermaLink="false">http://flexoop.com/?p=158</guid>
		<description><![CDATA[Recently at my job, our User Interface guru came up with the design and interface that she wanted for our users. However, the design she came up with required adding a colspan to a datagrid. As many know who have tried it, this is not really a possibility right out of the box with a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently at my job, our User Interface guru came up with the design and interface that she wanted for our users.  However, the design she came up with required adding a colspan to a datagrid.  As many know who have tried it, this is not really a possibility right out of the box with a Flex DataGrid.  It is apparently a possibility with the AdvancedDataGrid, but I have just never really liked the visuals of the datagrid, especially with how it outputs the rows of data&#8230;it seems very cluttered to me when grouping is added.  Plus, I have a PagedArrayCollection that I wrote and use quite regularly, that (currently) does not play nicely with the AdvancedDataGrid (I think it has something to do with the grouping), and currently just works with the regular DataGrid.  So, in order to accommodate the business and my PagedArrayCollection, rather than just have multiple rows of data in multiple columns, I came up with a solution to allow for the spanning of multiple columns, as many as is necessary.</p>
<p>I tried to figure out, visually and programmatically, I could mimic the HTML table colspan.  My solution actually involves 2 datagrids + single datagrids as itemrenderers within the rows.  As Flex recycles its itemrenderers, this appeared to be a pretty practical solution.  My first datagrid is used solely for the headers.  I made the height of the datagrid match the height of the headers of the first datagrid, so all that is visible is the headers themselves.</p>
<div class="wp-caption alignleft" style="width: 788px"><img alt="DataGrid Header" src="http://flexoop.com/wp-content/uploads/images/DataGridHeader.png" title="DataGrid Header" width="778" height="23" /><p class="wp-caption-text">DataGrid Header</p></div>
<p>The code for this is as follows (notice the small height of the datagrid):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:DataGrid id=<span style="color: #ff0000;">&quot;headerDataGrid&quot;</span> x=<span style="color: #ff0000;">&quot;70&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;780&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;23&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ dataProvider }&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:columns<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Name&quot;</span> dataField=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Location&quot;</span> dataField=<span style="color: #ff0000;">&quot;location&quot;</span><span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Exp&quot;</span> dataField=<span style="color: #ff0000;">&quot;exp&quot;</span><span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:columns<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:DataGrid<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>From here I created another datagrid, but this one contains only a single column.  I also removed the headers from this datagrid as I will be using the datagrid headers from the previously created datagrid (headerDataGrid), so this one just looks like the rows from a datagrid.</p>
<div class="wp-caption alignleft" style="width: 658px"><img alt="DataGrid Body" src="http://flexoop.com/wp-content/uploads/images/DataGridBodyMain.png" title="Main DataGrid" width="648" height="232" /><p class="wp-caption-text">DataGrid Body</p></div>
<p>Once I had these 2 datagrids, I put them right next to each other so it looks like they&#8217;re actually the same datagrid, but without vertical lines between the columns.</p>
<p>The code for the 2nd grid is:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:DataGrid x=<span style="color: #ff0000;">&quot;70&quot;</span> y=<span style="color: #ff0000;">&quot;61&quot;</span> id=<span style="color: #ff0000;">&quot;dgMain&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;780&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;444&quot;</span> showHeaders=<span style="color: #ff0000;">&quot;false&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ dataProvider }&quot;</span> paddingTop=<span style="color: #ff0000;">&quot;0&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;0&quot;</span>
	variableRowHeight=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #0066CC;">selectable</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:columns<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;All data&quot;</span> dataField=<span style="color: #ff0000;">&quot;col1&quot;</span> itemRenderer=<span style="color: #ff0000;">&quot;com.flexoop.utility.renderer.ColSpanRowRenderer&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:columns<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:DataGrid<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>Both of these datagrids are bound to the same dataprovider.  This makes manipulation of the arraycollection extremely simple.  I had thought I would be writing my own sort and filter functions, overriding the headers, but I forgot that once these datagrids are bound to the same arraycollection, Flex automatically handles all of that and everything just works.  Simple! <img src='http://flexoop.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   The headertext and dataField are irrelevant in this datagrid as they will not be used.  I set the variableRowHeight=&#8221;true&#8221; so the itemrenderer will show the multiple rows of data correctly.</p>
<p>As you can see from the above code, I created a ColSpanRowRenderer itemRenderer.  This handles the final part of the colspanned datagrid&#8230;the actual colspan.</p>
<div class="wp-caption alignleft" style="width: 790px"><img alt="ColSpan Row Renderer" src="http://flexoop.com/wp-content/uploads/images/colspanrowrenderer.png" title="ColSpan Row Renderer" width="780" height="177" /><p class="wp-caption-text">ColSpan Row Renderer</p></div>
<p>The code for this looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:DataGrid id=<span style="color: #ff0000;">&quot;dgLocal&quot;</span> x=<span style="color: #ff0000;">&quot;0&quot;</span> y=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> showHeaders=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;23&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ data }&quot;</span> backgroundAlpha=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #0066CC;">selectable</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
	borderSides=<span style="color: #ff0000;">&quot;{ parentDocument.detailed ? 'bottom top' : 'bottom' }&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:columns<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Name&quot;</span> dataField=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Location&quot;</span> dataField=<span style="color: #ff0000;">&quot;location&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Exp&quot;</span> dataField=<span style="color: #ff0000;">&quot;exp&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:columns<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:DataGrid<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Text</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">&quot;{ parentDocument.detailed }&quot;</span> includeInLayout=<span style="color: #ff0000;">&quot;{ parentDocument.detailed }&quot;</span>
	<span style="color: #0066CC;">htmlText</span>=<span style="color: #ff0000;">&quot;This is where the detailed text will go.&amp;lt;br /&amp;gt;This is not formatted now but can be once it goes live&quot;</span> y=<span style="color: #ff0000;">&quot;22&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

<p>This is all contained within a VBox with all padding set to zero to aid in visual layout, and to make it look like it is a row in the dgMainBody datagrid.  The height of the datagrid forces it to just show the single row of data, with showHeaders=&#8221;false&#8221; again.  I bind it to the &#8220;data&#8221; value that is passed in to the itemrenderer, then output the properties of that data object within the single row datagrid.  I have a variable named &#8220;detailed&#8221; in the parentDocument (the page containing my header and main body datagrids).  This allows me to show or hide the extra colspanned row of data.  This was part of the requirement from the business, so I added it in.  As the header, main body, and colspanrowrenderers all need to be tightly coupled, I was not so worried about referring to the &#8220;parentDocument&#8221;.  Had this been something I was going to be moving around to other components, I would have tried to think of another solution.  The &#8220;includeInLayout&#8221; attribute will completely remove the &#8220;Text&#8221; box from the view, so as not to take up any space when it is not visible.  In order to prevent the user from selecting the single row datagrid item, I set &#8216;selectable=&#8221;false&#8221;&#8216;, then in the outer datagrid (dgMainBody), I set &#8216;selectable=&#8221;true&#8221;&#8216;.  This will then allow the user to select the complete itemrenderer (both datagrid row and colspanned text field).</p>
<p>I had found that when detailed=&#8217;false&#8217;, the single datagrid rows did not alternate colors, which made sense as they were all the first row.  In order to fix this problem, I set backgroundAlpha=&#8221;0&#8243; in the colspanrowrenderer.  This then used the colors of the dgMainBody datagrid for coloring the itemrenderer.  The final visual part was setting the borderSides=&#8221;bottom&#8221; or &#8220;bottom top&#8221; depending on whether the view was detailed or not.</p>
<p>The final part of getting this to look and act like a regular datagrid was to adjust the column widths of all of the ColSpanRowRenderer rows when the header items were moved, as the rows are not actually linked directly back to the dgHeader.  To catch these changes, I added a creationComplete=&#8221;init()&#8221; to the vbox in my ColSpanRowRenderer.  Then in my init() function (along with a setColumnWidth function):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	setColumnWidth<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	parentDocument.<span style="color: #006600;">headerDataGrid</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> DataGridEvent.<span style="color: #006600;">COLUMN_STRETCH</span>, setColumnWidth <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setColumnWidth<span style="color: #66cc66;">&#40;</span> event:DataGridEvent=<span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> _i:uint = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> _length:uint = parentDocument.<span style="color: #006600;">headerDataGrid</span>.<span style="color: #006600;">columns</span>.<span style="color: #0066CC;">length</span>;
	<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span> _i <span style="color: #66cc66;">&lt;</span> _length <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		dgLocal.<span style="color: #006600;">columns</span><span style="color: #66cc66;">&#91;</span> _i <span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">width</span> = parentDocument.<span style="color: #006600;">headerDataGrid</span>.<span style="color: #006600;">columns</span><span style="color: #66cc66;">&#91;</span> _i <span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">width</span>;
		_i++;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>At first, I was only changing the width of the column that was being stretched, but I found that the flash player must do some other computations on the other columns, so I just decided to loop over all of the columns and resize each one to match the header columns.  I found that I had to add a &#8216;render=&#8221;setColumnWidth()&#8221;&#8216; also as some of my columns were a little screwy at times.  This adds a slight adjustment after the page renders, but is not all that noticeable and fixes any column width issues I was having.</p>
<p>So the final product looks like this:</p>
<div class="wp-caption alignleft" style="width: 713px"><img alt="DataGrid With ColSpan" src="http://flexoop.com/wp-content/uploads/images/DataGridWithColSpan.png" title="DataGrid With ColSpan" width="703" height="319" /><p class="wp-caption-text">DataGrid With ColSpan</p></div>
<p>And code is <a href="/wp-content/uploads/code/DataGridColSpan/DataGridColSpan.mxml" target="_blank">DataGridColSpan.mxml</a> and <a href="/wp-content/uploads/code/DataGridColSpan/ColSpanRowRenderer.mxml" target="_blank">ColSpanRowRenderer.mxml</a></p>
<p>Hopefully I haven&#8217;t bored anyone to tears with my explanation, but I wanted to be sure that everyone understands my reasoning for doing everything that I did to the datagrids.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://flexoop.com/2009/03/adding-colspan-to-a-datagrid/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Update to MenuItem class</title>
		<link>http://flexoop.com/2009/02/update-to-menuitem-class/</link>
		<comments>http://flexoop.com/2009/02/update-to-menuitem-class/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 04:35:11 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MenuItem]]></category>
		<category><![CDATA[MenuItemWithChildren]]></category>

		<guid isPermaLink="false">http://flexoop.com/?p=156</guid>
		<description><![CDATA[I have recently begun using my MenuItem and MenuItemWithChildren classes at my work, and have made a slight modification to the code to lessen some of the code writing required. As I was using the menuItem class, I realized that when I selected the item, I was usually just calling some function based upon the [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently begun using my <a href="/2008/11/menuitem-class/" target"_blank">MenuItem and MenuItemWithChildren</a> classes at my work, and have made a slight modification to the code to lessen some of the code writing required.</p>
<p>As I was using the menuItem class, I realized that when I selected the item, I was usually just calling some function based upon the label of that menu item.  Using my updated MenuItem class, you can now pass in a function as one of the parameters.</p>
<p>My MenuItem class now looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">flexoop</span>.<span style="color: #006600;">utility</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MenuItem <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * properties
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _enabled:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _groupName:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _icon:<span style="color: #000000; font-weight: bold;">Class</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _label:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _menuHandler:<span style="color: #000000; font-weight: bold;">Function</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _toggled:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _type:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * getters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">enabled</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._enabled;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> groupName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._groupName;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> icon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #000000; font-weight: bold;">Class</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._icon;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> label<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._label;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> menuHandler<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #000000; font-weight: bold;">Function</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._menuHandler;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> toggled<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._toggled;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._type;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * setters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">enabled</span><span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._enabled = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> groupName<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._groupName = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> icon<span style="color: #66cc66;">&#40;</span> value:<span style="color: #000000; font-weight: bold;">Class</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._icon = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> label<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._label = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> menuHandler<span style="color: #66cc66;">&#40;</span> value:<span style="color: #000000; font-weight: bold;">Function</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._menuHandler = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> toggled<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._toggled = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Inspectable<span style="color: #66cc66;">&#40;</span>enumeration=separator,check,radio,normal<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._type = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MenuItem<span style="color: #66cc66;">&#40;</span> label:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, menuHandler:<span style="color: #000000; font-weight: bold;">Function</span>=<span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #0066CC;">enabled</span>:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;normal&quot;</span>, toggled:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, groupName:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, icon:<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: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">enabled</span> = <span style="color: #0066CC;">enabled</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">groupName</span> = groupName;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">icon</span> = icon;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">label</span> = label;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">menuHandler</span> = menuHandler;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">toggled</span> = toggled;
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">type</span> = <span style="color: #0066CC;">type</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>And similarly for the MenuItemWithChildren class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">flexoop</span>.<span style="color: #006600;">utility</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MenuItemWithChildren <span style="color: #0066CC;">extends</span> MenuItem <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * properties
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _children:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * getters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> children<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._children;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * setters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> children<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._children = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MenuItemWithChildren<span style="color: #66cc66;">&#40;</span> label:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, menuHandler:<span style="color: #000000; font-weight: bold;">Function</span>=<span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #0066CC;">enabled</span>:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;normal&quot;</span>, toggled:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, groupName:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, icon:<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: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span> label, menuHandler, <span style="color: #0066CC;">enabled</span>, <span style="color: #0066CC;">type</span>, toggled, groupName, icon <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The 2nd parameter is now the menuHandler function.  So in order to use this, you could set up something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> xmlns:flexoop=<span style="color: #ff0000;">&quot;com.flexoop.utility.*&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
&nbsp;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">MenuEvent</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;
&nbsp;
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flexoop</span>.<span style="color: #006600;">utility</span>.<span style="color: #006600;">MenuItemWithChildren</span>;
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flexoop</span>.<span style="color: #006600;">utility</span>.<span style="color: #006600;">MenuItem</span>;
&nbsp;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> menuData:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection;
&nbsp;
			<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<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: #000000; font-weight: bold;">var</span> menuItem:MenuItemWithChildren = <span style="color: #000000; font-weight: bold;">new</span> MenuItemWithChildren<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 1&quot;</span>, showMe <span style="color: #66cc66;">&#41;</span>;
				menuItem.<span style="color: #006600;">children</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 4&quot;</span>, showMe <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuItem.<span style="color: #006600;">children</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 5&quot;</span>, showMe <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> menuItem <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test2&quot;</span>, showMe <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test3&quot;</span>, showMe <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				mb.<span style="color: #006600;">dataProvider</span> = menuData;
&nbsp;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> menuItemHandler<span style="color: #66cc66;">&#40;</span> event:MenuEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #66cc66;">&#40;</span> event.<span style="color: #006600;">item</span> as MenuItem <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">menuHandler</span><span style="color: #66cc66;">&#40;</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> showMe<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
				Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'this was fired from my menuItem'</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:ApplicationControlBar id=<span style="color: #ff0000;">&quot;acb&quot;</span><span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:MenuBar id=<span style="color: #ff0000;">&quot;mb&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ menuData }&quot;</span> click=<span style="color: #ff0000;">&quot;menuItemHandler( event )&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:ApplicationControlBar<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>(I didn&#8217;t get a chance to test the above example code so, if anyone finds that something doesn&#8217;t work correctly, feel free to ping me about it and I&#8217;ll try to get it working properly).  It&#8217;s a somewhat basic example as all items point to the same function, but it would be very simple to alter this so each menuItem points to a separate method instead, or pass a certain value to the function to display.</p>
]]></content:encoded>
			<wfw:commentRss>http://flexoop.com/2009/02/update-to-menuitem-class/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Databinding with MenuBar DataProvider</title>
		<link>http://flexoop.com/2008/11/databinding-with-menubar-dataprovider/</link>
		<comments>http://flexoop.com/2008/11/databinding-with-menubar-dataprovider/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 22:11:22 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MenuItem]]></category>

		<guid isPermaLink="false">http://flexoop.com/?p=60</guid>
		<description><![CDATA[A slight update to my previous post about databinding in the MenuBar&#8217;s dataProvider. It turns out that by just changing my initial menuData property from an Array to an ArrayCollection, everything &#8220;just works&#8221;. I guess it has to do with the ArrayCollection actually monitoring when its source changes and firing CollectionChange events. These events must [...]]]></description>
			<content:encoded><![CDATA[<p>A slight update to my <a href="http://flexoop.com/2008/11/menuitem-class/">previous post</a> about databinding in the MenuBar&#8217;s dataProvider.</p>
<p>It turns out that by just changing my initial menuData property from an Array to an ArrayCollection, everything &#8220;just works&#8221;.  I guess it has to do with the ArrayCollection actually monitoring when its source changes and firing CollectionChange events.  These events must then be picked up by the MenuBar parent, and it then updates its bindings.  Here&#8217;s the updated code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> xmlns:flexoop=<span style="color: #ff0000;">&quot;com.flexoop.utility.*&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flexoop</span>.<span style="color: #006600;">utility</span>.<span style="color: #006600;">MenuItemWithChildren</span>;
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flexoop</span>.<span style="color: #006600;">utility</span>.<span style="color: #006600;">MenuItem</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
&nbsp;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> menuData:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection;
&nbsp;
			<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<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: #000000; font-weight: bold;">var</span> menuItem:MenuItemWithChildren = <span style="color: #000000; font-weight: bold;">new</span> MenuItemWithChildren<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 1&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;
				menuItem.<span style="color: #006600;">children</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 4&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuItem.<span style="color: #006600;">children</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 5&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> menuItem <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test2&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test3&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:ApplicationControlBar id=<span style="color: #ff0000;">&quot;acb&quot;</span><span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:MenuBar id=<span style="color: #ff0000;">&quot;mb&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ menuData }&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:ApplicationControlBar<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>Just wanted to thank Fotis Chatzinikos over on the <a href="http://tech.groups.yahoo.com/group/flexcoders/" target="_blank">flexcoders group</a> for helping to solve this, at least partially.  I&#8217;m still curious as to what specifically would need to change in order to switch back to an array, but at least I know the quick and easy solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://flexoop.com/2008/11/databinding-with-menubar-dataprovider/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>MenuItem Class</title>
		<link>http://flexoop.com/2008/11/menuitem-class/</link>
		<comments>http://flexoop.com/2008/11/menuitem-class/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 23:25:27 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MenuItem]]></category>
		<category><![CDATA[MenuItemWithChildren]]></category>

		<guid isPermaLink="false">http://flexfusion.archfamily.com/?p=55</guid>
		<description><![CDATA[I am not completely sure why Adobe decided not to include this in their base classes when creating the Flex framework. They have, more or less, given all of the class structure in the definition of what a menuitem must contain&#8230;enabled, toggle, groupName, etc. I decided that there&#8217;s absolutely no point in rewriting the same [...]]]></description>
			<content:encoded><![CDATA[<p>I am not completely sure why Adobe decided not to include this in their base classes when creating the Flex framework.  They have, more or less, given all of the class structure in the definition of what a menuitem <a href="http://livedocs.adobe.com/flex/201/langref/mx/controls/Menu.html">must contain</a>&#8230;enabled, toggle, groupName, etc.  I decided that there&#8217;s absolutely no point in rewriting the same thing over and over again, so why not create a MenuItem class.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">archfamily</span>.<span style="color: #006600;">utility</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MenuItem <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * properties
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _enabled:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _groupName:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _icon:<span style="color: #000000; font-weight: bold;">Class</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _label:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _toggled:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _type:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * getters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">enabled</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._enabled;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> groupName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._groupName;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> icon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #000000; font-weight: bold;">Class</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._icon;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> label<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._label;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> toggled<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._toggled;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._type;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * setters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">enabled</span><span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._enabled = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> groupName<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._groupName = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> icon<span style="color: #66cc66;">&#40;</span> value:<span style="color: #000000; font-weight: bold;">Class</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._icon = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> label<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._label = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> toggled<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._toggled = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Inspectable<span style="color: #66cc66;">&#40;</span>enumeration=separator,check,radio,normal<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._type = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MenuItem<span style="color: #66cc66;">&#40;</span> label:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, <span style="color: #0066CC;">enabled</span>:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;normal&quot;</span>, toggled:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, groupName:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, icon:<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: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">enabled</span> = <span style="color: #0066CC;">enabled</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">groupName</span> = groupName;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">icon</span> = icon;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">label</span> = label;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">toggled</span> = toggled;
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">type</span> = <span style="color: #0066CC;">type</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I added the properties to the constructor so that the menu items could be created without have to first create a variable for them, but could rather just do something like &#8220;myArray.push( new MenuItem( &#8220;myLabel&#8221;, true ) )&#8221;. Initially I added the &#8220;children&#8221; as a property of this class, but then I found out that this will cause the menu items to show an arrow next to their name as if the MenuItem actually had children (even though the item is an empty array).  In order to circumvent this problem, I decided to create a second class, MenuItemWithChildren, that extends MenuItem, but adds the property &#8220;children&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">archfamily</span>.<span style="color: #006600;">utility</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MenuItemWithChildren <span style="color: #0066CC;">extends</span> MenuItem <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * properties
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _children:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * getters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> children<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>._children;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/***********************************
		 * setters
		 **********************************/</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> children<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>._children = value;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MenuItemWithChildren<span style="color: #66cc66;">&#40;</span>label:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, <span style="color: #0066CC;">enabled</span>:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;normal&quot;</span>, toggled:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, groupName:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;&quot;</span>, icon:<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: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span>label, <span style="color: #0066CC;">enabled</span>, <span style="color: #0066CC;">type</span>, toggled, groupName, icon<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now, whenever I want to create a menu item within one of my menu bars, all I have to do is create an array that holds all of my MenuItem or MenuItemWithChildren classes, and I have strongly typed class rather than a plain, old array of generic objects.  The one other thing to note is that if the menu is not created in the property declarations, then you have to set the array to the dataProvider of the menu item, or it will not refresh the view and you will not be able to see your menu items.  The implementation would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> xmlns:archfamily=<span style="color: #ff0000;">&quot;com.archfamily.utility.*&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">archfamily</span>.<span style="color: #006600;">utility</span>.<span style="color: #006600;">MenuItemWithChildren</span>;
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">archfamily</span>.<span style="color: #006600;">utility</span>.<span style="color: #006600;">MenuItem</span>;
&nbsp;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> menuData:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
			<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<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: #000000; font-weight: bold;">var</span> menuItem:MenuItemWithChildren = <span style="color: #000000; font-weight: bold;">new</span> MenuItemWithChildren<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 1&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;
				menuItem.<span style="color: #006600;">children</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 4&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuItem.<span style="color: #006600;">children</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test 5&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> menuItem <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test2&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				menuData.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> MenuItem<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;test3&quot;</span>, <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				mb.<span style="color: #006600;">dataProvider</span> = menuData;
&nbsp;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:ApplicationControlBar id=<span style="color: #ff0000;">&quot;acb&quot;</span><span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:MenuBar id=<span style="color: #ff0000;">&quot;mb&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ menuData }&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:ApplicationControlBar<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>I haven&#8217;t had to use the Menu class very often yet, but I&#8217;m sure this will come in handy to someone else.  If nothing else, it saves typing in Flex Builder.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://flexoop.com/2008/11/menuitem-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dedupe ArrayCollection Component</title>
		<link>http://flexoop.com/2008/11/dedupe-arraycollection-component/</link>
		<comments>http://flexoop.com/2008/11/dedupe-arraycollection-component/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 03:53:40 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[dedupeArrayCollection]]></category>

		<guid isPermaLink="false">http://flexfusion.archfamily.com/?p=52</guid>
		<description><![CDATA[Building off of my last post, I thought I might as well create a deduped arraycollection as well, just in case anyone wanted to use the data for something other than a combobox.  The implementation for this component is very similar to that of the combobox.  The DedupeArrayCollection allows you to pass it an array [...]]]></description>
			<content:encoded><![CDATA[<p>Building off of my <a title="last post" href="http://flexfusion.archfamily.com/2008/11/deduped-combobox-component/" target="_self">last post</a>, I thought I might as well create a deduped arraycollection as well, just in case anyone wanted to use the data for something other than a combobox.  The implementation for this component is very similar to that of the combobox.  The DedupeArrayCollection allows you to pass it an array (one that has some kind of properties to each of the items within it), then set the dedupeProperty to whatever field you wish to dedupe.</p>
<p>The DedupeArrayCollection:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">archfamily</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Dictionary</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">CollectionEvent</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DedupeArrayCollection <span style="color: #0066CC;">extends</span> ArrayCollection <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _dedupeProperty:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> dedupeProperty<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			_dedupeProperty = value;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">source</span> = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">source</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> dedupeProperty<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _dedupeProperty;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * 
		 * Needed to override the standard dataprovider in order to reset
		 * the duplicate value each time
		 * 
		 */</span>
		override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> source<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> _returnArray:<span style="color: #0066CC;">Array</span> = value;
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> value <span style="color: #66cc66;">&amp;&amp;</span> dedupeProperty.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> _map:Dictionary = <span style="color: #000000; font-weight: bold;">new</span> Dictionary<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
				value.<span style="color: #b1b100;">forEach</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> item:<span style="color: #66cc66;">*</span>, <span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span>, <span style="color: #0066CC;">array</span>:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
					_map<span style="color: #66cc66;">&#91;</span> item<span style="color: #66cc66;">&#91;</span> <span style="color: #0066CC;">this</span> <span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span> = item; <span style="color: #808080; font-style: italic;">// in the loop, this == dedupeProperty</span>
				<span style="color: #66cc66;">&#125;</span>, dedupeProperty <span style="color: #66cc66;">&#41;</span>;
&nbsp;
				_returnArray = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
				<span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">object</span>:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> _map <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
					_returnArray.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">object</span> <span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">source</span> = _returnArray;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> DedupeArrayCollection<span style="color: #66cc66;">&#40;</span> source:<span style="color: #0066CC;">Array</span>=<span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span> source <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The implementation of the arraycollection:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> xmlns:archfamily=<span style="color: #ff0000;">&quot;com.archfamily.*&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">archfamily</span>.<span style="color: #006600;">DedupeArrayCollection</span>;
&nbsp;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ac:DedupeArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> DedupeArrayCollection<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#91;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;car&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;bus&quot;</span>, total: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;bike&quot;</span>, total: <span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;train&quot;</span>, total: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;boat&quot;</span>, total: <span style="color: #cc66cc;">400</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;car&quot;</span>, total: <span style="color: #cc66cc;">500</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;bus&quot;</span>, total: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;convertible&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;gizmo&quot;</span>, total: <span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;boat&quot;</span>, total: <span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;car&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;dune buggy&quot;</span>, total:<span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;motorcycle&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
				ac.<span style="color: #006600;">dedupeProperty</span> = <span style="color: #ff0000;">&quot;total&quot;</span>;
			<span style="color: #66cc66;">&#125;</span>			
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:ComboBox id=<span style="color: #ff0000;">&quot;testing&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ ac }&quot;</span> labelField=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>The only thing I would probably change is to figure out what event needs to fire when my dedupeProperty is set to get the arraycollection to reload the source.  Currently I&#8217;m just setting the source to itself so that the event fires and reloads the arraycollection, but just firing the event would probably be less overhead.</p>
]]></content:encoded>
			<wfw:commentRss>http://flexoop.com/2008/11/dedupe-arraycollection-component/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deduped ComboBox Component</title>
		<link>http://flexoop.com/2008/11/deduped-combobox-component/</link>
		<comments>http://flexoop.com/2008/11/deduped-combobox-component/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 02:52:49 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[combobox]]></category>
		<category><![CDATA[dedupedComboBox]]></category>

		<guid isPermaLink="false">http://flexfusion.archfamily.com/?p=48</guid>
		<description><![CDATA[There are times that I have wanted to remove all duplicates from a combobox&#8217;s dataprovider, but haven&#8217;t wanted to requery the database or roll my own code snippet each time to remove those duplicates.  To make my life a little easier (and hopefully anyone else that may be in need of this feature), I&#8217;ve created [...]]]></description>
			<content:encoded><![CDATA[<p>There are times that I have wanted to remove all duplicates from a combobox&#8217;s dataprovider, but haven&#8217;t wanted to requery the database or roll my own code snippet each time to remove those duplicates.  To make my life a little easier (and hopefully anyone else that may be in need of this feature), I&#8217;ve created the DedupeComboBox class.</p>
<p>This handy little item allows you to set the dataprovider of the combobox to an array or arraycollection, and set the labelField value and the combobox will then handle the rest.  The labelfield is important as that is what allows the component to remove the duplicates from the arraycollection (if it is an array, it must also be an array of objects with properties that match the labelField or it will not remove anything).  Also, as the items populate the deduped dictionary instance, the value of that item in the arraycollection is saved to that &#8220;key&#8221; in the dictionary, allowing for retrieval of it later on if necessary.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">archfamily</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Dictionary</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">ComboBox</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DedupeComboBox <span style="color: #0066CC;">extends</span> ComboBox <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * 
		 * Needed to override the standard dataprovider in order to reset
		 * the duplicate value each time
		 * 
		 */</span>
		override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> dataProvider<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> _localArray:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#40;</span> value is ArrayCollection <span style="color: #66cc66;">&#41;</span> ? <span style="color: #66cc66;">&#40;</span> value as ArrayCollection <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">source</span> : value as <span style="color: #0066CC;">Array</span>;
			<span style="color: #000000; font-weight: bold;">var</span> _map:Dictionary = <span style="color: #000000; font-weight: bold;">new</span> Dictionary<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> labelField.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				_localArray.<span style="color: #b1b100;">forEach</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> item:<span style="color: #66cc66;">*</span>, <span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span>, <span style="color: #0066CC;">array</span>:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
					_map<span style="color: #66cc66;">&#91;</span> item<span style="color: #66cc66;">&#91;</span> <span style="color: #0066CC;">this</span> <span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span> = item; <span style="color: #808080; font-style: italic;">// in the loop, this == labelField</span>
				<span style="color: #66cc66;">&#125;</span>, labelField <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> _returnArray:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">object</span>:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> _map <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				_returnArray.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">object</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">dataProvider</span> = _returnArray;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> DedupeComboBox<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>then to implement it from your code you could do something as simple as this</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> xmlns:archfamily=<span style="color: #ff0000;">&quot;com.archfamily.*&quot;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ac:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;car&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;bus&quot;</span>, total: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;bike&quot;</span>, total: <span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;train&quot;</span>, total: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;boat&quot;</span>, total: <span style="color: #cc66cc;">400</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;car&quot;</span>, total: <span style="color: #cc66cc;">500</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;bus&quot;</span>, total: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;convertible&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;gizmo&quot;</span>, total: <span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;boat&quot;</span>, total: <span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;car&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;dune buggy&quot;</span>, total:<span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #ff0000;">&quot;motorcycle&quot;</span>, total: <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>archfamily:DedupeComboBox id=<span style="color: #ff0000;">&quot;testing&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{ ac }&quot;</span> labelField=<span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>You can even get just the non-duplicate totals by changing labelField=&#8221;name&#8221; to labelField=&#8221;total&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://flexoop.com/2008/11/deduped-combobox-component/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
