<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-56143911690970345</id><updated>2011-07-08T11:39:09.325+01:00</updated><category term='Flex'/><category term='LabelFunction'/><category term='ComboBox'/><category term='tutorial'/><title type='text'>FLEXible Fun</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://flexiblefun.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/56143911690970345/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://flexiblefun.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>NFRiaCowboy</name><uri>http://www.blogger.com/profile/05652522519930921694</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-56143911690970345.post-2545826366786026073</id><published>2009-03-25T00:32:00.000Z</published><updated>2009-03-25T16:19:55.983Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='ComboBox'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='LabelFunction'/><category scheme='http://www.blogger.com/atom/ns#' term='Flex'/><title type='text'>The LabelFunction, ComboBox</title><content type='html'>&lt;div&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;Hello All,&lt;/span&gt;&lt;/span&gt; &lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;this is my first post and I starting with something that could be very fun for newbies.&lt;/span&gt;&lt;/span&gt; &lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;This is a simple way to change how the information contained on a ArrayCollection is showed on a ComboBox simple &lt;span style="COLOR: #000000"&gt;but this could be useful if you are getting an Array of objects, and each Object containing the name and last name from the users of a DataBase.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;And making thinks a little bit complex, depending on the country of the user you can display the information in one of this two ways:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;for US - Last Name, First Name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;for PT - First Name, Last Name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;But in order to do that more things are needed and that is another Post ;)&lt;/span&gt;&lt;/span&gt; &lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;So lets go do this in 3 easy steps:&lt;/span&gt;&lt;/span&gt; &lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;strong&gt;STEP 1&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;The ArrayCollection contains a simple Object with 2 parameters,&lt;/span&gt;&lt;/span&gt;
&lt;blockquote&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #6699cc"&gt;&lt;strong&gt;var&lt;/strong&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;temp:Object =&lt;/span&gt; &lt;span style="COLOR: #0033ff"&gt;&lt;strong&gt;new&lt;/strong&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;Object();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;temp.name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;temp.number&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;just for fun, I create that complex verification to know when the variable&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;is pair or not.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;Then I add each new filled object&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;em&gt;temp&lt;/em&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;span&gt;to the&lt;/span&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;em&gt;myDataProvider&lt;/em&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;span&gt;(the ArrayCollection) variable.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;&lt;strong&gt;STEP 2&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;create the ComboBox, defining the dataprovider and the labelFuntion&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;mx:ComboBox&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;dataProvider="&lt;/span&gt; &lt;span style="COLOR: #990000"&gt;{&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;myDataProvider&lt;/span&gt; &lt;span style="COLOR: #990000"&gt;}&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;" labelFunction="&lt;/span&gt; &lt;span style="COLOR: #990000"&gt;createLabel&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="COLOR: #000000"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;Ok, now you can ask what is a labelFuncion?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="COLOR: #000000"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;The labelFunction is a property of the ComboBox (and other components) that let you provide a function that will handle each item of the dataProvider, and create a String that will be our label to display on the ComboBox.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="COLOR: #000000"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;strong&gt;STEP 3&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="COLOR: #000000"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;The labelFunction:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #0033ff"&gt;&lt;strong&gt;private&lt;/strong&gt;&lt;/span&gt; &lt;span style="COLOR: #339966"&gt;&lt;strong&gt;function&lt;/strong&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;createLabel(value:Object):String{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #6699cc"&gt;&lt;strong&gt;var&lt;/strong&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;out:String;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;out = value.name +&lt;/span&gt; &lt;span style="COLOR: #990000"&gt;&lt;strong&gt;" : "&lt;/strong&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;+ value.number;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #0033ff"&gt;&lt;strong&gt;return&lt;/strong&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;out;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: 'Courier New', monospace"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;as you can see this is a very simple function, but the complexity of the function will be defined by the complexity of your data, and how you want to show it, the thing that you always keep in mind is the labelFunction will recibe&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;span style="TEXT-DECORATION: underline"&gt;&lt;strong&gt;ALWAYS&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;span&gt;&lt;span&gt;an Object and provide a String as result of whatever you do inside.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;&lt;span&gt;&lt;span&gt;The Object you receive from the ComboBox, as I told before, is one item of the dataProvider, in this case an Object that represent the original&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;em&gt;&lt;span&gt;&lt;span&gt;temp&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt; &lt;span style="COLOR: #000000"&gt;&lt;span&gt;&lt;span&gt;Object.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;&lt;span&gt;&lt;span&gt;I really hope that you find this example easy to understand and that could be useful for you.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN: left"&gt;&lt;span style="FONT-FAMILY: Verdana, sans-serif"&gt;&lt;span style="FONT-SIZE: x-small"&gt;&lt;span style="COLOR: #000000"&gt;&lt;span&gt;&lt;span&gt;See you soon :D&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/56143911690970345-2545826366786026073?l=flexiblefun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://flexiblefun.blogspot.com/feeds/2545826366786026073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://flexiblefun.blogspot.com/2009/03/labelfunction-combobox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/56143911690970345/posts/default/2545826366786026073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/56143911690970345/posts/default/2545826366786026073'/><link rel='alternate' type='text/html' href='http://flexiblefun.blogspot.com/2009/03/labelfunction-combobox.html' title='The LabelFunction, ComboBox'/><author><name>NFRiaCowboy</name><uri>http://www.blogger.com/profile/05652522519930921694</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
