<?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>Mihai Corlan &#187; AIR</title>
	<atom:link href="http://corlan.org/category/air/feed/" rel="self" type="application/rss+xml" />
	<link>http://corlan.org</link>
	<description>Web, Mobile, and Rock&#38;Roll</description>
	<lastBuildDate>Mon, 30 Jan 2012 11:01:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Native Extensions examples available now</title>
		<link>http://corlan.org/2011/09/22/native-extensions-examples-available-now/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=native-extensions-examples-available-now</link>
		<comments>http://corlan.org/2011/09/22/native-extensions-examples-available-now/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 14:46:37 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3218</guid>
		<description><![CDATA[
			
				
			
		
Among of the biggest news of the Adobe AIR 3 release  is the Native Extensions feature. If you want to get started with this, or maybe just try it, you should check out the Native Extensions page on Adobe Developer Connection.
There are five examples so far:

Gyroscope (iOS/Android)
NetworkInfo (iOS) &#8211; retrieves information about the network interfaces [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/09/22/native-extensions-examples-available-now/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F09%2F22%2Fnative-extensions-examples-available-now%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F09%2F22%2Fnative-extensions-examples-available-now%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Among of the biggest news of the Adobe AIR 3 release  is the <a href="http://www.adobe.com/devnet/air/articles/extending-air.html">Native Extensions</a> feature. If you want to get started with this, or maybe just try it, you should check out the Native Extensions <a href="http://www.adobe.com/devnet/air/native-extensions-for-air.html">page</a> on Adobe Developer Connection.</p>
<p>There are five examples so far:</p>
<ol>
<li><a href="http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/gyroscope.html">Gyroscope</a> (iOS/Android)</li>
<li><a href="http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/networkinfo.html">NetworkInfo</a> (iOS) &#8211; retrieves information about the network interfaces on an iOS device</li>
<li><a href="http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/vibration.html">Vibration</a> (iOS/Android) &#8211; make the device vibrate</li>
<li><a href="http://custardbelly.com/blog/2011/09/21/air-native-extension-example-ibattery-for-ios/">iBattery</a> (iOS) &#8211; gets the battery status (unknown, unplugged, charging, or full) of an iOS device</li>
<li><a href="http://blog.magicalhobo.com/2011/09/12/air-3-native-extension-imageprocessor/">.NET Image Encoder</a> (Windows) &#8211; encodes a bitmap into BMP, JPEG, or PNG format using Microsoft .NET Framework 4</li>
</ol>
<p>The first three extensions were created by Adobe engineers, the last two by community. As I said before I&#8217;m looking forward to seeing many more extensions created and having a central place to go for all of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/09/22/native-extensions-examples-available-now/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building an iPad game with Adobe AIR in a week</title>
		<link>http://corlan.org/2011/08/30/building-an-ipad-game-with-adobe-air-in-a-week/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-an-ipad-game-with-adobe-air-in-a-week</link>
		<comments>http://corlan.org/2011/08/30/building-an-ipad-game-with-adobe-air-in-a-week/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 12:29:42 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3173</guid>
		<description><![CDATA[
			
				
			
		
Radu Ticiu of Timisoara Mobile Development Group invited me to speak at their August event about Adobe&#8217;s solutions for mobile development. And I must say I&#8217;m glad I accepted. Not only because the event and the people were great but because the other speaker was quite interesting.
Stefan is his name and he runs one of [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/08/30/building-an-ipad-game-with-adobe-air-in-a-week/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F30%2Fbuilding-an-ipad-game-with-adobe-air-in-a-week%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F30%2Fbuilding-an-ipad-game-with-adobe-air-in-a-week%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Radu Ticiu of <a href="http://www.meetup.com/TiMoDev/">Timisoara Mobile Development Group</a> invited me to speak at their August event about Adobe&#8217;s solutions for mobile development. And I must say I&#8217;m glad I accepted. Not only because the event and the people were great but because the other speaker was quite interesting.</p>
<p>Stefan is his name and he runs one of the most creative <a href="http://wearex3.com/">companies</a> in this part of the world. Just to give you some context: they&#8217;ve won three <a href="http://www.thefwa.com/">FWA</a> awards so far. His presentation was about the making off of an iPad game using Adobe AIR and Flash Builder 4.5. So far nothing new or extraordinary. isn&#8217;t it?</p>
<p>Well what really caught my attention were these facts:</p>
<ul>
<li>While they had great expertise in building Flash applications for the desktop, this was the first project they&#8217;ve done for mobile.</li>
<li>They completed the game from concept to final IPA file ready for publishing in a week.</li>
<li>The team who built this consisted of one designer, one developer, and Stefan.</li>
</ul>
<p><span id="more-3173"></span></p>
<p>Here are some screen shots of their game &#8211; called <a href="http://itunes.apple.com/ro/app/chemistry-brothers/id451480299?mt=8">Chemistry Brothers</a>:</p>
<p><img class="alignnone size-full wp-image-3174" title="chemistry-brothers-1" src="http://corlan.org/wp-content/uploads/2011/08/chemistry-brothers-1.jpg" alt="" width="480" height="360" /></p>
<p><img class="alignnone size-full wp-image-3175" title="chemistry-brothers-2" src="http://corlan.org/wp-content/uploads/2011/08/chemistry-brothers-2.jpg" alt="" width="480" height="360" /></p>
<p>During the presentation (and after while we enjoyed some beer and food) I learned more about this project and the company. And I think this project and the way they approached it is a good example of how you can get into mobile development if you are a web or desktop developer.</p>
<p>These were Stefan&#8217;s challenges before deciding to start the project:</p>
<ul>
<li>no expertise in mobile development</li>
<li>no expertise in Flash and AIR mobile development</li>
<li>no expertise in selling an application on Apple&#8217;s app store</li>
</ul>
<p>Though these challenges were quite big he had something to rely on:</p>
<ul>
<li>tons of creativity</li>
<li>great expertise in desktop and web development including Flash and Adobe AIR</li>
<li>a plan</li>
</ul>
<p>The plan he had was as important as the skills of his team. First of all, he decided to spend a week for building the game, from nothing to the polished &#8220;thing&#8221; you can find in app store. It was an all-or-nothing kind of bet. And to increase the chances of success he took his team out of the town to a remote town with nothing to distract them. They did a sort of software bootcamp.</p>
<p>Second, from the beginning he didn&#8217;t want to have anything less than great performances. To ensure this they used a first generation iPad for testing the code and they targeted 30 frames per second for their game. Anything less was not accepted.</p>
<p>Third, they struck a fine balance between the &#8220;features&#8221; of this game. They spent a lot of time on the graphics and game story but they didn&#8217;t spend much time on building lots of levels. It would have been impossible to do all those things with such restrictions (three people and one week).</p>
<p>And finally, they did a kind of agile development not for the code but for the product (game). Remember that I said they didn&#8217;t have any prior experience in building and selling mobile applications. So their plan was to build the game in one week and then ship it. If it had success then they would continue to develop as they already had the game story and lots of ideas. Guess what? They are happy with how the game is selling so far. Stefan told me that they will continue this project.</p>
<p>If you are one of the people who couldn&#8217;t find time for trying mobile development so far you are not alone. And more importantly, it is not so difficult to make your first move. Just think of an application that you&#8217;d like to build and make sure you allocate time for this. It could be a series of weekends during a month or three days of your vacation. It really doesn&#8217;t matter. What matters is to be focused and work on this fully committed. Chances are that you&#8217;d be surprised by yourself and what you can do.</p>
<p>In the end I just want to share some pictures from their office. Some say that having a creative environment stimulates creativity. After talking to Stefan and seeing his company&#8217;s work I&#8217;m not sure about this anymore. It looks like creative people change ordinary things into something to remember.</p>
<div id="attachment_3176" class="wp-caption alignnone" style="width: 600px"><img class="size-full wp-image-3176" title="A wall built out of books" src="http://corlan.org/wp-content/uploads/2011/08/1.jpg" alt="A wall built out of books" width="590" height="443" /><p class="wp-caption-text">A wall built out of books</p></div>
<div id="attachment_3177" class="wp-caption alignnone" style="width: 600px"><img class="size-full wp-image-3177" title="Playing around with Dark Vader's helmet " src="http://corlan.org/wp-content/uploads/2011/08/3.jpg" alt="Playing around with Dark Vader's helmet" width="590" height="443" /><p class="wp-caption-text">Playing around with Darth Vader&#39;s helmet</p></div>
<div id="attachment_3178" class="wp-caption alignnone" style="width: 600px"><img class="size-full wp-image-3178" title="Another inspirational wall closely guarded by a she-clone" src="http://corlan.org/wp-content/uploads/2011/08/12.jpg" alt="Another inspirational wall closely guarded by a she-clone" width="590" height="443" /><p class="wp-caption-text">Another inspirational wall closely guarded by a she-clone</p></div>
<div id="attachment_3179" class="wp-caption alignnone" style="width: 453px"><img class="size-full wp-image-3179" title="Rest room guardian!" src="http://corlan.org/wp-content/uploads/2011/08/4.jpg" alt="Rest room guardian!" width="443" height="590" /><p class="wp-caption-text">Rest room guardian!</p></div>
<div id="attachment_3180" class="wp-caption alignnone" style="width: 600px"><img class="size-full wp-image-3180" title="Taking a break or having a meeting in a cozy space" src="http://corlan.org/wp-content/uploads/2011/08/5.jpg" alt="Taking a break or having a meeting in a cozy space" width="590" height="443" /><p class="wp-caption-text">Taking a break or having a meeting in a cozy space</p></div>
<p>If you have similar stories or just want to talk back, don&#8217;t hesitate to use the comments :). All I can say is: Bravo Stefan &amp; Company!</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/08/30/building-an-ipad-game-with-adobe-air-in-a-week/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flex Mobile Development: skinning the ActionBar component</title>
		<link>http://corlan.org/2011/08/29/flex-mobile-development-skinning-the-actionbar-component/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-mobile-development-skinning-the-actionbar-component</link>
		<comments>http://corlan.org/2011/08/29/flex-mobile-development-skinning-the-actionbar-component/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 06:00:14 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3142</guid>
		<description><![CDATA[
			
				
			
		
One of the important pieces of the Flex framework for mobile development is the ActionBar class. This class lets you create an application title bar with three distinct areas. Starting from left to right you can have a navigation area, a title area, and an actions area. Of course you are not forced to use [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/08/29/flex-mobile-development-skinning-the-actionbar-component/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F29%2Fflex-mobile-development-skinning-the-actionbar-component%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F29%2Fflex-mobile-development-skinning-the-actionbar-component%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the important pieces of the Flex framework for mobile development is the <em><a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/ActionBar.html">ActionBar</a></em> class. This class lets you create an application title bar with three distinct areas. Starting from left to right you can have a navigation area, a title area, and an actions area. Of course you are not forced to use all these areas.</p>
<p>Why would you want to use this component? There are many reasons for using it but probably the most important is that it is an established user interaction design pattern on Android and iOS. This is how you usually add things like an application or section title, navigation buttons, search input texts, or action buttons.</p>
<p><span id="more-3142"></span></p>
<p>Here are two screen shots of the Facebook application running on Android and iOS that illustrates this idea:</p>
<p><img class="alignnone size-full wp-image-3148" title="actionbar1" src="http://corlan.org/wp-content/uploads/2011/08/actionbar11.png" alt="" width="270" height="388" /> <img class="alignnone size-full wp-image-3149" title="actionbar2" src="http://corlan.org/wp-content/uploads/2011/08/actionbar2.png" alt="" width="270" height="388" /></p>
<h2>Using the ActionBar component</h2>
<p>Using the <em>ActionBar</em> component is quite easy. First, you&#8217;ll need to create a Flex mobile project that uses either <em>ViewNavigatorApplication</em> or <em>TabbedViewNavigatorApplication</em>. Then, you can define the components you want to add to the <em>ActionBar</em> either globally (for all the <em>Views)</em> or individually (for each <em>View)</em>.</p>
<p>If you want to add them inside of a <em>View</em> here is how you do it:</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"&gt;

 &lt;s:navigationContent&gt;
     &lt;s:Button label="Back"/&gt;
 &lt;/s:navigationContent&gt;
 &lt;s:titleContent&gt;
     &lt;s:TextInput prompt="type to search" width="100%"/&gt;
 &lt;/s:titleContent&gt;
 &lt;s:actionContent&gt;
     &lt;s:Button label="+"/&gt;
 &lt;/s:actionContent&gt;

&lt;/s:View&gt;</pre>
<p>This code produces the following <em>ActionBar</em>:</p>
<p><img class="alignnone size-full wp-image-3151" title="actionbar3" src="http://corlan.org/wp-content/uploads/2011/08/actionbar3.png" alt="" width="270" height="233" /></p>
<p>If you want to set it globally then the method differe slightly depending on what Application root tag you chose when creating the project (<em>ViewNavigatorApplication</em> or <em>TabbedViewNavigatorApplication</em>). For <em>ViewNavigatorApplication</em> you&#8217;d do something like this:</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       firstView="views.ActionBarHomeView"&gt;

 &lt;s:navigationContent&gt;
      &lt;s:Button label="Back"/&gt;
 &lt;/s:navigationContent&gt;
 &lt;s:titleContent&gt;
      &lt;s:TextInput prompt="type to search" width="100%"/&gt;
 &lt;/s:titleContent&gt;
 &lt;s:actionContent&gt;
      &lt;s:Button label="+"/&gt;
 &lt;/s:actionContent&gt;

&lt;/s:ViewNavigatorApplication&gt;</pre>
<p>And for <em>TabbedViewNavigatorApplication</em> you&#8217;d add one for each tab you have in your application. For example:</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"&gt;

 &lt;s:ViewNavigator label="Tab 1" width="100%" height="100%" firstView="views.Tab1View"&gt;
      &lt;s:navigationContent&gt;
           &lt;s:Button label="Back"/&gt;
      &lt;/s:navigationContent&gt;
      &lt;s:titleContent&gt;
           &lt;s:TextInput prompt="type to search" width="100%"/&gt;
      &lt;/s:titleContent&gt;
      &lt;s:actionContent&gt;
           &lt;s:Button label="+"/&gt;
      &lt;/s:actionContent&gt;
 &lt;/s:ViewNavigator&gt;
 &lt;s:ViewNavigator label="Tab 2" width="100%" height="100%" firstView="views.Tab2View"&gt;

 &lt;/s:ViewNavigator&gt;

&lt;/s:TabbedViewNavigatorApplication&gt;</pre>
<p>And here is how this code looks like at runtime:</p>
<p><img class="alignnone size-full wp-image-3154" title="actionbar4" src="http://corlan.org/wp-content/uploads/2011/08/actionbar4.png" alt="" width="270" height="429" /></p>
<p>If you set the <em>ActionBar</em> globally and you want to override a section or all sections in a particular <em>View</em> all you have to do is to set that section/sections in the <em>View.</em></p>
<p>You should also know that you can control the <em>ActionBar</em> visibility and rendering mode. For example in any <em>View</em> in which you want to hide the <em>ActionBar</em> you can set <em>actionBarVisible = false</em>. By default the <em>ActionBar</em> is rendered so it takes up some of the available space for the rest of your application. If you want to have the bar hovering on top of the rest of your application you can set the <em>overlayControls</em> to <em>true</em> in your <em>View</em>.</p>
<h2>Understanding how the ActionBar component works</h2>
<p>Let&#8217;s see how everything is put together. Each part of the <em>ActionBar</em> (navigation, title, and action content) is actually a Spark Group object. If you open the <em>ActionBar</em> class file you&#8217;ll find three properties named: <em>actionGroup</em>, <em>navigationGroup</em>, and <em>titleGroup</em>. These Groups are populated by calling the setter methods: <em>actionContent()</em>, <em>titleContent()</em>, and <em>navigationContent()</em>. These methods are called by the <em>View</em> class to push the components you set for each section and the argument is an Array (you can set a Button or a number of UI components for each section).</p>
<p>How about the layout used by these three groups? Well you can set a different layout than the default by calling the <em>actionLayout</em>, <em>navigationLayout</em>, and <em>titleLayout</em> setters.</p>
<p>The <em>ActionBar</em> component is a Spark component and this means that the task for laying out the various UI components that you can add to each section is actually implemented by a skin class. And of course the look and feel is implemented by the same skin class. The default skin is <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/skins/mobile/ActionBarSkin.html"><em>spark.skins.mobile.ActionBarSkin</em></a>. This class extends the <em>MobileSkin</em> class, which in turns extends the <em>UIComponent</em>.</p>
<p>The interesting parts in the skin class are these three methods: <em>createChildren()</em>, <em>measure()</em>, and <em>layoutContents()</em>.</p>
<p>If you take a look at the <em>createChildren()</em> method you will see that here is where the three groups (<em>navigationGroup</em>, <em>actionGroup</em>, and <em>titleGroup</em>) used for each section are actually created and the default layout is set. Also you can see that the default layout used by each group is <em>HorizontalLayout</em>. Here is a snippet of the code that creates the <em>navigationGroup</em>:</p>
<pre>navigationGroup = new Group();
var hLayout:HorizontalLayout = new HorizontalLayout();
hLayout.horizontalAlign = HorizontalAlign.LEFT;
hLayout.verticalAlign = VerticalAlign.MIDDLE;
hLayout.gap = 0;
hLayout.paddingLeft = hLayout.paddingTop = hLayout.paddingRight
        = hLayout.paddingBottom = 0;
navigationGroup.layout = hLayout;
navigationGroup.id = "navigationGroup";</pre>
<p>The <em>measure()</em> method is executed executed after the <em>createChildren()</em> method or when the <em>invalidateSize()</em> method is executed. As the name implies, this method measures the width and the height of the <em>ActionBar</em> taking into consideration the padding (left, right, top, and bottom) and each group width and height (<em>navigationGroup</em>, <em>titleGroup</em>, and <em>actionGroup</em>). It is important to note that the height of the <em>ActionBar</em> is determined by the highest element you have, if this height is bigger than the default height. In other words if you add a <em>Button</em> and set the height of the button to 200, then the <em>ActionBar</em> height will be 200 pixels.</p>
<p>And finally the <em>layoutContent()</em> method is responsible for positioning and setting the size of each <em>Group</em>. This method positions each group starting from left to right with the <em>navigationGroup</em>, <em>titleGroup</em>, and <em>actionGroup</em>. If the total width of the <em>navigationGroup</em> and <em>actionGroup</em> is equal to or more than the total available width then the <em>titleGroup</em> is not displayed (visible = false).</p>
<p>Here is a graphical representation of how these different parts are related:</p>
<p><img class="alignnone size-full wp-image-3160" title="actiobar6" src="http://corlan.org/wp-content/uploads/2011/08/actiobar6.png" alt="" width="562" height="211" /></p>
<h2>Skinning the ActionBar component</h2>
<p>Let&#8217;s talk about styling the ActionBar component. Out of the box you can quite easily change the appearance using the CSS properties. For example you can use CSS to transform the default look and feel  of the <em>ActionBar</em> presented in a screen shot at the beginning of this article to something like this with a little bit of CSS:</p>
<p><img class="alignnone size-full wp-image-3156" title="actionbar4" src="http://corlan.org/wp-content/uploads/2011/08/actionbar42.png" alt="" width="270" height="74" /></p>
<p>And the CSS code that does this is this (please note that you have to include the CSS code or file in the main application file and not in the <em>Views</em>):</p>
<pre>&lt;fx:Style&gt;
@namespace s "library://ns.adobe.com/flex/spark";</pre>
<pre>s|ActionBar {
      chromeColor: #484877;
      defaultButtonAppearance: beveled;
}
&lt;/fx:Style&gt;</pre>
<p>The second CSS property in the code above (defaultButtonAppearance) is responsible for rendering the buttons in iOS style. If you inspect the <em>ActionBar</em> class you will find all the important CSS properties that you can play with.</p>
<p>If you want to go beyond background and font colors, sizes, and so forth you have to go down the road of creating a custom skin. And the easiest way to do this is to extend the <em>ActionBarSkin</em> class.</p>
<p>Here are the important parts of the <em>ActionBarSkin</em> class from a skinning perspective:</p>
<ul>
<li><em>border</em> and <em>borderClass</em> properties. <em>Border</em> represents the first child of the <em>ActionBarSkin</em> (take a look at the <em>createChildren()</em> method).<em>BorderClass</em> is a reference to an FXG file that is set in the class constructor depending on the <em>applicationDPI</em> value. The <em>borderClass</em> is used for creating the borders of the <em>ActionBar</em> and the shadow at the bottom. Here is a screen shot of what this looks like (I placed a pinkish background behind the graphics to provide some contrast for the highlights you can notice on the left/right side):</li>
</ul>
<p><img class="alignnone size-full wp-image-3158" title="actionbar5" src="http://corlan.org/wp-content/uploads/2011/08/actionbar5.png" alt="" width="350" height="273" /></p>
<ul>
<li><em>drawBackground()</em> method. This method is responsible for drawing the background. In the previous screen shots this is where the black or dark blue color is coming from. If you take a look at this method you will notice that it uses CSS properties (default or set by the programmer) to draw a gradient.</li>
</ul>
<p>I think that in the most of cases, when you want to skin an <em>ActionBar</em> component you&#8217;ll likely modify the <em>drawBackground()</em> method and create a different <em>borderClass</em> FXG file.</p>
<p>Let me show you an example of a custom skinning. There are three steps involved in this.</p>
<p>First, I created a new FXG file to be used for the background. To do this I opened up the FXG file used by default by the <em>ActionBarSkin</em> in Adobe Illustrator (you can find the path for this FXG in the <em>ActionBarSkin</em> constructor). And I added three green rectangles (some with a solid color, others with a transparent gradient). Here is the result in Illustrator:</p>
<p><img class="alignnone size-full wp-image-3165" title="actionbar7" src="http://corlan.org/wp-content/uploads/2011/08/actionbar7.png" alt="" width="297" height="237" /></p>
<p>Then, I exported the FXG file as an FXG. And I opened this file in a text editor to remove some of the tags and attributes introduced by Illustrator. Finally, I add the FXG file to the Flex mobile project.</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;UTF-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>Graphic <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;2.0&quot;</span> xmlns=<span style="color: #990000;">&quot;http://ns.adobe.com/fxg/2008&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; scaleGridLeft=<span style="color: #990000;">&quot;2&quot;</span> scaleGridTop=<span style="color: #990000;">&quot;3&quot;</span> scaleGridRight=<span style="color: #990000;">&quot;88&quot;</span> scaleGridBottom=<span style="color: #990000;">&quot;61&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;89.8335&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;60&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#16938D&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0.0830078&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;35&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;89.8335&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;26.6665&quot;</span> <span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>LinearGradient <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;44.9165&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">scaleX</span>=<span style="color: #990000;">&quot;26.6665&quot;</span> <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.160132&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#E2E2E2&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.126504&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.400165&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#A9A9A9&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.31613&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.79&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>LinearGradient<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;1.89014&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;89.8335&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;21.3774&quot;</span> <span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>LinearGradient <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;44.9165&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;21.3774&quot;</span> <span style="color: #004993;">scaleX</span>=<span style="color: #990000;">&quot;21.3774&quot;</span> <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;270&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>LinearGradient<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;2&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.75&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;62&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;2&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.85&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;64&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.35&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;65&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.25&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;66&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.2&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;67&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.15&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;68&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.1&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;69&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.05&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.25&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;88&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;61&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.1&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;88&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;60&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>LinearGradient <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0.5&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">scaleX</span>=<span style="color: #990000;">&quot;60&quot;</span> <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.25&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.1&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>LinearGradient<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;89&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;60&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>LinearGradient <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0.5&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">scaleX</span>=<span style="color: #990000;">&quot;60&quot;</span> <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.25&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.1&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>LinearGradient<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;90&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;70&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>Graphic<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>Second, I created a new ActionScript class that extends the <em>ActionBarkSkin</em>. In the constructor I make sure that the <em>borderClass</em> uses the FXG file I created in the previous step. And I overrode the <em>drawBackground()</em> method because the FXG file does everything I need. Here is the complete listing:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #9900cc; font-weight: bold;">package</span> org<span style="color: #000066; font-weight: bold;">.</span>corlan<span style="color: #000066; font-weight: bold;">.</span>skins <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>skins<span style="color: #000066; font-weight: bold;">.</span>mobile<span style="color: #000066; font-weight: bold;">.</span>ActionBarSkin<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CustomActionBarSkin <span style="color: #0033ff; font-weight: bold;">extends</span> ActionBarSkin <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CustomActionBarSkin<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//backgroundActionBar is the name of the FXG file</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderClass = backgroundActionBar<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> drawBackground<span style="color: #000000;">&#40;</span>unscaledWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> unscaledHeight<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
<p>Third, I changed the CSS from the main application file in order to set the new skin class as the <em>ActionBar</em> skin class, and the chromeColor used for the buttons. Here is the code:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>ViewNavigatorApplication xmlns<span style="color: #000066; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;firstView=<span style="color: #990000;">&quot;views.ActionBarHomeView&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span>Style<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; @<span style="color: #004993;">namespace</span> s <span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; s<span style="color: #000066; font-weight: bold;">|</span>ActionBar <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chromeColor<span style="color: #000066; font-weight: bold;">:</span> #16938D<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; defaultButtonAppearance<span style="color: #000066; font-weight: bold;">:</span> beveled<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; skinClass<span style="color: #000066; font-weight: bold;">:</span> ClassReference<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;org.corlan.skins.CustomActionBarSkin&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>fx<span style="color: #000066; font-weight: bold;">:</span>Style<span style="color: #000066; font-weight: bold;">&gt;</span> &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>ViewNavigatorApplication<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>Finally, here is how the skinned <em>ActionBar</em> at runtime:</p>
<p><img class="alignnone size-full wp-image-3166" title="actionbar8" src="http://corlan.org/wp-content/uploads/2011/08/actionbar8.png" alt="" width="483" height="168" /></p>
<p>In conclusion, if you couple these techniques with skinning of the other components you plan to use inside the <em>ActionBar</em> then you can really get something that is quite unique.</p>
<p>You can download the Flex project source code used for this example from <a href="http://corlan.org/downloads/ActionBar.fxp">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/08/29/flex-mobile-development-skinning-the-actionbar-component/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Flex Mobile Development: pay attention to list.itemRenderFunction</title>
		<link>http://corlan.org/2011/08/23/flex-mobile-development-pay-attention-to-list-itemrenderfunction/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-mobile-development-pay-attention-to-list-itemrenderfunction</link>
		<comments>http://corlan.org/2011/08/23/flex-mobile-development-pay-attention-to-list-itemrenderfunction/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 11:15:58 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3133</guid>
		<description><![CDATA[
			
				
			
		
A colleague of mine who is building a Flex mobile application had some performance issues with a list. In short, when he used a pretty heavy custom item renderer (with checkboxes, buttons, and labels) the scrolling performance dropped a lot. When using just a label item renderer everything worked well.
So, we started to debug the [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/08/23/flex-mobile-development-pay-attention-to-list-itemrenderfunction/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F23%2Fflex-mobile-development-pay-attention-to-list-itemrenderfunction%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F23%2Fflex-mobile-development-pay-attention-to-list-itemrenderfunction%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>A colleague of mine who is building a Flex mobile application had some performance issues with a list. In short, when he used a pretty heavy custom item renderer (with checkboxes, buttons, and labels) the scrolling performance dropped a lot. When using just a label item renderer everything worked well.</p>
<p>So, we started to debug the code and, as I suspected, the culprit was the layout manager: the virtualization was off.</p>
<p>This was strange as he didn&#8217;t turn off the <em>useVirtualLayout</em> flag anywhere in the code &#8211; at least not explicitly. So why was the virtualization off? Because he used <em>list.itemRenderFunction</em> to change the item renderer at runtime. If you take a look at the documentation you will find this:</p>
<blockquote><p>Function that returns an item renderer IFactory for a specific item. You should define an item renderer function similar to this sample function:</p>
<p><em>function myItemRendererFunction(item:Object):IFactory</em></p>
<p><strong>Currently, when using itemRendererFunction with a virtual layout (useVirtualLayout=true), item renderer recycling is turned off. Because of this, using <em>itemRendererFunction</em> can cause a performance degradation and is not recommended for mobile. This may be fixed in future versions of Flex.</strong></p></blockquote>
<p>So, if you use a heavy item renderer and/or you have many items, don&#8217;t set the item renderer using the <em>itemRendererFunction</em> method.</p>
<p>Instead, you can wrap your custom item renderer in a <em>ClassFactory</em> object and then assign this object to the <em>list.itemRenderer</em> property. Like this:</p>
<pre>var factory:ClassFactory = new ClassFactory(MyCustomItemRenderer);
// set the properties for custom item renderer
factory.properties = {iconField:"thumbnailSmall",
                  messageField:"description", iconHeight:180, iconWidth:180};
// set the ClassFactory object as the list item renderer
myList.itemRenderer = factory;</pre>
<p>There is one more thing. In the example above I used the properties property of the ClassFactory object to set the properties I needed (for example what data property should be used for the message label). You can&#8217;t use this approach for setting CSS properties like fontSize. The only solution I found so far is to create setters that behind the scenes are doing something like this:</p>
<pre>public class MyCustomItemRenderer {
   //...

   public function set fontSize(value:int):void {
      setStyle("fontSize", value);
   }

   //...
}</pre>
<p>This was my tip of the week. And don&#8217;t forget, stay away from <em>useVirtualLayout</em> = false;</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/08/23/flex-mobile-development-pay-attention-to-list-itemrenderfunction/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Flex Mobile Development: storing data locally</title>
		<link>http://corlan.org/2011/08/18/flex-mobile-development-storing-data-locally/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-mobile-development-storing-data-locally</link>
		<comments>http://corlan.org/2011/08/18/flex-mobile-development-storing-data-locally/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 08:57:12 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3117</guid>
		<description><![CDATA[
			
				
			
		
One way to improve the user experience for mobile applications is to save data locally. This technique is important for desktop applications and it is even more important for mobile applications (mostly because the network connection is expensive, slower, or intermittent).
When using applications such as mail or Twitter clients local storage enables users to see [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/08/18/flex-mobile-development-storing-data-locally/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F18%2Fflex-mobile-development-storing-data-locally%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F18%2Fflex-mobile-development-storing-data-locally%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>One way to improve the user experience for mobile applications is to save data locally. This technique is important for desktop applications and it is even more important for mobile applications (mostly because the network connection is expensive, slower, or intermittent).</p>
<p>When using applications such as mail or Twitter clients local storage enables users to see the messages or tweets loaded in the previous session. And while you are seeing these &#8220;old&#8221; items the application can pull in newer items behind the scenes. The main idea is to not to make the user stare at an empty screen each time he opens your application.</p>
<p>A second benefit of this technique is that your application will feel much more responsive. As I said it is possible that the user has a slow Internet connection and downloading 12 small pictures and some descriptions could be visibly slow. Local storage can offer a &#8220;performance&#8221; boost especially for applications that access data that changes rarely.</p>
<p>Depending on your specific use case you may want to save locally:</p>
<ul>
<li>media assets (images, MP3 files, video files)</li>
<li>text or HTML resources</li>
<li>XML files</li>
<li>ActionScript data structures (an array of ActionScript value objects for example)</li>
</ul>
<p><span id="more-3117"></span></p>
<p>So how can you store data locally in an AIR mobile application (Android, PlayBook, and iOS)? You have almost the same methods as in AIR desktop applications (on the desktop you can use the encrypted local store to save ActionScript objects):</p>
<ul>
<li>Use the embedded SQLite database &#8211; obviously perfect for data that are a good match for a relational database</li>
<li>Save ActionScript objects or collections of objects in files &#8211; serialize the objects into a file and read back when needed. Or you can use <em>SharedObject</em> to do the same</li>
<li>Save binary assets directly into files &#8211; perfect for saving images or videos locally</li>
</ul>
<p>I won&#8217;t go into details about these three techniques. Almost three years ago I wrote a <a href="http://corlan.org/2008/09/02/storing-data-locally-in-air/">blogpost</a> that explains each technique (back then it was only AIR for desktops, but remember that apart from the encrypted local store you can use the same approach on mobile or desktop). So click <a href="http://corlan.org/2008/09/02/storing-data-locally-in-air/">here</a> if you want to learn how to use these techniques.</p>
<p>There is one aspect I do want to highlight, however. When you want to save data locally using files you should always use the application storage folder. This folder is outside of the application installation folder. So you can update the application without worrying about the saved data. Here is a simple example for creating a new file inside the application storage folder:</p>
<pre>var file:File = File.applicationStorageDirectory.resolvePath("new-file.png");
var fileStream:FileStream = new FileStream();
fileStrean.open(file, FileMode.WRITE);
fileStream.writeBytes(data, 0, data.length);
fileStream.close()</pre>
<h2>Flex mobile support for persistence</h2>
<p>You probably already know about the persistence support of the Flex mobile framework. If you save your information to the <em>data</em> property of your <em>View</em> pages and set the <em>persistNavigatorState </em>attribute in the main application file to <em>true</em>, then all the information will be automatically saved when the application is closed and restored when the application is re-opened.</p>
<p>So here is a simple example. Suppose that you use this data model in your application:</p>
<pre>package {

[Bindable]     
class User {
    public var firstName:String;
    public var lastName:String;   
}
}</pre>
<p>Next, you turn on the persistence support in the main application file:</p>
<pre>&lt;s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    firstView="views.HomeView"
    <strong>persistNavigatorState="true"</strong>/&gt;</pre>
<p>And finally you use the <em>data</em> property to save the current instance of <em>User</em>. Bellow is the first <em>View</em> of the application. It uses bidirectional binding for displaying the <em>User</em> first name and last name properties.</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   title="HomeView"
   viewActivate="onViewActivated()"&gt;
&lt;fx:Script&gt;
 &lt;![CDATA[

   private function onViewActivated():void {
      // if it is the first time the application runs t
      // here is no data
      if (!data) {
         // create a new User instance and
         // save it to data property
         data = new User();
      }
   }

 ]]&gt;
&lt;/fx:Script&gt;
 &lt;s:layout&gt;
     &lt;s:VerticalLayout/&gt;
 &lt;/s:layout&gt;
 &lt;s:Spacer height="10"/&gt;

 &lt;s:Label text="First Name:"/&gt;
 &lt;s:TextInput width="100%" text="@{data.firstName}"/&gt;
 &lt;s:Label text="Last Name:"/&gt;
 &lt;s:TextInput width="100%" text="@{data.lastName}"/&gt;
&lt;/s:View&gt;</pre>
<p>When you run the application for the first time you won&#8217;t see any information in the two text input boxes. However if you type in something and then close the app and re-open it, you will see the information you typed during the previous session.</p>
<p>When is the <em>data</em> property of a <em>View</em> saved to disk? Every time the application is closed or a <em>View</em> is destroyed/replaced by a new <em>View</em>. In terms of events right after the View deactivate event is triggered.</p>
<p>When is the <em>data</em> property of a <em>View</em> recreated if persistence is turned on? Right before the View activated event is thrown.</p>
<p>The <em>data</em> property of each <em>View</em> is saved to disk using <em>flash.net.SharedObject</em> and the object that does this is the <em>ViewNavigator</em> instance accessible in any <em>View</em> class by using the <em>navigator</em> property.</p>
<p>If you want to be sure that the <em>data</em> property is persisted you can call <em>navigator.saveViewData()</em> in your <em>View</em>. Why would you want to trigger the saving process manually? Because in the unlikely event the app is closed by the operating system due to low battery or memory events you cannot be sure that the normal event flow for closing the app will be followed. By calling <em>navigator.saveViewData()</em> manually each time the user updates something you can make sure that nothing will be lost.</p>
<h2>RegisterClassAlias</h2>
<p>When you serialize ActionScript objects to files or use SharedObject the original data type is lost when you deserialize them. The same applies when using the <em>data</em> property of the <em>View</em> because, under the hood, <em>SharedObject</em> is used for storing the data. If you want to keep the custom data type, all you have to do is to use <em>registerClassAlias()</em> method.</p>
<p>Why? Because the serialization is done using the AMF3 format (Action Message Format) and if you want to preserve the class information for the objects you serialize/deserialize then you have register the class alias of the class object. If you don&#8217;t do this, when you decode the objects you&#8217;ll get anonymous objects.</p>
<p>In a previous section I used a custom data type User. If I want to make sure that the data type is preserved I can register this class in the main application file (this way I make sure that the class is registered before any decoding is performed):</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
 xmlns:s="library://ns.adobe.com/flex/spark"
 firstView="views.HomeView" persistNavigatorState="true"&gt;

&lt;fx:Script&gt;
&lt;![CDATA[
   import flash.net.registerClassAlias;

   <strong>registerClassAlias("User", User);</strong>
]]&gt;
&lt;/fx:Script&gt;

&lt;/s:ViewNavigatorApplication&gt;</pre>
<h2>Conclusions</h2>
<p>On Android you have to remember to set the appropriate permission in the application configuration file if you want to write files to disk (android.permission.WRITE_EXTERNAL_STORAGE). Also take into consideration how much space the data you want to saved will occupy. You should let the user know if you plan to consume GB of space.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/08/18/flex-mobile-development-storing-data-locally/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flex Mobile Development: caching images using ContentCache</title>
		<link>http://corlan.org/2011/08/16/flex-mobile-development-caching-images-using-contentcache/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-mobile-development-caching-images-using-contentcache</link>
		<comments>http://corlan.org/2011/08/16/flex-mobile-development-caching-images-using-contentcache/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 15:05:12 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3106</guid>
		<description><![CDATA[
			
				
			
		
There are many places where you can optimize your code especially when working on mobile applications. In this post I will focus on caching images using the spak.core.ContentCache class (part of the Flex framework).
Right from the Flex documentation, you can see ContentCache could be useful:
Provides a caching and queuing image content loader suitable for using [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/08/16/flex-mobile-development-caching-images-using-contentcache/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F16%2Fflex-mobile-development-caching-images-using-contentcache%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F16%2Fflex-mobile-development-caching-images-using-contentcache%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There are many places where you can optimize your code especially when working on mobile applications. In this post I will focus on caching images using the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/core/ContentCache.html"><em>spak.core.ContentCache</em></a> class (part of the Flex framework).</p>
<p>Right from the Flex documentation, you can see <em>ContentCache</em> could be useful:</p>
<blockquote><p>Provides a caching and queuing image content loader suitable for using   a shared image cache for the BitmapImage and spark Image components.</p></blockquote>
<h2>Why cache images?</h2>
<p>So why would you cache images? Every time you set a new source for a Spark <em>Image</em> or a <em>BitmapImage</em> object a new <em>flash.display.Loader</em> object is created to load the image bytes.</p>
<p>Now, let&#8217;s suppose you display a list of items and each item has an image (could be an icon or could be a picture). Each image is hosted on a remote server so it has to be downloaded. Finally, some of these images are the same for different items in the list (for example for a Twitter client it is quite common to see many entries with the same avatar; each entry represents a tweet from the same user and the avatar is the same in this case).</p>
<p>If you don&#8217;t use a caching mechanism, you will notice that as you scroll through the list it will take some time to load images. And the same could happen for images stored locally especially if they are not very small. While waiting for images to load and be displayed the first time is OK (and there isn&#8217;t much to do other than preload them) waiting for the same image every time it is displayed is quite annoying.</p>
<p>Here comes the <em>ContentCache</em> class. This class stores the bytes loaded (actually it stores the <em>LoaderInfo</em> object used for loading each image) and every time an image must be loaded it first checks the cache; if is not there then it goes through the loading process. If it is cached already, then it provides the <em>LoaderInfo</em> object.</p>
<p><span id="more-3106"></span></p>
<h2>How do you use the <em>ContentCache</em> class?</h2>
<p>You can enable caching for your Spark <em>Image</em> or <em>BitmapImage</em> objects quite easy. All you have to do is to create an instance of <em>ContentCache</em> and set this instance to the <em>contentLoader</em> property of the <em>BitmapImage</em> or <em>Image</em> object. Other than this, it&#8217;s business as usual. When you want to load an image you just set the source property of the <em>Image</em> or <em>BitmapImage</em> object and the <em>ContentCache</em> object will take care of the rest.</p>
<p>There is one thing you must be aware of: if an image was changed after it was cached and the source is the same then you have to invalidate the cache yourself in order to see the new image. Otherwise you will see the old version. When you want to remove an image from the cache you use the <em>removeCacheEntry()</em> method and pass the source for the image you want to invalidate in the cache.</p>
<p>You control the number of cached images using <em>maxCacheEntries</em> property (the default value is 100).</p>
<p>Let&#8217;s see a simple example:</p>
<pre>private var cache:ContentCache = new ContentCache();

private function setImage(source:String):void {
   //if we didn't set the cache
   if ( !img.contentLoader ) {
       img.contentLoader = cache;
   }
   //set the image source
   img.source = source;
}
...
&lt;s:Image id="img"/&gt;</pre>
<h2>Using <em>ContentCache</em> with Lists</h2>
<p>The Flex framework has a built-in list item renderer that supports images: <em>IconItemRenderer</em>. This is perfect for displaying lists that have images and text. By default the <em>IconItemRenderer</em> uses a <em>ContentCache</em> object to cache the images. <del>However the <em>ContentCache</em> instance is not shared across all the item renderers.</del></p>
<p>What do I mean? A Flex mobile list uses virtualization. This means that if the list displays 10 items at once it will create about 11 item renderer instances and reuse them. So even if the list has 1,000 items to display only 11 item renderers will be created. Next, each item renderer instance will use a <em>ContentCache</em> instance to cache the images. <del>So in total there will be 11 <em>ContentCache</em> instances. This means that it could happen to have an image already displayed by the list but because it was cached by a different <em>ContentCache</em> instance than the one used by the current item it will be loaded again.</del></p>
<p>The <em>IconItemRenderer</em> class uses a static property to hold an instance of the <em>ContentCache</em>. This means that the same image cache will be used by your list. However, if you have a second list or you use multiple item renderers for the same list, by default, it will be used another instance of <em>ContentCache</em>. The easiest way to fix this is to first create a single <em>ContentCache</em> instance (you can use the Singleton pattern here):</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #9900cc; font-weight: bold;">package</span> org<span style="color: #000066; font-weight: bold;">.</span>corlan<span style="color: #000066; font-weight: bold;">.</span>utils <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>ContentCache<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ImageCache <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> _instance<span style="color: #000066; font-weight: bold;">:</span>ImageCache<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> cache<span style="color: #000066; font-weight: bold;">:</span>ContentCache<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ImageCache<span style="color: #000000;">&#40;</span>s<span style="color: #000066; font-weight: bold;">:</span>Singleton<span style="color: #000066; font-weight: bold;">,</span> maxCacheEntries<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a>=<span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cache = <span style="color: #0033ff; font-weight: bold;">new</span> ContentCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cache<span style="color: #000066; font-weight: bold;">.</span>maxCacheEntries = maxCacheEntries<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getInstance<span style="color: #000000;">&#40;</span>maxCacheEntries<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a>=<span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>ImageCache <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ImageCache<span style="color: #000066; font-weight: bold;">.</span>_instance == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ImageCache<span style="color: #000066; font-weight: bold;">.</span>_instance = <span style="color: #0033ff; font-weight: bold;">new</span> ImageCache<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Singleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> maxCacheEntries<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> ImageCache<span style="color: #000066; font-weight: bold;">.</span>_instance<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #9900cc; font-weight: bold;">class</span> Singleton <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
<p>Then you extend the <em>IconItemRenderer</em> and set this Singleton as the <em>contentLoader</em> object:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ListItemRenderer <span style="color: #0033ff; font-weight: bold;">extends</span> IconItemRenderer <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ListItemRenderer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iconContentLoader = ImageCache<span style="color: #000066; font-weight: bold;">.</span>getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>cache<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
<p>When you build from scratch a list item renderer that uses images, you can use the same approach.</p>
<p>Obviously this technique can be used for other places as well not only for lists.</p>
<h2>Drawbacks</h2>
<p>As with any caching or pooling technique there are trade-offs. You have to find a fine balance between not caching any images and caching all the images. By default the <em>ContentLoader</em> is set to cache 100 entries. But this doesn&#8217;t mean that it is the best value.  It all depends on how big the images are and how much memory you want to use for caching. So be sure you take this into consideration when caching images.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/08/16/flex-mobile-development-caching-images-using-contentcache/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flex Mobile Development: Creating Dialog Windows</title>
		<link>http://corlan.org/2011/08/10/flex-mobile-development-creating-dialog-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-mobile-development-creating-dialog-windows</link>
		<comments>http://corlan.org/2011/08/10/flex-mobile-development-creating-dialog-windows/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 14:54:42 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3088</guid>
		<description><![CDATA[
			
				
			
		
Ever wondered how to create a modal dialog window in Flex mobile applications? For example, you may want to ask the user for a confirmation when he performs a delete operation or maybe to select an item from a list. Well, if you don&#8217;t know how to do it, then read on.
Flex has a class [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/08/10/flex-mobile-development-creating-dialog-windows/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F10%2Fflex-mobile-development-creating-dialog-windows%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F10%2Fflex-mobile-development-creating-dialog-windows%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Ever wondered how to create a modal dialog window in Flex mobile applications? For example, you may want to ask the user for a confirmation when he performs a delete operation or maybe to select an item from a list. Well, if you don&#8217;t know how to do it, then read on.</p>
<p>Flex has a class that just does this: <em><a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/SkinnablePopUpContainer.html">SkinnablePopUpContainer</a></em>. <em>SkinnablePopUpContainer</em> extends <em>SkinnableContainer</em> class and has a very simple API you can use in order to &#8220;open&#8221; and &#8220;close&#8221; the dialog.</p>
<h2>Understanding SkinnablePopUpContainer</h2>
<p>Because <em>SkinnablePopUpContainer</em> extends the <em>SkinnableContainer</em> it is extremely easy to create any kind of dialog window you want. You can create a new MXML component that extends the <em>SkinnablePopUpContainer</em>. Then you set a layout manager that works for you (VerticalLayout, HorizontalLayout). And finally, you add the UI components you need &#8211; labels, buttons, lists, and so on.</p>
<p>Suppose you want to create a simple alert window that looks like this:</p>
<p><img title="Alert Window" src="http://corlan.org/wp-content/uploads/2011/08/dialog1.png" alt="" width="437" height="145" /></p>
<p><span id="more-3088"></span></p>
<p>Here is the code to implement this (as a new MXML component that extends <em>SkinnablePopUpContainer</em>):</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:SkinnablePopUpContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    backgroundColor="0x898989"&gt;

    &lt;s:layout&gt;
        &lt;s:VerticalLayout horizontalAlign="center"/&gt;
    &lt;/s:layout&gt;

   &lt;s:Label text="The contact was saved" width="100%" textAlign="center"/&gt;
   &lt;s:Button label="OK" width="100%" click="this.close()"/&gt;
&lt;/s:SkinnablePopUpContainer&gt;</pre>
<p>The API for controlling the <em>SkinnablePopUpContainer</em> is pretty simple:</p>
<ul>
<li>To open or display the window you create a new instance and then call the <em>open()</em> method of <em>SkinnablePopUpContainer</em>. This method has two arguments. The first argument is the display object container where it will be created. The second argument is a flag that tells Flex if the window will be modal or not.</li>
<li>To close the window and send data from the window to the application you use the <em>close</em>() method of <em>SkinnablePopUpContainer</em>. This methods also has two arguments. The first argument is a flag. You can set this to true if, for example, the user clicked the OK button, and false otherwise. If you want to send some data back to the application you use the second argument. For example, if you have a <em>TextInput</em> in your dialog and you want to send the text you will use this second argument.</li>
<li>To listen for the close event and read the data sent from the <em>SkinnablePopUpContainer</em> you have to register an event listener on the <em>SkinnablePopUpContainer</em>. The event type is <em>PopUpEvent</em>. <em>PopUpEvent</em> has two properties that you can use to read the flag and data set when calling the <em>close()</em> method: <em>commit</em> and <em>data</em>.</li>
</ul>
<p>Here is an example of how to open a <em>SkinnablePopUpContainer</em> component and read the flag/data when it is closed:</p>
<pre>//create the component and open it
var alertWindow:SkinnablePopUpContainer = new SkinnablePopUpContainer();
alertWindow.addEventListener(PopUpEvent.CLOSE, onAlertClose, false, 0, true);
alertWindow.width = stage.width;
alertWindow.height = stage.height / 2;
alertWindow.x = 0;
alertWindow.y = 100;
alertWindow.open(this, true);

private function onAlertClose(event:PopUpEvent):void {
    trace(event.commit);
    trace(event.data);
    alertWindow = null;
}</pre>
<h2>Creating custom dialog windows</h2>
<p>Once you understand how to use the <em>SkinnablePopUpContainer</em> it is pretty simple to create any kind of dialog window you might need: confirmation messages, simple alerts, pop up lists, and so on. Here is the code for a confirmation window that has two buttons (Yes and No) and lets you set the message text:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>SkinnablePopUpContainer xmlns<span style="color: #000066; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;0&#215;898989&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;400&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>layout<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>VerticalLayout gap=<span style="color: #990000;">&quot;20&quot;</span> paddingBottom=<span style="color: #990000;">&quot;10&quot;</span> paddingLeft=<span style="color: #990000;">&quot;30&quot;</span> paddingRight=<span style="color: #990000;">&quot;30&quot;</span> paddingTop=<span style="color: #990000;">&quot;30&quot;</span> horizontalAlign=<span style="color: #990000;">&quot;center&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>layout<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _message<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">message</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _message<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">message</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _message = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onClick<span style="color: #000000;">&#40;</span>commit<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span>commit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{message}&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> textAlign=<span style="color: #990000;">&quot;center&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>HGroup <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;Yes&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;50%&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;onClick(true)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;No&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;50%&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;onClick(false)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>HGroup<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>SkinnablePopUpContainer<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>And here is how this component look on my Android phone:</p>
<p><img title="Confirmation Window" src="http://corlan.org/wp-content/uploads/2011/08/dialog2.png" alt="" width="251" height="400" /></p>
<p>And here is the code for a pop up list that lets you to set the title, the list&#8217;s data provider, the list&#8217;s label field, the list&#8217;s initial selected items, and multiple selections (you can retrieve the selected items by listening for <em>PopupEvent.CLOSE</em> and reading the <em>data</em> attribute).</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>SkinnablePopUpContainer xmlns<span style="color: #000066; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;0&#215;898989&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;400&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>layout<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>VerticalLayout gap=<span style="color: #990000;">&quot;20&quot;</span> paddingBottom=<span style="color: #990000;">&quot;10&quot;</span> paddingLeft=<span style="color: #990000;">&quot;30&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paddingRight=<span style="color: #990000;">&quot;30&quot;</span> paddingTop=<span style="color: #990000;">&quot;30&quot;</span> horizontalAlign=<span style="color: #990000;">&quot;center&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>layout<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>collections<span style="color: #000066; font-weight: bold;">.</span>ArrayCollection<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dataProvider<span style="color: #000066; font-weight: bold;">:</span>ArrayCollection<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _labelField<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _allowMultipleSelection<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _selectedItems<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Object<span style="color: #000066; font-weight: bold;">&gt;;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> selectedItems<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Object<span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _selectedItems<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> selectedItems<span style="color: #000000;">&#40;</span>v<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Object<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _selectedItems = v<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> allowMultipleSelection<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _allowMultipleSelection<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> allowMultipleSelection<span style="color: #000000;">&#40;</span>v<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _allowMultipleSelection = v<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> labelField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _labelField<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> labelField<span style="color: #000000;">&#40;</span>v<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _labelField = v<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> dataProvider<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>ArrayCollection <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _dataProvider<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> dataProvider<span style="color: #000000;">&#40;</span>v<span style="color: #000066; font-weight: bold;">:</span>ArrayCollection<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dataProvider = v<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onClick<span style="color: #000000;">&#40;</span>commit<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span>commit<span style="color: #000066; font-weight: bold;">,</span> list<span style="color: #000066; font-weight: bold;">.</span>selectedItems<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Select an item:&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>List id=<span style="color: #990000;">&quot;list&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataProvider=<span style="color: #990000;">&quot;{dataProvider}&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelField=<span style="color: #990000;">&quot;{labelField}&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allowMultipleSelection=<span style="color: #990000;">&quot;{allowMultipleSelection}&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedItems=<span style="color: #990000;">&quot;{selectedItems}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>HGroup <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;OK&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;50%&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;onClick(true)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;Cancel&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;50%&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;onClick(false)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>HGroup<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>SkinnablePopUpContainer<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>And here is the component running on my phone:</p>
<p><img class="alignnone size-full wp-image-3095" title="Popup List Dialog" src="http://corlan.org/wp-content/uploads/2011/08/dialog3.png" alt="" width="250" height="400" /></p>
<h2>Skinning</h2>
<p>The two custom dialog windows I showed you in the previous section use the default look and feel. What about skinning a <em>SkinnablePopUpContainer</em>? There is a Flex class that provides the default skin for a <em>SkinnablePopUpContainer</em>: <em>SkinnablePopUpContainerSkin</em>. By creating a skin that extends this default skin you can change the background of the component quite easily. If you look at the <em>SkinnablePopUpContainerSkin</em> skin you&#8217;ll notice that it has a <em>rect</em> with the id equal to <em>background</em>. This is the starting point to change the default background. You can draw additional stuff on top of this background or replace it alltogether with an FXG or PNG file.</p>
<p>For the rest of the UI components used in a <em>SkinnablePopUpContainer </em>(buttons, text inputs, labels, and so on) you will create additional skins and/or use CSS. Here is a screenshot with the same confirmation window but this time using a custom skin:</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/08/dialog4.png"><img class="alignnone size-full wp-image-3098" title="Skinned Confirmation Window" src="http://corlan.org/wp-content/uploads/2011/08/dialog4.png" alt="" width="251" height="400" /></a></p>
<p>Here is the skin class used to customize the confirmation window presented in the previous section:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Skin xmlns<span style="color: #000066; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> xmlns<span style="color: #000066; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #000066; font-weight: bold;">:</span>fb=<span style="color: #990000;">&quot;http://ns.adobe.com/flashbuilder/2009&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">alpha</span><span style="color: #000066; font-weight: bold;">.</span>disabled=<span style="color: #990000;">&quot;0.5&quot;</span> xmlns<span style="color: #000066; font-weight: bold;">:</span>skins=<span style="color: #990000;">&quot;org.corlan.dialog.skins.*&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span>Metadata<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/** </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @copy spark.skins.spark.ApplicationSkin#hostComponent</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>HostComponent<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;spark.components.SkinnablePopUpContainer&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fx<span style="color: #000066; font-weight: bold;">:</span>Metadata<span style="color: #000066; font-weight: bold;">&gt;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>states<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;normal&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;disabled&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;closed&quot;</span> stateGroups=<span style="color: #990000;">&quot;closedGroup&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;disabledAndClosed&quot;</span> stateGroups=<span style="color: #990000;">&quot;closedGroup&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>states<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!&#8211;</span> Transitions <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #004993;">open</span> and <span style="color: #004993;">close</span> <span style="color: #000066; font-weight: bold;">&#8211;&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>transitions<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition fromState=<span style="color: #990000;">&quot;closed&quot;</span> toState=<span style="color: #990000;">&quot;normal&quot;</span> autoReverse=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Fade duration=<span style="color: #990000;">&quot;150&quot;</span> <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{chrome}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition fromState=<span style="color: #990000;">&quot;disabledAndClosed&quot;</span> toState=<span style="color: #990000;">&quot;disabled&quot;</span> autoReverse=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Fade duration=<span style="color: #990000;">&quot;150&quot;</span> <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{chrome}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition fromState=<span style="color: #990000;">&quot;normal&quot;</span> toState=<span style="color: #990000;">&quot;closed&quot;</span> autoReverse=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Fade duration=<span style="color: #990000;">&quot;150&quot;</span> <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{chrome}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition fromState=<span style="color: #990000;">&quot;disabled&quot;</span> toState=<span style="color: #990000;">&quot;disabledAndClosed&quot;</span> autoReverse=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Fade duration=<span style="color: #990000;">&quot;150&quot;</span> <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{chrome}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>Transition<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>transitions<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!&#8212;</span> Defines the <span style="color: #004993;">background</span> and <span style="color: #004993;">content</span> group used by <span style="color: #0033ff; font-weight: bold;">this</span> skin<span style="color: #000066; font-weight: bold;">.</span> <span style="color: #000066; font-weight: bold;">&#8211;&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>Group id=<span style="color: #990000;">&quot;chrome&quot;</span> <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">visible</span><span style="color: #000066; font-weight: bold;">.</span>closedGroup=<span style="color: #990000;">&quot;false&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!&#8212;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Defines the appearance of the SkinnablePopUpContainer <span style="color: #9900cc; font-weight: bold;">class</span><span style="color: #990000;">&#8216;s background. </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; In this case a FXG file is used to draw the background.</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211;&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;skins:BackGroundAlert id=&quot;background&quot; left=&quot;0&quot; right=&quot;0&quot; top=&quot;0&quot; bottom=&quot;0&quot;/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;!&#8212; @copy spark.components.SkinnableContainer#contentGroup &#8211;&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;s:Group id=&quot;contentGroup&quot; left=&quot;0&quot; right=&quot;0&quot; top=&quot;0&quot; bottom=&quot;0&quot; minWidth=&quot;0&quot; minHeight=&quot;0&quot;&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;s:layout&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;s:BasicLayout/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/s:layout&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/s:Group&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp;&lt;/s:Group&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;"> &nbsp; &nbsp;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #990000;">&lt;/s:Skin&gt;</span></div>
</li>
</ol>
</div>
<p>And this is the FXG used by the skin class to draw the background:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span> <span style="color: #000066; font-weight: bold;">?&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>Graphic <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;2.0&quot;</span> xmlns=<span style="color: #990000;">&quot;http://ns.adobe.com/fxg/2008&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">d</span>=<span style="color: #990000;">&quot;http://ns.adobe.com/fxg/2008/dt&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #000066; font-weight: bold;">:</span>flm=<span style="color: #990000;">&quot;http://ns.adobe.com/flame/2008&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; scaleGridLeft=<span style="color: #990000;">&quot;10&quot;</span> scaleGridTop=<span style="color: #990000;">&quot;10&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; scaleGridRight=<span style="color: #990000;">&quot;90&quot;</span> scaleGridBottom=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>Rect <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100&quot;</span> radiusX=<span style="color: #990000;">&quot;10&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>LinearGradient <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;190.417&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">scaleX</span>=<span style="color: #990000;">&quot;361.667&quot;</span> <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.0424137&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#E1DBCE&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.0886452&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#CEC3AE&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.139618&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#C4B89F&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.208589&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#C2B59B&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.588957&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#C2B59B&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.758513&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#C0B399&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.852955&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#B2A58E&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;0.932468&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#918372&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>GradientEntry ratio=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#594A42&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>LinearGradient<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fill<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>stroke<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>SolidColorStroke weight=<span style="color: #990000;">&quot;3&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>stroke<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>Rect<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>Graphic<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<h2>Download</h2>
<p>You can download a working Flex project that includes all the code used in this article from <a href="https://github.com/mcorlan/AlertExample">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/08/10/flex-mobile-development-creating-dialog-windows/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>AIR 3 Beta and Flash Player 11 Beta are out!</title>
		<link>http://corlan.org/2011/08/10/air-3-beta-and-flash-player-11-beta-are-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=air-3-beta-and-flash-player-11-beta-are-out</link>
		<comments>http://corlan.org/2011/08/10/air-3-beta-and-flash-player-11-beta-are-out/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 09:29:58 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=3084</guid>
		<description><![CDATA[
			
				
			
		
We just released AIR 3 Beta 2 for desktop and Flash Player 11 Beta for desktop. You can download them from here and here.
Here is a list of the most important news in these releases.
AIR 3 Beta:

You can download the AIR 3 SDK and start building mobile and desktop apps. You can also download the [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/08/10/air-3-beta-and-flash-player-11-beta-are-out/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F10%2Fair-3-beta-and-flash-player-11-beta-are-out%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F08%2F10%2Fair-3-beta-and-flash-player-11-beta-are-out%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We just released AIR 3 Beta 2 for desktop and Flash Player 11 Beta for desktop. You can download them from <a href="http://labs.adobe.com/downloads/air3.html">here</a> and <a href="http://labs.adobe.com/downloads/flashplayer11.html">here</a>.</p>
<p>Here is a list of the most important news in these releases.</p>
<p><strong>AIR 3 Beta:</strong></p>
<ul>
<li>You can download the AIR 3 SDK and start building mobile and desktop apps. You can also download the AIR 3 runtimes for Windows and Mac OS</li>
<li><strong>Stage Video Hardware Acceleration for mobile</strong> ( previously, this was available only for desktops). This will enable developers to leverage hardware acceleration for decoding and composing the video on the screen. This means reduced memory and CPU usage and smoother video playback.</li>
<li><strong>Captive Runtime Support (AIR for desktop and Android)</strong>. You will be able to package your application with a captive runtime. This enables you either to use a specific version of the runtime instead of what the user might have or to push the app together with the runtime so the user doesn&#8217;t have to go through the installation process of the runtime. Needless to say that this was one popular request :)</li>
<li><strong>iOS Background Audio Playback Support</strong>. You can write multi-tasking apps that can play audio in background.</li>
<li><strong>Android Licensing Service Support</strong>. You have access to the Android Market Licensing Service so you can enforce licensing policies for paid apps that are published through Android Market.</li>
<li><strong>Android Front-facing Camera Support</strong>. This is another popular request. This was already available on iOS and PlayBook; now you can use it on Android too.</li>
<li><strong>Encrypted Local Storage for Mobile</strong>. Another feature that developers wanted badly. Now you can store encrypted data the same way you would do on AIR desktop apps. Great for storing passwords and other sensitive data.</li>
<li><strong> </strong><strong>H.264/AVC Software Encoding for Cameras for Desktop</strong>. You can stream high-quality video from your computer&#8217;s camera with better compression and industry-standard support.</li>
</ul>
<p>You can read more <a href="http://labs.adobe.com/technologies/flashplatformruntimes/air3/">here</a>.</p>
<p><strong>Flash Player 11 desktop Beta:</strong></p>
<ul>
<li><strong>Stage3D APIs (AKA Molehill)</strong>. 3D GPU accelerated graphics.</li>
<li><strong>Native 64-bit support</strong>. For 64-bit operating systems (Linux, Mac OS, and Windows).</li>
<li><strong>G.711 audio compression for telephony</strong>. Real-time voice and telephony capabilities and support for integration with existing phone systems using a G.711 codec.</li>
<li><strong>Socket Progress Events</strong>. This was another feature requested by many developers.</li>
<li><strong>JPEG-XR support</strong>. Support for JPEG-XR compression format so you can use higher quality images with less bandwidth. Plus you can use alpha channel transparency.</li>
</ul>
<p>You can read more <a href="http://labs.adobe.com/technologies/flashplatformruntimes/flashplayer11/features.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/08/10/air-3-beta-and-flash-player-11-beta-are-out/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adobe Mobile Challenge</title>
		<link>http://corlan.org/2011/07/06/adobe-mobile-challenge/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adobe-mobile-challenge</link>
		<comments>http://corlan.org/2011/07/06/adobe-mobile-challenge/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 10:07:43 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[PlayBook]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2980</guid>
		<description><![CDATA[
			
				
			
		
My fellow evangelist, Michael Chaize, has way too much time. During the weekend he put together this nice site to announce a contest to the world. Oops, not to the world, but to those living in the European Union.

So, if you live in European Union and you publish an AIR application to Android Market, Apple [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/07/06/adobe-mobile-challenge/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F07%2F06%2Fadobe-mobile-challenge%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F07%2F06%2Fadobe-mobile-challenge%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>My fellow evangelist, Michael Chaize, has way too much time. During the weekend he put together this nice site to announce a contest to the world. Oops, not to the world, but to those living in the European Union.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-2981" title="airmobilelogo_raster" src="http://corlan.org/wp-content/uploads/2011/07/airmobilelogo_raster.jpg" alt="" width="405" height="251" /></p>
<p>So, if you live in European Union and you publish an AIR application to Android Market, Apple App Store, and BlackBerry App World by September 1st 2011 then you can enter in this competition. What can you win? Well, it depends. If the grand jury (all European Adobe Evangelists) picks you as  one of the winners then you can get a trip to Adobe MAX 2011 Los Angeles or Adobe Creative Suite software. If your application is not a winner than you can still win experience and maybe some good feedback from the jury :)</p>
<p>Here is the man himself introducing the contest (don&#8217;t ask me why he is talking like this. All I know is that he lives in Paris :D):</p>
<p><iframe src="http://www.youtube.com/embed/pp5RSDyK6T8" width="560" frameborder="0" height="349"></iframe></p>
<p>Now, don&#8217;t be lazy and start working on your amazing app! You can read more about the contest <a href="http://www.adobemobilechallenge.com/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/07/06/adobe-mobile-challenge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating Flex Mobile Section Lists</title>
		<link>http://corlan.org/2011/07/04/creating-flex-mobile-section-lists/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-flex-mobile-section-lists</link>
		<comments>http://corlan.org/2011/07/04/creating-flex-mobile-section-lists/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 01:30:50 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2931</guid>
		<description><![CDATA[
			
				
			
		
For a mobile application I&#8217;m working on I need a section list. If you are familiar with the Flex framework you know that you don&#8217;t have built-in section list components (you can have vertical, horizontal, and tile lists). I played a little bit with the Flex List, IconItemRenderer, and BasicLayout classes and managed to put [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/07/04/creating-flex-mobile-section-lists/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F07%2F04%2Fcreating-flex-mobile-section-lists%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F07%2F04%2Fcreating-flex-mobile-section-lists%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>For a mobile application I&#8217;m working on I need a section list. If you are familiar with the Flex framework you know that you don&#8217;t have built-in section list components (you can have vertical, horizontal, and tile lists). I played a little bit with the Flex List, IconItemRenderer, and BasicLayout classes and managed to put together two section lists: a vertical section list and a tile section list. In this post I will talk about how I did it and about some theory behind the list components.</p>
<p><span id="more-2931"></span></p>
<h2>What is a Section List?</h2>
<p>Before talking about code, let&#8217;s establish what a section list is:</p>
<ul>
<li>It is a list that provides a way to render items grouped in sections. For example, if you have a data structure like &#8220;Fruits, Banana, Cherry, Kiwi, Cheese, Cheddar, Gorgonzola&#8221; a section list will render this data in a way that makes it clear that Fruits/Banana/Cherry/Kiwi is one section and Cheese/Cheddar/Gorgonzola is another one;</li>
<li>The section title items can&#8217;t be selectable. In our example, clicking on Fruits or Cheese items will not throw a select event nor will it select the item;</li>
<li>Section title items should be rendered so that it is clear they are different from regular items.</li>
</ul>
<p>Here is an example of a vertical section list (blue items are section title items, the gray Blueberries item represents the current selection):</p>
<p><img class="aligncenter size-full wp-image-2941" title="section-list" src="http://corlan.org/wp-content/uploads/2011/06/section-list.png" alt="" width="300" height="434" /></p>
<p>If you wonder why you&#8217;d need such a list, here are a couple of examples where you can find it pretty useful:</p>
<ul>
<li>You have a list of people and you want to display the items sorting alphabetically. By creating sections A, B, C, and so on users can easily navigate through the sections to find what they are looking for;</li>
<li>You have a properties or preference page in your application with a bunch of options (for example, Editing, Account, and so forth). You can nicely organize the information so users can find their way quickly.</li>
</ul>
<h2>Some Theory Behind Flex lists</h2>
<p>This is the boring section of this post :) If you don&#8217;t like it, feel free to skip it :D</p>
<p>Flex mobile lists inherit the architecture of the Spark components introduced in Flex 4 back in 2010. An oversimplified dissection of a Flex mobile list would reveal these &#8220;organs&#8221;: list component, DataGroup, Scroller, layout manager, and item renderer. By default a Flex mobile list is a vertical list (items are rendered vertically and if there are more than can be fitted on the view port than you can scroll the list up and down).</p>
<p>Here is a description of how these things work together:</p>
<ul>
<li>The list component uses a container for holding the items that will be displayed. This container is an instance of the <em>DataGroup</em> class.</li>
<li>The <em>DataGroup</em> container implements the <em>IViewport</em> interface. If the items to be displayed don&#8217;t fit in the viewport, they are clipped.</li>
<li>To scroll the viewport of the <em>DataGroup</em> and see the rest of the items, a <em>Scroller</em> is used. In the case of the mobile Flex list the <em>Scroller</em> displays a scrollbar only when you interact with the list (by default it is hidden). Its size gives a visual clue about the number of the elements from the list (the more elements in the list, the smaller the thumb).</li>
<li>The list component uses a layout manager. This class is in control of how and where the items displayed in the <em>DataGroup</em> are rendered.</li>
<li>Each item of the list is displayed using an item renderer. The Flex framework gives you two built-in item renderers for lists: <em>IconItemRenderer</em> and <em>LabelRenderer</em>. The item renderer class is in charge of how an item will be rendered on the screen. Lists are designed to work with a single item renderer.</li>
<li>The list component has a property called <em>dataProvider</em> that you can use to set the data you want to display. Typically you&#8217;d assign to this property and <em>Array</em> or an <em>ArrayCollection</em> of <em>Strings</em> or <em>Objects</em>.</li>
<li>Finally, mobile lists use virtualization (the virtualization part is implemented actually by the layout manager). This means that only the items that are visible in the viewport are rendered. And when the viewport is moved (for example, you scroll the list down) the item renderers of the items that were moved out of the view port are reused for the items that just got in the view port. This way, even on a mobile device, you can have lists with 10,000 items and you want run out of memory. However there is still a cost with this approach: the <em>DataGroup</em> has to execute a bunch of <em>removeChildAt()</em> and <em>addChildAt()</em> calls in order to reuse the item renderer instances.</li>
</ul>
<p>I won&#8217;t get into details about how everything is linked together at runtime and what methods are called and when. I&#8217;ll save this for another post.</p>
<p>The first section list I wanted to create was a vertical section list. Let&#8217;s see how I implement it.</p>
<h2>Creating a Vertical Section List</h2>
<p>I looked at the built-in Flex mobile list and I realized that making a Vertical Section List would be quite easy. The VerticalLayout manager does all the work I needed, and the only things I had to change were:</p>
<ol>
<li>Disabling item selection for list items that are section titles;</li>
<li>Finding a simple way to define the data provider structure (which data items are section title items and which are just regular items).</li>
<li>Extend one of the two built-in item renderers so I can have two  distinct looks: one for section title items and one for regular items;</li>
</ol>
<p>First, I decided on how to model the data provider used for the <em>SectionList</em>. I decided that I want to be able to use an <em>Array</em> or <em>ArrayCollection</em> of objects and I will use different properties to store the label for section title items and regular items.</p>
<p>Next, I created a new class that extends the Flex List class. In this class I override the <em>item_mouseDownHandler()</em> method. This method is executed each time you touch the list. So all I had to do is to check whether the item touched is a section title item or not. If it is, then I just call <em>event.preventDefault()</em> to cancel the selection.</p>
<p>Next, I added a property named <em>sectionField</em> to store the property name used for defining a data as an section list. Here is the code of the <em>SectionList</em> class:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #9900cc; font-weight: bold;">package</span> org<span style="color: #000066; font-weight: bold;">.</span>corlan<span style="color: #000066; font-weight: bold;">.</span>components <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>components<span style="color: #000066; font-weight: bold;">.</span>IItemRenderer<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>components<span style="color: #000066; font-weight: bold;">.</span>List<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SectionList <span style="color: #0033ff; font-weight: bold;">extends</span> List <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/**</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The property name for data that are section title items</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _sectionField<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> sectionField<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _sectionField = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/**</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Disable selection for section title items </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> item_mouseDownHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">currentTarget</span> <span style="color: #0033ff; font-weight: bold;">is</span> IItemRenderer<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">data</span> = IItemRenderer<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">currentTarget</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">data</span><span style="color: #000000;">&#91;</span>_sectionField<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">preventDefault</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>item_mouseDownHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
<p>Then I created a new item renderer by extending the built-in mobile item renderer <em>IconItemRenderer</em>. <em>IconItemRenderer</em> enables you to display more than just a label (you can have a decorator, an image, and a subtitle). To tell you the truth, I have used only the label. So, I guess I could have chosen the <em>LabelRenderer</em> as well.</p>
<p>The first thing I did was to override the <em>set data()</em> method. This method is called automatically everytime the item renderer class is used to render a data item. So this is the perfect place to check if the data that is about to be displayed is a section title item or not. Depending on the result I change the font alignment and weight and I change the <em>labelField</em> value to the property name to be used as the source of the text.</p>
<p>Next, I override the <em>drawBackground()</em> method. This method draws the background of the item. Depending on what data I have to render I change the color of the background.</p>
<p>Finally, I added three new properties that allow me to set the name of the property that holds a section title item, a regular item, and background color to be used for section title items: <em>sectionField</em> and <em>normalLabelField</em>.</p>
<p>Here is the code of the custom item renderer:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>IconItemRenderer xmlns<span style="color: #000066; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #000066; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> &nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> iconWidth=<span style="color: #990000;">&quot;64&quot;</span> iconHeight=<span style="color: #990000;">&quot;64&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _backgroundSection<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = 0xDDDDDD<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> backgroundSection<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _backgroundSection = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _normalLabelField<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;label&quot;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> normalLabelField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _normalLabelField<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> normalLabelField<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _normalLabelField = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _sectionField<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;section&quot;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> sectionField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _sectionField<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> sectionField<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> == _sectionField<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _sectionField = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invalidateProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/**</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Change the style based on the data: section item or regular item</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #3f5fbf;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">data</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000;">&#91;</span>_sectionField<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelField = _sectionField<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;textAlign&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;center&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;fontWeight&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;bold&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelField = _normalLabelField<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;textAlign&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;left&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;fontWeight&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;normal&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> drawBackground<span style="color: #000000;">&#40;</span>unscaledWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> unscaledHeight<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>drawBackground<span style="color: #000000;">&#40;</span>unscaledWidth<span style="color: #000066; font-weight: bold;">,</span> unscaledHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//change the background if we render for a section title item</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#91;</span>_sectionField<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>_backgroundSection<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> unscaledWidth<span style="color: #000066; font-weight: bold;">,</span> unscaledHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>IconItemRenderer<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>With all this sorted out, here is how you use the <em>SectionList</em> component in your code:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>components<span style="color: #000066; font-weight: bold;">:</span>SectionList id=<span style="color: #990000;">&quot;list&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; sectionField=<span style="color: #990000;">&quot;section&quot;</span> dataProvider=<span style="color: #990000;">&quot;{arr}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>components<span style="color: #000066; font-weight: bold;">:</span>itemRenderer<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span>Component<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>skins<span style="color: #000066; font-weight: bold;">:</span>SectionListItemRenderer </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; normalLabelField=<span style="color: #990000;">&quot;label&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sectionField=<span style="color: #990000;">&quot;section&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backgroundSection=<span style="color: #990000;">&quot;0x1d9cd1&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fx<span style="color: #000066; font-weight: bold;">:</span>Component<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>components<span style="color: #000066; font-weight: bold;">:</span>itemRenderer<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>components<span style="color: #000066; font-weight: bold;">:</span>SectionList<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>This example uses the data provider defined below. This is why I set the <em>sectionField</em> property of the <em>SectionList</em> and <em>SectionListItemRenderer</em> to &#8220;<em>section</em>&#8220;. You can see how the background color for section title items is set.</p>
<p>Defining the data provider:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>s<span style="color: #000066; font-weight: bold;">:</span>ArrayCollection id=<span style="color: #990000;">&quot;arr&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> section=<span style="color: #990000;">&quot;Fruits&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> label=<span style="color: #990000;">&quot;Banana&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> label=<span style="color: #990000;">&quot;Blueberries&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> label=<span style="color: #990000;">&quot;Cherry&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> label=<span style="color: #990000;">&quot;Kiwi&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> section=<span style="color: #990000;">&quot;Vegetables&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> label=<span style="color: #990000;">&quot;Bean&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> label=<span style="color: #990000;">&quot;Cabbage&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> label=<span style="color: #990000;">&quot;Cucumber&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>s<span style="color: #000066; font-weight: bold;">:</span>ArrayCollection<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>Here&#8217;s a video with the list running in the Flash Builder desktop simulator and on my Android phone:</p>
<p><iframe src="http://player.vimeo.com/video/25754936" width="400" frameborder="0" height="225"></iframe></p>
<h2>Creating a Tile Section List</h2>
<p>A tile section list could be handy, especially on tablets. Because you have plenty of space on the horizontal axis you can fit multiple items on the same row and thus make better use of the available screen on the device. Here is an example of tile section list (the item renderer used here doesn&#8217;t do a good job of separating visually adjacent items):</p>
<p><img class="aligncenter size-full wp-image-2966" title="tile-section" src="http://corlan.org/wp-content/uploads/2011/06/tile-section.png" alt="" width="590" height="278" /></p>
<p>If all you need is a tile list then you can use the Flex list with the built-in <em>TileLayout</em> manager.</p>
<p>With the vertical section list up and running all I had to do was to create a new layout manager. This layout manager lays out the items (starting from left to right and top to bottom) using these rules:</p>
<ul>
<li> If the item is a regular item and it is enough room to accommodate it on the current row it will draw the item next to the previous one;</li>
<li>If the item is a regular item and there is not enough room to fit the item on the current row, it goes on the next row;</li>
<li>If the item is a section title item it goes on the next row and fills is the entire view port width.</li>
</ul>
<p>Fortunately, back in 2010, Evtim Georgiev (an engineer on the Flex SDK team) created<a href="http://www.adobe.com/devnet/flex/articles/spark_layouts.html"> a custom layout</a> that was pretty close to what I needed. So I took this layout manager and modified it a little bit. The magic happens in the <em>updateDisplayList()</em> method. This method is called every time the display list of the List is invalidated (for example if you change the width/height of the list or when the list component is initialized). The two arguments of this method represent the view port&#8217;s height and width.</p>
<p><em>updateDisplayList()</em> method is where you position and size the items. For my first run I chose to create a layout manager that doesn&#8217;t use virtualization. This means that updateDisplayList() will iterate over all the items you have in the list and create an item renderer for each one and then position and size the item. The layout manager positions the items in the DataGroup instance used by the list for displaying the items. The item renderer class implements the ILayoutElement interface. Using this API, the layout manager can set the width/height and x/y of each item renderer.</p>
<p>As I explained, the layout manager uses the whole width of the view port for section title items. For regular items, I added a property to the layout manager called columnWidth &#8211; so you can control how many items you can have on the same row.</p>
<p>Here is the code of this custom layout manager (I called it SectionListLayout):</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900; font-style: italic;">//see Evtim Georgiev article http://www.adobe.com/devnet/flex/articles/spark_layouts.html</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #9900cc; font-weight: bold;">package</span> org<span style="color: #000066; font-weight: bold;">.</span>corlan<span style="color: #000066; font-weight: bold;">.</span>layout <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>ILayoutElement<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>components<span style="color: #000066; font-weight: bold;">.</span>supportClasses<span style="color: #000066; font-weight: bold;">.</span>GroupBase<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>layouts<span style="color: #000066; font-weight: bold;">.</span>BasicLayout<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SectionListLayout <span style="color: #0033ff; font-weight: bold;">extends</span> BasicLayout <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _horizontalGap<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _verticalGap<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> explicitColumnWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _columnWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">250</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> SectionListLayout<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> horizontalGap<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _horizontalGap = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// We must invalidate the layout</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> layoutTarget<span style="color: #000066; font-weight: bold;">:</span>GroupBase = <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>layoutTarget<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>invalidateSize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>invalidateDisplayList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> verticalGap<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _verticalGap = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// We must invalidate the layout</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> layoutTarget<span style="color: #000066; font-weight: bold;">:</span>GroupBase = <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>layoutTarget<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>invalidateSize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>invalidateDisplayList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> columnWidth<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; explicitColumnWidth = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> == _columnWidth<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _columnWidth = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> layoutTarget<span style="color: #000066; font-weight: bold;">:</span>GroupBase = <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>layoutTarget<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>invalidateSize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>invalidateDisplayList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// When extending the BasicLayout </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// you have to override this method</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> measure<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> updateDisplayList<span style="color: #000000;">&#40;</span>containerWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> containerHeight<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// The position for the first element</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> maxWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> maxHeight<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> elementWidth<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> elementHeight<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// loop through the elements</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> layoutTarget<span style="color: #000066; font-weight: bold;">:</span>GroupBase = <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> count<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = layoutTarget<span style="color: #000066; font-weight: bold;">.</span>numElements<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> element<span style="color: #000066; font-weight: bold;">:</span>ILayoutElement<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> count<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// get the current element, we&#8217;re going to work with the</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// ILayoutElement interface</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element = useVirtualLayout <span style="color: #000066; font-weight: bold;">?</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>getVirtualElementAt<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>getElementAt<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Resize the element to its preferred size by passing</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// NaN for the width and height constraints</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element<span style="color: #000066; font-weight: bold;">.</span>setLayoutBoundsSize<span style="color: #000000;">&#40;</span><span style="color: #004993;">NaN</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">NaN</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elementHeight = element<span style="color: #000066; font-weight: bold;">.</span>getLayoutBoundsHeight<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>element <span style="color: #0033ff; font-weight: bold;">as</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000;">&#40;</span>element <span style="color: #0033ff; font-weight: bold;">as</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span>section<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element<span style="color: #000066; font-weight: bold;">.</span>setLayoutBoundsSize<span style="color: #000000;">&#40;</span>containerWidth<span style="color: #000066; font-weight: bold;">,</span> elementHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elementWidth = containerWidth<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element<span style="color: #000066; font-weight: bold;">.</span>setLayoutBoundsSize<span style="color: #000000;">&#40;</span>_columnWidth<span style="color: #000066; font-weight: bold;">,</span> elementHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elementWidth = _columnWidth<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Would the element fit on this line, or should we move</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// to the next line?</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> elementWidth <span style="color: #000066; font-weight: bold;">&gt;</span> containerWidth<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span>= elementHeight <span style="color: #000066; font-weight: bold;">+</span> _verticalGap<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Position the element</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element<span style="color: #000066; font-weight: bold;">.</span>setLayoutBoundsPosition<span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Find maximum element extents. This is needed for</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// the scrolling support.</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maxWidth = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>maxWidth<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> elementWidth<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maxHeight = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>maxHeight<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span> elementHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Update the current position, add the gap</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span>= elementWidth <span style="color: #000066; font-weight: bold;">+</span> _horizontalGap<span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Scrolling support &#8211; update the content size</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layoutTarget<span style="color: #000066; font-weight: bold;">.</span>setContentSize<span style="color: #000000;">&#40;</span>maxWidth<span style="color: #000066; font-weight: bold;">,</span> maxHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
<p>The item renderer and list data provider are the same as the ones used for the vertical section list. I&#8217;m using the same SectionList I created earlier. Here is how I instantiate the SectionList and set the various properties:</p>
<div class='sniplrcode'>
<ol class="actionscript3" style="font-family:monospace;">
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;</span>components<span style="color: #000066; font-weight: bold;">:</span>SectionList id=<span style="color: #990000;">&quot;list&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; sectionField=<span style="color: #990000;">&quot;section&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; dataProvider=<span style="color: #990000;">&quot;{arr}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>components<span style="color: #000066; font-weight: bold;">:</span>layout<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>layout<span style="color: #000066; font-weight: bold;">:</span>SectionListLayout columnWidth=<span style="color: #990000;">&quot;200&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>components<span style="color: #000066; font-weight: bold;">:</span>layout<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>components<span style="color: #000066; font-weight: bold;">:</span>itemRenderer<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>fx<span style="color: #000066; font-weight: bold;">:</span>Component<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>skins<span style="color: #000066; font-weight: bold;">:</span>SectionListItemRenderer </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; normalLabelField=<span style="color: #990000;">&quot;label&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sectionField=<span style="color: #990000;">&quot;section&quot;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backgroundSection=<span style="color: #990000;">&quot;0x1d9cd1&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>fx<span style="color: #000066; font-weight: bold;">:</span>Component<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>components<span style="color: #000066; font-weight: bold;">:</span>itemRenderer<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">&lt;/</span>components<span style="color: #000066; font-weight: bold;">:</span>SectionList<span style="color: #000066; font-weight: bold;">&gt;</span></div>
</li>
</ol>
</div>
<p>And here is a video with the tile section list in action:</p>
<p><iframe src="http://player.vimeo.com/video/25760761" width="400" frameborder="0" height="225"></iframe></p>
<h2>Caveat</h2>
<p>Obviously, a layout manager that doesn&#8217;t support virtualization could trigger performance issues when you have  hundreds or thousands of items (at least on mobile devices; on the desktop you probably won&#8217;t run into this most of the time). However, if you don&#8217;t have many items, than it could be actually faster than a layout that uses virtualization.</p>
<p>LATER UPDATE: You can read <a href="http://corlan.org/2011/07/11/creating-flex-mobile-lists-part-ii-using-virtualization/">here</a> how you can create layout managers that support virtualization.</p>
<p>Why? Because when a list uses virtualization, it recycles the item renderers (as soon as you move out of the screen an item, its item renderer is reused for an item that just got into the view port). This means that as each item renderer is recycled, it must be removed from the <em>DataGroup</em> display list, new data are set, the item is redrawn if necessary, and it is added to the <em>DataGroup</em> display list.</p>
<p>Right now I&#8217;m working on a Tile Section Layout manager with support for virtualization. Once I finish it, I will write another blog post that will explain in greater depth &#8220;the art&#8221; of creating layout managers.</p>
<h2>Download the code</h2>
<p>You can download the source code of the Flex mobile project from my <a href="https://github.com/mcorlan/SimpleSectionList">GitHub account</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/07/04/creating-flex-mobile-section-lists/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flash Builder 4.5.1 and Flex 4.5.1 are out!</title>
		<link>http://corlan.org/2011/06/20/flash-builder-4-5-1-and-flex-4-5-1-are-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flash-builder-4-5-1-and-flex-4-5-1-are-out</link>
		<comments>http://corlan.org/2011/06/20/flash-builder-4-5-1-and-flex-4-5-1-are-out/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 09:33:23 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PlayBook]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2924</guid>
		<description><![CDATA[
			
				
			
		
When we launched Flash Builder and Flex 4.5 in May we said that we will have an update a month later that brings Flex mobile development to all three platforms: Android, iOS, and PlayBook (BlackBerry Tablet OS). And this is the update we were talking about.
So starting today, you can build all sorts of amazing [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/06/20/flash-builder-4-5-1-and-flex-4-5-1-are-out/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F06%2F20%2Fflash-builder-4-5-1-and-flex-4-5-1-are-out%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F06%2F20%2Fflash-builder-4-5-1-and-flex-4-5-1-are-out%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>When we launched Flash Builder and Flex 4.5 in May we said that we will have an update a month later that brings Flex mobile development to all three platforms: Android, iOS, and PlayBook (BlackBerry Tablet OS). And this is the update we were talking about.</p>
<p>So starting today, you can build all sorts of amazing mobile apps that run across these different devices.</p>
<p>If you want to find more about this, make sure you register for <a href="http://www.adobe.com/cfusion/event/index.cfm?event=detail&amp;id=1489921&amp;loc=en_us">Adobe Developer Week</a>. This is a series of webinars that will start today.</p>
<p>In the meantime you can check <a href="http://www.webkitchen.be/2011/06/20/build-ios-applications-with-flex-and-flash-builder-4-5-1/">Serge</a>&#8216;s videos.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/06/20/flash-builder-4-5-1-and-flex-4-5-1-are-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe AIR 2.7 is out!</title>
		<link>http://corlan.org/2011/06/15/adobe-air-2-7-is-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adobe-air-2-7-is-out</link>
		<comments>http://corlan.org/2011/06/15/adobe-air-2-7-is-out/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 10:03:03 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2920</guid>
		<description><![CDATA[
			
				
			
		
We&#8217;ve just released Adobe AIR 2.7 for desktop, Android, iOS, and PlayBook. In terms of features, here is a list of the most important.
Mobile:

Improved performance for AIR apps (including those built with Flex) running on iOS. You will see up to a 4X improvement for the same app when running on AIR 2.7.
Faster development time [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/06/15/adobe-air-2-7-is-out/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F06%2F15%2Fadobe-air-2-7-is-out%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F06%2F15%2Fadobe-air-2-7-is-out%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We&#8217;ve just released Adobe AIR 2.7 for desktop, Android, iOS, and PlayBook. In terms of features, here is a list of the most important.</p>
<p>Mobile:</p>
<ul>
<li>Improved performance for AIR apps (including those built with Flex) running on iOS. You will see up to a 4X improvement for the same app when running on AIR 2.7.</li>
<li>Faster development time for iOS applications &#8211; there is a new mode for testing and debugging your AIR app on iOS devices that will enable faster cycles.</li>
<li>And this is one I&#8217;m sure you&#8217;ll love: you can install the AIR runtime on the SD card of your Android device.</li>
</ul>
<p>Desktop:</p>
<ul>
<li>Integrated support for Media Measurement &#8211; allows companies to see how content is distributed and viewed by users</li>
<li>Acoustic echo cancellation &#8211; this is the same feature already available in Flash Player 10.3. It means you can enable users to do VoIP using speakers and microphone (no need for headsets).</li>
<li>Navigation Improvements for HTML Content &#8211; developers can now respond to a new event to be notified when content  within the HTMLLoader control attempts to change the location of a page.  This enhancement provides developers with a better way to implement  intra-application navigation.</li>
</ul>
<p>Watch my fellow evangelist, Renaun Erickson, showing AIR app performance on an iPad:</p>
<p><iframe title="AdobeTV Video Player" src="http://tv.adobe.com/embed/76/10277/" frameborder="0" height="296" scrolling="no" width="480"></iframe></p>
<p>You can download AIR 2.7 from <a href="http://www.adobe.com/products/air/">here</a>. This month, Flash Builder 4.5 will get an update to enable support for AIR 2.7 and PlayBook will receive an update OTA of AIR 2.7 by the end of June.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/06/15/adobe-air-2-7-is-out/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Creating Flex Mobile Apps with Flash Builder for PHP</title>
		<link>http://corlan.org/2011/05/05/creating-flex-mobile-apps-with-flash-builder-for-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-flex-mobile-apps-with-flash-builder-for-php</link>
		<comments>http://corlan.org/2011/05/05/creating-flex-mobile-apps-with-flash-builder-for-php/#comments</comments>
		<pubDate>Thu, 05 May 2011 16:18:37 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2840</guid>
		<description><![CDATA[
			
				
			
		
As you might have heard, we released earlier this week Flash Builder and Flex 4.5. Part of this release is a new product called Flash Builder for PHP 4.5. This is something you should make sure you try if you are a PHP and Flash/Flex developer.
So what is Flash Builder for PHP? This product will [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/05/05/creating-flex-mobile-apps-with-flash-builder-for-php/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F05%2F05%2Fcreating-flex-mobile-apps-with-flash-builder-for-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F05%2F05%2Fcreating-flex-mobile-apps-with-flash-builder-for-php%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>As you might have heard, we released earlier this week Flash Builder and Flex 4.5. Part of this release is a new product called Flash Builder for PHP 4.5. This is something you should make sure you try if you are a PHP and Flash/Flex developer.</p>
<p>So what is Flash Builder for PHP? This product will install Flash Builder 4.5 with Zend Studio 8.1 as a plugin plus some additional plugins that integrate these two products. Using this IDE you can create mixed projects (Flex and PHP both for desktop and mobile devices) and you can streamline testing, deploying, debugging, and consuming PHP services via Flex remoting (with the help of Zend Framework).</p>
<p>Instead of writing a pretty long article, I decide to shoot a video tutorial on how you can create a Flex mobile app that uses a PHP service. This tutorial will walk you through:</p>
<ul>
<li>Using the new project type Flex Mobile and PHP</li>
<li>Creating a mobile application that has two views/screens. I will explain how to use the ViewNavigator and View classes to control your application state</li>
<li>Consuming a PHP service from a Flex mobile app using remoting</li>
<li>Testing and debugging the code (Flex and PHP) on the desktop simulator and physical device</li>
</ul>
<p>I hope you will enjoy this. If you want to download the files used for this tutorial, click <a href="http://corlan.org/downloads/flex-php-mobile.zip" target="_blank">here</a> (unzip the file and you will get the Flex project you can import it and the PHP files plus the database dump).</p>
<p><object width="400" height="220"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=23318739&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="220" src="http://vimeo.com/moogaloop.swf?clip_id=23318739&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/05/05/creating-flex-mobile-apps-with-flash-builder-for-php/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Mobile Development: scaling content depending on the screen resolution</title>
		<link>http://corlan.org/2011/04/28/mobile-development-scaling-content-depending-on-the-screen-resolution/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mobile-development-scaling-content-depending-on-the-screen-resolution</link>
		<comments>http://corlan.org/2011/04/28/mobile-development-scaling-content-depending-on-the-screen-resolution/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 11:39:46 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2817</guid>
		<description><![CDATA[
			
				
			
		
The Flex framework offers a number of methods to adjust the size of the application UI depending on the device screen resolution and density. For example, you can set the applicationDPI attribute or you can use different CSS files.
In this post I will show you how you can scale or adapt the application UI at [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/04/28/mobile-development-scaling-content-depending-on-the-screen-resolution/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F04%2F28%2Fmobile-development-scaling-content-depending-on-the-screen-resolution%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F04%2F28%2Fmobile-development-scaling-content-depending-on-the-screen-resolution%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The Flex framework offers a number of methods to adjust the size of the application UI depending on the device screen resolution and density. For example, you can set the applicationDPI attribute or you can use different CSS files.</p>
<p>In this post I will show you how you can scale or adapt the application UI at runtime using the Capabilities API. But first, why would you want to change the size of the application UI? Consider these two pictures.</p>
<p>Nexus One:</p>
<p style="text-align: center;"><img title="phone1" src="http://corlan.org/wp-content/uploads/2011/04/phone1.png" alt="" width="300" height="500" /></p>
<p>Samsung Galaxy Tab:</p>
<p style="text-align: center;"><img class="aligncenter" title="tab1" src="http://corlan.org/wp-content/uploads/2011/04/tab1.png" alt="" width="300" height="512" /></p>
<p>The first one is a screen capture taken on a Nexus One phone and the second is taken on a Samsung Galaxy Tab. Obviously, the Samsung Galaxy Tab has a higher screen resolution (600 X 1024) compared to the Nexus One (480 x 800). So, if you don&#8217;t make any adjustments to your UI, everything will be smaller on the bigger screen (as you can see from these pictures).</p>
<p>Sometimes, this is not a problem. In other situations, you might want to increase the size for some parts of your design due to aesthetic or usability reasons, or maybe both.</p>
<h2>Using scaling to adjust the content size</h2>
<p>When I worked on the <a href="https://market.android.com/details?id=air.org.corlan.aTabSplitter2&amp;feature=search_result" target="_blank">aTabSplitter</a> application, the first thing I did regarding the UI was to make sure that it wouldl fit nicely on a screen with a resolution of 400 x 800. By using Flex containers (VGroup, TileGroup, and HGroup) and playing with a mix of absolute and relative sizes I was able to easily create a &#8220;liquid&#8221; design. For example the keyboard is designed to take up about 320 pixels x 320 pixels. The TextArea at the top is set to fill in all the available space. Why did I choose this resolution? By looking at various Android devices I felt that this is the smallest resolution. Here is the code:</p>
<div id="snipplr_embed_52753" class="snipplr_embed"><a href="http://snipplr.com/view/52753/flex-keyboard/">Code snippet &#8211; Flex Keyboard</a> on Snipplr</div>
<p><script src="http://snipplr.com/js/embed.js" type="text/javascript"></script><script src="http://snipplr.com/json/52753" type="text/javascript"></script></p>
<p>For the aTabSplitter application I wanted to increase the size of the virtual keyboard when the application runs on devices with a screen resolution higher than 480 x 800. And the simplest solution is to use the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html" target="_blank">Capabilities API</a>. When you run your application on a device, Capabilities.screenResolutionX gives you the horizontal resolution. If you want to check for the screen density, you can use Capabilities.screenDPI.</p>
<p>Back to the code, I set an ID to the HGroup that holds the buttons and then I registered a listener for the creationComplete event on the view. Using this listener I can check for the screen resolution and if needed I can change the size of the HGroup using its scaleX and scaleY properties. When the container scale is changed, all the contained components are scaled too. Thus everything is kept in place, nicely aligned.</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
 xmlns:s="library://ns.adobe.com/flex/spark"
 title="HomeView" creationComplete="layoutButtons()"&gt;
&lt;fx:Script&gt;
&lt;![CDATA[

private function layoutButtons():void {
  if (Capabilities.screenResolutionX == 600) {
     buttonsHolder.scaleX = buttonsHolder.scaleY = Capabilities.screenResolutionX / 450;
   }
}
]]&gt;
&lt;/fx:Script&gt;

[...]

&lt;s:HGroup id="buttonsHolder" gap="5"&gt;
[...]
&lt;/s:HGroup&gt;</pre>
<p>And here is how the keyboard looks when I run the code on a Samsung Galaxy Tab (compare to the previous screenshot taken on the same device):</p>
<p><img class="aligncenter size-full wp-image-2825" title="tab2" src="http://corlan.org/wp-content/uploads/2011/04/tab2.png" alt="" width="300" height="512" /></p>
<p>Of course, you can apply scale in the other direction &#8211; decreasing the size of a component.</p>
<h2>Conclusions</h2>
<p>This is a pretty simple trick yo can use to adjust your content to different screen sizes. In the next post I will show you how you can adapt the content to screen orientation changes &#8211; device held in portrait or landscape mode.</p>
<p>You can download the project code from <a href="https://github.com/mcorlan/ScalingExample" target="_blank">here</a> (you&#8217;ll need Flash Builder 4.5 and Flex 4.5 to run and compile the project).</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/04/28/mobile-development-scaling-content-depending-on-the-screen-resolution/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adobe AIR 2.7 Beta 1 is on Labs</title>
		<link>http://corlan.org/2011/04/01/adobe-air-2-7-beta-1-is-on-labs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adobe-air-2-7-beta-1-is-on-labs</link>
		<comments>http://corlan.org/2011/04/01/adobe-air-2-7-beta-1-is-on-labs/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 08:02:27 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2771</guid>
		<description><![CDATA[
			
				
			
		
We just released the first beta of Adobe AIR 2.7 on Adobe Labs. You can get the bits from here. What&#8217;s new with this release?
First, this beta is available just for desktops for now. Second, the main features are:

Acoustic Echo Cancellation -  you can create now high  quality collaborative or chat apps that deliver [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/04/01/adobe-air-2-7-beta-1-is-on-labs/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F04%2F01%2Fadobe-air-2-7-beta-1-is-on-labs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F04%2F01%2Fadobe-air-2-7-beta-1-is-on-labs%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We just released the first beta of Adobe AIR 2.7 on Adobe Labs. You can get the bits from <a href="http://labs.adobe.com/technologies/flashplatformruntimes/air2-7/" target="_blank">here</a>. What&#8217;s new with this release?</p>
<p>First, this beta is available just for desktops for now. Second, the main features are:</p>
<ul>
<li>Acoustic Echo Cancellation -  you can create now high  quality collaborative or chat apps that deliver excellent sound quality  without a headset. Now, Flash Player 10.3 supports acoustic echo  cancellation, noise suppression, voice activity detection, and automatic  compensation for various mic input levels.</li>
<li>Enhanced HTMLLoader API &#8211; developers have more control on how clickable links behave in HTMLLoader.</li>
<li>Media Measurement &#8211; this feature enables companies to understand how  their videos are  distributed and consumed and to collect this data in  real-time. There is  a new set of open APIs that can be used to  implement video analytics.</li>
</ul>
<p><img class="alignnone size-full wp-image-1389" title="air2.png" src="http://corlan.org/wp-content/uploads/2009/11/air2.png" alt="" width="149" height="150" /></p>
<p>Some of these features have already made their first appearance in the Flash Player 10.3 beta released a couple of weeks ago. Now, they are integrated into Adobe AIR as well. The final version should come not later than Q2 2011.</p>
<p>Now go and download the bits :)</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/04/01/adobe-air-2-7-beta-1-is-on-labs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating PlayBook apps with Flex and QNX UI Components</title>
		<link>http://corlan.org/2011/03/28/creating-playbook-apps-with-flex-and-qnx-ui-components/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-playbook-apps-with-flex-and-qnx-ui-components</link>
		<comments>http://corlan.org/2011/03/28/creating-playbook-apps-with-flex-and-qnx-ui-components/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 10:32:41 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PlayBook]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2762</guid>
		<description><![CDATA[
			
				
			
		
I got some requests about how to use both Flex and QNX UI components for building PlayBook apps. In this post I will show you how to do it.
Here are the basic steps.
1. Create a Flex mobile project. Make sure that you enable the project for BlackBerry Tablet OS development.

2. Edit project properties to include [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/03/28/creating-playbook-apps-with-flex-and-qnx-ui-components/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F28%2Fcreating-playbook-apps-with-flex-and-qnx-ui-components%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F28%2Fcreating-playbook-apps-with-flex-and-qnx-ui-components%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I got some requests about how to use both Flex and QNX UI components for building PlayBook apps. In this post I will show you how to do it.</p>
<p>Here are the basic steps.</p>
<p>1. Create a Flex mobile project. Make sure that you enable the project for BlackBerry Tablet OS development.</p>
<p><img class="alignnone size-medium wp-image-2764" title="fqnx-1" src="http://corlan.org/wp-content/uploads/2011/03/fqnx-1-300x286.png" alt="" width="300" height="286" /></p>
<p>2. Edit project properties to include the QNX libraries in the project build path (right-click on the project name &gt; Properties). Select BlackBerry Tablet OS section and then select the Include BlackBerry Tablet OS Libraries in Build Path option.</p>
<p><img class="alignnone size-full wp-image-2765" title="fqnx-2" src="http://corlan.org/wp-content/uploads/2011/03/fqnx-2.png" alt="" width="600" height="368" /></p>
<p>Once you apply these changes your project should be ready for QNX components. Of course you have to add QNX components using ActionScript code; you can&#8217;t use QNX components as MXML tags.</p>
<p>You have to remember that the QNX UI components don&#8217;t inherit or extend the Flex base UI components. And because of this you can&#8217;t add them, for example, directly to a View Flex class using view.addElement(QNX-UI-component); instead you can use an instance of Flex UIComponent as a wrapper. Here is a code snippet that illustrates this technique:</p>
<div id="snipplr_embed_51209" class="snipplr_embed"><a href="http://snipplr.com/view/51209/playbook-development-flex-and-qnx-ui-component-example/">Code snippet &#8211; PlayBook development: Flex and QNX UI component example</a> on Snipplr</div>
<p><script src="http://snipplr.com/js/embed.js" type="text/javascript"></script><script src="http://snipplr.com/json/51209" type="text/javascript"></script></p>
<p>Here is screencast that walks you through the setup and shows a sample app:</p>
<p><object width="400" height="220"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=21586815&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="220" src="http://vimeo.com/moogaloop.swf?clip_id=21586815&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<h2>Download</h2>
<p>You can download the project code from <a href="https://github.com/mcorlan/FlexAndQNX">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/03/28/creating-playbook-apps-with-flex-and-qnx-ui-components/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Conqu &#8211; one of the coolest Android apps outhere</title>
		<link>http://corlan.org/2011/03/25/conqu-one-of-the-coolest-android-apps-outhere/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=conqu-one-of-the-coolest-android-apps-outhere</link>
		<comments>http://corlan.org/2011/03/25/conqu-one-of-the-coolest-android-apps-outhere/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 10:06:21 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[PlayBook]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2755</guid>
		<description><![CDATA[
			
				
			
		
Yesterday, fellow evangelist, Terry Ryan, showed me  a tablet app for Android called Conqu. After I installed and played with it for about 5 minutes, I said: &#8220;Wow! Mate, this is the coolest app for Android tablets ever!&#8221;.
The application helps you to &#8220;Get the things done&#8221; &#8211; by managing tasks. Here is a video and [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/03/25/conqu-one-of-the-coolest-android-apps-outhere/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F25%2Fconqu-one-of-the-coolest-android-apps-outhere%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F25%2Fconqu-one-of-the-coolest-android-apps-outhere%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Yesterday, fellow evangelist, <a href="http://www.terrenceryan.com/blog/" target="_blank">Terry Ryan</a>, showed me  a tablet app for Android called Conqu. After I installed and played with it for about 5 minutes, I said: &#8220;Wow! Mate, this is the coolest app for Android tablets ever!&#8221;.</p>
<p>The application helps you to &#8220;Get the things done&#8221; &#8211; by managing tasks. Here is a video and screenshots:</p>
<p><object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/QKUPDgBvkRI?fs=1&amp;hl=en_US&amp;rel=0" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="640" height="390" src="http://www.youtube.com/v/QKUPDgBvkRI?fs=1&amp;hl=en_US&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://corlan.org/wp-content/uploads/2011/03/conqu-1.png"><img class="alignnone size-medium wp-image-2757" style="border: 0pt none;" title="conqu-1" src="http://corlan.org/wp-content/uploads/2011/03/conqu-1-300x168.png" alt="" width="300" height="168" /></a> <a href="http://corlan.org/wp-content/uploads/2011/03/conqu-2.png"><img class="alignnone size-medium wp-image-2758" style="border: 0pt none;" title="conqu-2" src="http://corlan.org/wp-content/uploads/2011/03/conqu-2-300x168.png" alt="" width="300" height="168" /></a></p>
<p>And by the way, this application is built using Flex 4.5 (&#8220;Hero&#8221;) and uses Adobe AIR for Android as a runtime. Now this is something pretty cool. Well done guys!!!</p>
<p>Because they use the Flash Plaform, it isn&#8217;t that hard to target other Flash supported devices such as: PlayBook, desktops, or iOS. In fact if you take a look at their roadmap, this is exactly what they are up to.</p>
<p>I really like the fact that they work on a feature that allows synchronization between devices over the cloud. This will facilitate team work and make this app an interesting and appealing choice for small/medium business.</p>
<h2>Getting the App</h2>
<p>You can install the application from <a href="https://market.android.com/details?id=air.com.conqu" target="_blank">here</a> (for now there is only the tablet version) and <a href="http://conqu.com/" target="_blank">here</a> you can check the roadmap and features.</p>
<p>Congratulations to the <a href="http://www.asfusion.com/" target="_blank">people</a> behind this project. I&#8217;m looking forward to testing their desktop/PlayBook/iPad versions and hope to meet them in person. I&#8217;m really curious to talk  about their experience building this app.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/03/25/conqu-one-of-the-coolest-android-apps-outhere/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Animating QNX components in PlayBook apps</title>
		<link>http://corlan.org/2011/03/23/animating-onx-components-in-playbook-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=animating-onx-components-in-playbook-apps</link>
		<comments>http://corlan.org/2011/03/23/animating-onx-components-in-playbook-apps/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 13:24:31 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2745</guid>
		<description><![CDATA[
			
				
			
		
In this post I want to show you how you can use animations/transitions for QNX components to create a better user experience. User experience designers use transitions when they want to highlight or focus user attention to a specific part of the application.
For example, when you add a new component to the screen as a [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/03/23/animating-onx-components-in-playbook-apps/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F23%2Fanimating-onx-components-in-playbook-apps%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F23%2Fanimating-onx-components-in-playbook-apps%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post I want to show you how you can use animations/transitions for QNX components to create a better user experience. User experience designers use transitions when they want to highlight or focus user attention to a specific part of the application.</p>
<p>For example, when you add a new component to the screen as a result of user interaction you can do it in two ways:</p>
<ul>
<li>just add the new component to the display</li>
<li>create a transition or animation that gradually introduces the new component to the display</li>
</ul>
<p>I think it is easiest to understand the subtle difference between the two approaches by seeing this screencast:</p>
<p><object width="400" height="220"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=21389555&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="220" src="http://vimeo.com/moogaloop.swf?clip_id=21389555&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>In my application I used the tweener library for animating the container that holds the list. This ActionScript library is one of the most used libraries out there for this task. You can grab it from <a href="http://code.google.com/p/tweener/" target="_blank">here</a>.</p>
<p>LATER EDIT: QNX is using Tweener internally. So you don&#8217;t have to add this library, is already part of the SDK (qnx-screen.swc). Thanks to Julian Dolce of RIM for pointing this out.</p>
<p>Once you get the SWC file, you have to add it to your ActionScript mobile project. The easiest way, especially if you plan to use more libraries, is to add a folder to the ActionScript build path and configure Flash Builder so that every SWC file you drop in this folder will be added to the project.</p>
<p>The steps are:</p>
<ul>
<li>Create a folder in your project. I created a folder called libs for my project.</li>
<li>Copy the tweener.swc file into this folder<br />
<img class="aligncenter size-full wp-image-2748" title="tweener1" src="http://corlan.org/wp-content/uploads/2011/03/tweener1.png" alt="" width="231" height="279" /></li>
<li>Open the project properties page (right-click the project name and select Properties) and select the ActionScript build path. Then click the Add SWC Folder button and select the folder you created earlier. Click the OK button and you are good to go.</li>
</ul>
<p><img class="aligncenter size-full wp-image-2749" title="tweener2" src="http://corlan.org/wp-content/uploads/2011/03/tweener2-e1300886069531.png" alt="" width="600" height="293" /></p>
<p>How do you use this library? Actually it is pretty simple. There is a static method on the Tweener class called addTween(). You use this method to specify the display object you want to animate, the properties you want to animate (could be the x, y, size, etc), and the animation duration. You can also specify a number of functions to be called for example when the animation is completed or for each step of the animation.</p>
<p>Here is the code for animating the list in the screen:</p>
<pre>// rightDock is the container that holds the list
// it is docked to the right-side of the screen
Tweener.addTween(rightDock, {size : 200, time : 1, onUpdate: onUpdateTween});

private function onUpdateTween():void {
    myMain.layout();
}</pre>
<p>And this is the code for removing the list from the screen:</p>
<pre>Tweener.addTween(rightDock, {size : 1, time : 1, onUpdate: onUpdateTween,
    onComplete: onCompleteTween});

private function onCompleteTween():void {
    myMain.removeChild(rightDock);
}</pre>
<p>Why do I call myMain.layout() for each step of the animation?  This method is executed in order to reposition and redraw the components on the screen so they account for the width change of the rightDock container.</p>
<p>You can download the project source code from <a href="http://corlan.org/downloads/examples/PlayBookTilelist.zip" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/03/23/animating-onx-components-in-playbook-apps/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Extending QNX TileList: Liquid Tile List</title>
		<link>http://corlan.org/2011/03/07/extending-qnx-tilelist-liquid-tile-list/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=extending-qnx-tilelist-liquid-tile-list</link>
		<comments>http://corlan.org/2011/03/07/extending-qnx-tilelist-liquid-tile-list/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 13:06:05 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2681</guid>
		<description><![CDATA[
			
				
			
		
After I tried the available list components from QNX UI library for PlayBook development, my fist question was: how can I customize both the look and feel, and the functionality of these components? In this post, I will show you how you can extend the TileList and AlternatingCellRenderer QNX components to change the UI and [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/03/07/extending-qnx-tilelist-liquid-tile-list/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F07%2Fextending-qnx-tilelist-liquid-tile-list%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F03%2F07%2Fextending-qnx-tilelist-liquid-tile-list%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>After I tried the <a href="http://corlan.org/2011/02/01/working-with-playbook-qnx-list-components/">available</a> list components from QNX UI library for PlayBook development, my fist question was: how can I customize both the look and feel, and the functionality of these components? In this post, I will show you how you can extend the TileList and AlternatingCellRenderer QNX components to change the UI and add additional functionality.</p>
<p>By default, a <a href="http://www.blackberry.com/developers/docs/airapi/1.0.0/qnx/ui/listClasses/TileList.html" target="_blank">TileList</a> looks like this:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-2551" style="border: 0pt none;" title="list5" src="http://corlan.org/wp-content/uploads/2011/02/list5.jpg" alt="" width="300" height="201" /></p>
<p style="text-align: left;">You use the dataProvider property to set the data, and its default renderer (<a href="http://www.blackberry.com/developers/docs/airapi/1.0.0/qnx/ui/listClasses/CellRenderer.html" target="_blank">CellRenderer</a>) expects the data to be an object that has a String property called label. And this property will be used to display the text for each tile. You control can control the number of tiles by using the columnCount property, and you can set the width and the height of the tiles by using columnWidth and rowHeight properties. You use the cellPadding property to control the space between the tiles.</p>
<p style="text-align: left;">This is pretty cool. But what if you want to display more complex data? Let&#8217;s say you want to have a picture, label, and some graphic? Obviously you&#8217;ll have to extend the default renderer to do this. Here is what I have in my mind:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-2684" style="border: 0pt none;" title="tileList1" src="http://corlan.org/wp-content/uploads/2011/03/tileList1.jpg" alt="" width="456" height="303" /></p>
<p style="text-align: center;"> </p>
<p style="text-align: left;"><span id="more-2681"></span></p>
<p style="text-align: left;">Second, I wanted the TileList to be able to calculate dynamically the number of columns that can be layout, depending on three input data: the width of the TileList, the cellPadding value, and the size of a tile. So, instead of hard coding the columnCount property when creating the component, I just set the size of the tiles (columnWidth and rowHeight) and the width of the TileList and based on these the TileList will calculate how many columns can fit in the given width and sets the columnCount property accordingly. Here is an example (in the first picture the tiles size is set to 130pixels, in the second one to 250pixels):</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-2685" style="border: 0pt none;" title="tilelist2" src="http://corlan.org/wp-content/uploads/2011/03/tilelist2.jpg" alt="" width="600" height="365" /></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-2686" style="border: 0pt none;" title="tilelist3" src="http://corlan.org/wp-content/uploads/2011/03/tilelist3.jpg" alt="" width="600" height="365" /></p>
<p style="text-align: left;">This means that I have to extend the TileList component to add this behavior. But, the first step is to create a custom CellRenderer so I can display the picture, label, and gray rounded square. Luckily, fellow evangelist, Renaun Erickson, created a <a href="http://renaun.com/blog/2011/01/using-qnx-image-and-imagecache-in-list-custom-cellrenderer/" target="_blank">example</a> that was pretty close to what I needed.</p>
<h2 style="text-align: left;">Creating a custom CellRenderer for the the TileList</h2>
<p>Renaun&#8217;s example is pretty closed to what I want to achieve. The reason I needed to modify it, was that I want a different arrangement of the components and, more importantly, I want to push the width and the height of the tiles from the TileList &#8211; I don&#8217;t want to have these values hard coded in the CellRenderer class.</p>
<p>Now, let&#8217;s step back and talk about the lifecycle of a CellRenderer component. The lists components use virtualization; this means that the list will create a limited number of CellRenderer components and reuse them as you scroll down and up the list. Every time an instance of the CellRenderer is reused, the TileList component will push the new data that needs to be displayed by that cell using the data property of the CellRenderer.</p>
<p>Next, every time you change the columnWidth/rowHeight properties, the TileList will loop through all the instances of the CellRender and call the setSize() method to push the new values.</p>
<p>Knowing this it became quite clear what I need to do in order to create my custom CellRenderer: override the set data() and setSize() methods, and add the parts I needed (image, rectangle, label). Here is some of the code (for the complete code go do Download section and get the project source):</p>
<pre>public class PictureCellRenderer extends AlternatingCellRenderer {

    /**
     * Skin parts used to render the data
     */
    protected var img:Image;
    protected var lbl:Label;
    protected var bg:Sprite;
    protected var format:TextFormat;

    public function PictureCellRenderer() {
        super();
        // hide the built in label
        label.visible = false;
        createUI();
    }
    /**
     * setSize() is called everytime the tiles size are changed
     * this is where we add our method layout() to reposition/redraw
     * various parts of the cell renderer.
     */
    override public function setSize(w:Number, h:Number):void {
        super.setSize(w, h);
        //we want to draw the skin parts only when the
        //actual width/height are set
        //this method is called first for the default sizes and then for
        //for the user prefered sizes
        if (stage) {
            layout();
        }
    }
    /**
     * Updates the text and image everytime a new data is set
     * for this renderer instance.
     */
    override public function set data(value:Object):void {
        super.data = value;
        //Update the image source and text if there is valid data.
        if (value) {
            img.setImage(value.img);
            lbl.text = value.label;
        }
    }
    /**
     * Create all the cell renderer components just once
     */
    private function createUI():void {
        img = new Image();
        bg = new Sprite();
        lbl = new Label();

        //...
        //code to position the img, Sprite, and label
        //...

        addChild(img);
        addChild(bg);
        addChild(lbl);
    }
    /**
     *     Draws the rectangle used as background
     *  for the label
     */
    private function drawBg():void {
        //code to redraw the gray rounded rectangular
    }
    /**
     * Reposition/redraw the renderer parts
     * everytime the tile size is changed
     */
    private function layout():void {
        lbl.y = height - 20;
        lbl.width = width - 10;
        drawBg();
        onComplete(new Event(Event.COMPLETE));
    }
    /**
     * Resize the image once the bits were loaded
     */
    private function onComplete(e:Event):void {
        img.setSize(width - 20, height - 20);
    }
}</pre>
<p>Few notes on the code above:</p>
<ul>
<li>The components used to display the data (Image, Sprite, and Label) are created inside the createUI() method called from the constructor &#8211; they are created only once</li>
<li>When you load an image, you have to listen to the Event.COMPLETE event if you want to set width and height to something different than the size of the image</li>
<li>Every time the setSize() method is called, the layout() function is executed; thus the Image, Sprite, and Label components are repositioned or resized to use the new width and height available</li>
<li>In the constructor I turn invisible the built-in label component of parent class. I tried to reuse it instead of creating a new label but I couldn&#8217;t find a method to change it&#8217;s position nor the format. I&#8217;m not sure if this is bug or is something wrong with my approach</li>
<li>I extended the AlternatingCellRenderer instead of CellRender just to get different backgrounds for adjacent cells. The code should work as well if you extend the latter</li>
<li>The data you pass to this render must be an object that has a label property for the text and an img property for the Image URL (both must be Strings)</li>
<li>This renderer uses <a href="http://www.blackberry.com/developers/docs/airapi/1.0.0/qnx/utils/ImageCache.html" target="_blank">ImageCache</a> in order to cache the images. Depending on your application you must see how many images you should cache so you don&#8217;t use too much system memory</li>
</ul>
<h2 style="text-align: left;">Extending the TileList component to support liquid layout</h2>
<p>With the custom CellRenderer in place, more than half of the work was done &#8211; or at least this is what I thought first :). So what was left to be implemented was the ability of the TileList to decide automatically how many columns fit in the given width and every time the width of the component or width of the tiles was changed, to recalculate the number of columns and update its layout. Having this behavior incorporated in my custom TileList means that:</p>
<ul>
<li>I don&#8217;t have to do anything when the display orientation changes &#8211; the TileList will automatically change the number of columns to fit the new width and height</li>
<li>I can control the size of the tiles at runtime; for example the user can zoom in or out using a slider</li>
</ul>
<p>I had two options to get this behavior:</p>
<ul>
<li>Create a method that does all the math to determine the new columnCount</li>
<li>Or to extend the TileList component and build this behavior in the component itself</li>
</ul>
<p>I chose the second option and before explaining how I did it, here is the LiquidTileList component code:</p>
<pre>public class LiquidTileList extends TileList {
	/**
	 * if true, when changing the size of the tiles
	 * scrolls the list so the first tile from the previous
	 * state is still visible
	 */
	public var keepVisibleItem:Boolean;

	public function LiquidTileList() {
		super();
		setSkin(PictureCellRenderer);
	}
	/**
	 * Overriding the draw method to inject 
	 * our method of calculating the number of
	 * tiles that fit the screen
	 * This method is called every time the width/height
	 * is changed
	 */
	override protected function draw():void {
		var i:int;
		if (keepVisibleItem &amp;&amp; firstVisibleItem)
			i = firstVisibleItem.index;
		scrollIndexVisible(0, 0);
		calculateColumns();
		super.draw();
		if (keepVisibleItem &amp;&amp; i)
			scrollIndexVisible(i, 0);
	}
	/**
	 * Calculates the number of tiles that fit
	 * the width
	 */
        private function calculateColumns():void {
		var columnNumber:int = Math.floor( (width - (cellPadding * columnCount -1) )
                                                      / columnWidth);
		if (columnNumber != columnCount)
			columnCount = columnNumber;
	}
}</pre>
<p>In the constructor I set the PictureCellRenderer as the default skin. Next, I over wrote the draw() method. This method is called every time the width and height of the list is changed, or you change the tiles size (columnWidth, rowHeight); first I calculate the number of columns using the new sizes (by calling the calculateColumns() method) and then I call the parent draw() method to redo the layout using the new columnCount value.</p>
<p>If you wonder what&#8217;s the deal with the scrollIndexVisible() calls, well this was the hard part. I think there is a bug in the virtualization engine of the TileList because when I changed the size of the tiles, sometimes you end up with items missing or you can&#8217;t scroll anymore. So this is the only way I found to get around this issue. Second, I wanted to be keep in the view the first visible element. For example, suppose you have a large list and you scrolled a bit and then you decide to increase the size of the tiles three times. I think that the user would expect to see the the first items of the previous view. So this is why I added a public property called keepVisibleItem.</p>
<p>In my tests, the component works fine after applying the scrollIndexVisible fix. However, if you want to change the tiles size using a slider and you apply the new values live (you apply the new values listening for SliderEvent.MOVE event) then it is better to set the keepVisibleItem to false.</p>
<p>And here is a snippet of code of how you can use this custom component:</p>
<pre>peopleList = new LiquidTileList();
peopleList.keepVisibleItem = true;
peopleList.dataProvider = getPeople();
peopleList.scrollDirection = ScrollDirection.VERTICAL;
peopleList.size = 100;
peopleList.sizeUnit = SizeUnit.PERCENT;
peopleList.sizeMode = SizeMode.BOTH;
//provide a default number of columns;
//this can be override by LiquidTileList so it fill all
//the available width
peopleList.columnCount = 5;
peopleList.columnWidth = 150;
peopleList.rowHeight = 150;
peopleList.cellPadding = 5;
peopleList.selectionMode = ListSelectionMode.SINGLE;

slider = new Slider();
slider.minimum = 130; //min value
slider.maximum = 250; //max value
slider.value = 150;   //default value
slider.addEventListener(SliderEvent.END, onSliderMove);
slider.addEventListener(SliderEvent.MOVE, onSliderMove);
...
/**
 * Slider event changeing the size of the tiles
 */
private function onSliderMove(e:SliderEvent):void {
	peopleList.columnWidth = e.value;
	peopleList.rowHeight = e.value;
}</pre>
<p>And here is a screencast of this example:</p>
<p><object width="400" height="220"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=20738772&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="220" src="http://vimeo.com/moogaloop.swf?clip_id=20738772&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<h2>Download the code</h2>
<p>You can download the entire project from <a href="http://corlan.org/downloads/PlayBookTilelist.zip">here</a>. Have a look at it, and drop a comment if you find bugs or you have a better idea :)</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/03/07/extending-qnx-tilelist-liquid-tile-list/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Support for screen navigation and application session caching for QNX PlayBook apps</title>
		<link>http://corlan.org/2011/02/22/support-for-screen-navigation-and-application-session-caching-for-qnx-playbook-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=support-for-screen-navigation-and-application-session-caching-for-qnx-playbook-apps</link>
		<comments>http://corlan.org/2011/02/22/support-for-screen-navigation-and-application-session-caching-for-qnx-playbook-apps/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 12:05:18 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2621</guid>
		<description><![CDATA[
			
				
			
		
If you&#8217;ve ever worked with Flex &#8220;Hero&#8221; mobile components you probably love the way Flex &#8220;Hero&#8221; handles the screen metaphor. It provides a neat way to encapsulate the UI and business logic for each screen in a class.
On a mobile device, you need to keep in mind that an application can be closed anytime by [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/02/22/support-for-screen-navigation-and-application-session-caching-for-qnx-playbook-apps/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F22%2Fsupport-for-screen-navigation-and-application-session-caching-for-qnx-playbook-apps%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F22%2Fsupport-for-screen-navigation-and-application-session-caching-for-qnx-playbook-apps%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you&#8217;ve ever worked with Flex &#8220;Hero&#8221; mobile components you probably love the way Flex &#8220;Hero&#8221; handles the screen metaphor. It provides a neat way to encapsulate the UI and business logic for each screen in a class.</p>
<p>On a mobile device, you need to keep in mind that an application can be closed anytime by the operating system. This could be because the OS is trying to free some resources or maybe the battery just died. In either case when the user reopens the app, he expects to see the last screen he was working on as well as any data that was entered. Again, with Flex &#8220;Hero&#8221; mobile applications all you have to do is to set the sessionCachingEnabled to true and assign the information you want to be persisted to the data property of your views.</p>
<p>This is great; however if you develop applications for PlayBook using the QNX libraries (the native Tablet OS SDK for Adobe AIR) you can&#8217;t use Flex &#8220;Hero&#8221; and, as a result, you don&#8217;t have support for the screen metaphor. I wanted this kind of support for an application I plan to build for PlayBook.</p>
<p>Lucky for me, I didn&#8217;t have to start from scratch because my fellow evangelist, Piotr Walczyszyn, has already created a small <a href="http://www.riaspace.com/2011/02/as3viewnavigator-viewnavigator-for-as3flash-projects/" target="_blank">library</a> that does nice tweening between two screens and implements the methods for adding a screen or popping one. So, I took his library and I modified it a little bit. Why did I modify the library? First, I wanted to have session caching capabilities and to be able to push data from one screen to another in the same manner as a Flex &#8220;Hero&#8221; mobile application. And second, I wanted to make it easier to work with QNX UI components (the original library supported generic ActionScript mobile projects).</p>
<p><span id="more-2621"></span></p>
<h2>Basic usage</h2>
<p>To use this library you have to add the library code to your project and create classes that extends org.corlan.asviews.BaseView for each view/screen you need for your application.</p>
<p>In the main application file you create an instance of the org.corlan.asviews.ViewNavigator class. You use its pushView() method to define the first view/screen and to move to new screens. You use the popView() method to move back to the previous screen/view or popToFirstView() to jump directly to the first view/screen.</p>
<p>If you need session caching for your app there are two things you have to do. First, when you create the ViewNavigator instance, you set the second argument to true. Second, you register the ViewNavigator.prepareForClosing() method as an event listener for the application Close event:</p>
<pre><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Monaco} span.s1 {color: #0659fc} --> NativeApplication.nativeApplication.addEventListener(
     Event.EXITING, navigator.prepareForClosing, false, 0, true);</pre>
<p>See this screencast for more information or read on the next section.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="220" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=20238266&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="220" src="http://vimeo.com/moogaloop.swf?clip_id=20238266&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2>Downloading and using the library</h2>
<p>You can download the sample project from <a href="http://corlan.org/downloads/ASViews.zip" target="_blank">here</a> and the library from <a href="http://corlan.org/downloads/as3viewnavigator.fxpl" target="_blank">here</a>.</p>
<p>It is quite simple to use it once you set up the library project and add it as a dependency to your ActionScript mobile project. Here are the steps:</p>
<ol>
<li>Download the as3viewnavigator library from <a href="http://corlan.org/downloads/as3viewnavigator.fxpl" target="_blank">here</a> and import it in Flash Builder Burrito. Then open the project properties dialig box, select Flex Library Build Path, and make sure that qnx-screen.swc file is added to the build path (you can find this swc in the sdks/blackberry-tablet-sdk-0.9.2/frameworks/libs/qnx-screen/ folder inside the Flash Builder Burrito installation folder).<br />
<a href="http://corlan.org/wp-content/uploads/2011/02/views-2.jpg"><img class="alignnone size-medium wp-image-2624" style="border: 0pt none;" title="views-2" src="http://corlan.org/wp-content/uploads/2011/02/views-2-300x170.jpg" alt="" width="300" height="170" /></a></li>
<li>Create a new ActionScript Mobile Project for PlayBook development. Then open the project properties dialog box, select ActionScript Build Path, click the Add Project, and choose the as3viewnavigator project.<br />
<img class="alignnone size-medium wp-image-2623" title="views-1" src="http://corlan.org/wp-content/uploads/2011/02/views-1-300x225.jpg" alt="" width="300" height="225" /></li>
</ol>
<p>Now you are ready to use it. The basic steps are:</p>
<ul>
<li>For each screen you want, create a class that extends the org.corlan.asviews.BaseView (this class extends the QNX Container class and implements the org.corlan.asviews.IView interface). When you create the screen classes you have to keep in mind that you need to override two methods from the BaseView class:
<ul>
<li>createUI() &#8211; this is where you create the UI for the screen using the components from the QNX libraries or your own components.</li>
<li>applyData() &#8211; you use this method to populate the UI with the data saved in the previous session. This method is called automatically once your screen class is added to the stage.</li>
</ul>
</li>
<li>Store whatever data you want to be persisted in the data property of your screen classes</li>
<li>In the main application file, you instantiate the org.corlan.asviews.ViewNavigator class and push the first screen. Also, you need to register the ViewNavigator.prepareForClosing method to listen for application Close events.</li>
<li>In any screen that you need to push a new screen (or move back) you just call the navigator.pushView(View-Class-Name, data), navigator.popView(), or navigator.popToFirstView() methods</li>
</ul>
<p>Now let&#8217;s see some snippets of code to better understand the workflow. First here is the code for the main application file:</p>
<pre>[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
public class ASViews extends Sprite
{

	private var navigator:ViewNavigator;

	public function ASViews()
	{
		stage.align = StageAlign.TOP_LEFT;
		stage.scaleMode = StageScaleMode.NO_SCALE;

		// Creating an instance of ViewNavigator
		// if second argument is set to true then the history
		// is persisted between sessions
		navigator = new ViewNavigator(this, true);
		// Pushing first view to the navigator
		navigator.pushView(HomeScreen);
		//listening for application closing event
		//in order to save the history
		NativeApplication.nativeApplication.addEventListener(Event.EXITING,
				navigator.prepareForClosing, false, 0, true)
	}

}</pre>
<p>And here is the code for the first screen, HomeScreen (in the onItemSelected() method I push the second screen passing along the current selected item from the list to be used in the second screen):</p>
<pre>public class HomeScreen extends BaseView
{

	private var list:List;

	public function HomeScreen(s:Number=100, su:String="percent")
	{
		super(s, su);
	}

	override protected function createUI():void {
		flow = ContainerFlow.HORIZONTAL;

		var optionsArr:Array = [
			{label: "Flash Gordon - The fastest man on earth!"},
			{label: "Superman - This guy could use some fashion advisory!"},
			{label: "Batman - The coolest bat in town!"},
			{label: "Green Lantern - Not a friend of Green Hornet"},
			{label: "Green Hornet - Can be tricked with some good coffee!"}
		];

		//list with the options
		list = new List();
		list.containment = Containment.BACKGROUND;
		list.dataProvider = new DataProvider(optionsArr);
		list.selectionMode = ListSelectionMode.SINGLE;
		list.addEventListener(ListEvent.ITEM_CLICKED,
                        onItemSelected, false, 0, true);

		addChild(list);
	}

	private function onItemSelected(e:ListEvent):void {
		if (!data)
			data = new Object();
		data["selectedItem"] = list.selectedIndex;
		navigator.pushView(SecondScreen, list.selectedItem);
	}

	override protected function applyData():void {
		trace("applyData() HomeScreen");
		if (!data)
			return;
		if (data["selectedItem"])
			list.selectedIndex = data["selectedItem"];
	}
}</pre>
<p>This is the code for the second screen, SecondScreen (in the onGoBack() method I call the navigator.popView() method to move back to the previous screen):</p>
<pre>public class SecondScreen extends BaseView
{

private var lbl:Label;

public function SecondScreen(s:Number=100, su:String="percent")
{
	super(s, su);
}

override protected function createUI():void
{
	flow = ContainerFlow.VERTICAL;

	var topContainer:Container = new Container();
	//			topContainer.margins = Vector.([1,1,1,1]);
	//			topContainer.debugColor = 0x33FF33;
	topContainer.size = 50;
	topContainer.sizeUnit = SizeUnit.PIXELS;
	topContainer.flow = ContainerFlow.HORIZONTAL;
	topContainer.containment = Containment.DOCK_TOP;

	var left:Container = new Container();
	//			left.margins = Vector.([1,1,1,1]);
	//			left.debugColor = 0x33FF33;
	left.size = 70;
	left.sizeUnit = SizeUnit.PERCENT;
	left.flow = ContainerFlow.VERTICAL;
	left.align = ContainerAlign.NEAR;

	var right:Container = new Container();
	//			right.margins = Vector.([1,1,1,1]);
	//			right.debugColor = 0x33FF33;
	right.size = 30;
	right.sizeUnit = SizeUnit.PERCENT;
	right.flow = ContainerFlow.VERTICAL;
	right.align = ContainerAlign.FAR;

	lbl = new Label();
	lbl.text = "";
	lbl.autoSize = TextFieldAutoSize.CENTER;

	var backBtn:BackButton = new BackButton();
	backBtn.label = "Go Back";
	backBtn.addEventListener(MouseEvent.CLICK, onGoBack, false, 0, true);

	left.addChild(new Spacer(50));
	left.addChild(lbl);
	right.addChild(new Spacer(1));
	right.addChild(backBtn);

	topContainer.addChild(left);
	topContainer.addChild(right);
	addChild(topContainer);
}

private function onGoBack(e:MouseEvent):void {
	navigator.popView();
}

override protected function applyData():void {
	trace("applyData() SecondScreen");
	if (!data)
		return;
	lbl.text = data["label"];
}</pre>
<p>In case you&#8217;re wondering how do I save the data, I&#8217;m using SharedObject and I persist an array representing the current screen stack (the screen class name and the data object for each instance).</p>
<h2>Conclusions</h2>
<p>Although I intend to use this library in my projects, I haven&#8217;t tested it extensively ywt. This means you may find bugs. If so, please let me know. Furthermore, there is a big difference in how this library manages the views compared to how Flex does: Flex&#8217;s ViewNavigator destroys by default a view when removing it. This library doesn&#8217;t. So, if you have lots of views with lots of components you might end up using a lot of memory. For such a use case it should be modified to mimic the Flex approach.</p>
<p>If you&#8217;ve started to create apps for PlayBook I&#8217;m eager to learn how you manage the screens. So, please talk back :D!</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/02/22/support-for-screen-navigation-and-application-session-caching-for-qnx-playbook-apps/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Working with PlayBook QNX UI components</title>
		<link>http://corlan.org/2011/02/17/working-with-playbook-qnx-ui-components/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-playbook-qnx-ui-components</link>
		<comments>http://corlan.org/2011/02/17/working-with-playbook-qnx-ui-components/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 17:03:28 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2575</guid>
		<description><![CDATA[
			
				
			
		
In a previous post I talked about all sorts of lists available to developers when using the BlackBerry Tablet OS SDK for Adobe AIR. In this article I will focus on the remaining UI controls. I have an idea for a PlayBook application and before writing a single line of code I wanted to make [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/02/17/working-with-playbook-qnx-ui-components/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F17%2Fworking-with-playbook-qnx-ui-components%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F17%2Fworking-with-playbook-qnx-ui-components%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In a previous <a href="http://corlan.org/2011/02/01/working-with-playbook-qnx-list-components/" target="_blank">post</a> I talked about all sorts of lists available to developers when using the BlackBerry Tablet OS SDK for Adobe AIR. In this article I will focus on the remaining UI controls. I have an idea for a PlayBook application and before writing a single line of code I wanted to make sure that I understood all the UI components that are available as part of the BlackBerry SDK. By the way, in case you didn&#8217;t know, RIM offers a free PlayBook device to any developer who gets his application on<a href="http://us.blackberry.com/developers/tablet/playbook_offer.jsp" target="_blank"> BlackBerry App World</a>. I thought I&#8217;d share with you the results of my research.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/02/uiqnx.jpg"><img class="alignnone size-full wp-image-2609" title="uiqnx" src="http://corlan.org/wp-content/uploads/2011/02/uiqnx.jpg" alt="" width="600" height="354" /></a></p>
<p>I won&#8217;t cover how to skin these components. This is a topic for another blog post. In the meantime you can read Ryan&#8217;s posts on skinning ( <a href="http://blog.digitalbackcountry.com/2010/12/skinning-playbook-components/" target="_blank">buttons/text fields</a> and <a href="http://blog.digitalbackcountry.com/2011/01/creating-custom-list-skins-for-the-blackberry-playbook/" target="_blank">lists</a>) and Renaun&#8217;s <a href="http://http://renaun.com/blog/2011/02/playbook-sample-actionscript-application-using-qnx-components/" target="_blank">post</a>.</p>
<p><span id="more-2575"></span></p>
<h2>Buttons</h2>
<p>There are seven buttons in the package <em>qnx.ui.buttons</em>. If you want to do something when a buttons is clicked you have to register an event listener for <em>MouseEvent.CLICK, </em> <em>Event.CHANGE</em> (only for <em>SegmentedControl</em>), or <em>Event.SELECT </em>(for <em>ToggleSwitch</em>); for example:</p>
<pre>myButton.addEventListener(MouseEvent.CLICK, doSomethingOnClick);

private function doSomethingOnClick(e:MouseEvent):void {
    //do something
}</pre>
<p><em>LabelButton</em> and <em>IconButton</em>, as the names suggest, enable you to create buttons with either text labels or icons. Both these buttons extend the <em>Button</em> class (if you use the <em>Button</em> class  itself you will get a button without a label or icon). You can enable toggle by setting the the property with the same name to true. This will give you a button, that once clicked, stays selected and then is unselected when you click it again. In the image below you can see these two buttons with toggle on in the selected and unselected state.</p>
<p><img class="alignnone size-full wp-image-2579" title="buttons-1" src="http://corlan.org/wp-content/uploads/2011/02/buttons-1.jpg" alt="" width="391" height="170" /></p>
<p>You can use a <em>flash.Text.TextFormat</em> object to change the label settings for a <em>LabelButton</em>. You set the image to be used by the <em>IconButton</em> by calling the <em>setIcon()</em> method and passing the path to the image to be used or a Bitmap/BitmapData instance. Here is the code used for rendering the example above:</p>
<pre>var format:TextFormat = new TextFormat();
format.font = "BBAlpha Sans";
format.size = 22;
format.color = 0x990000;
format.align = TextFormatAlign.CENTER;

var btn:LabelButton = new LabelButton();
btn.size = 50;
btn.sizeMode = SizeUnit.PIXELS;
btn.label = "Label Button";
btn.toggle = true;
btn.setTextFormatForState(format,SkinStates.DISABLED);
btn.setTextFormatForState(format,SkinStates.UP);
btn.setTextFormatForState(format,SkinStates.DOWN);
btn.setTextFormatForState(format,SkinStates.SELECTED);
btn.setTextFormatForState(format,SkinStates.DISABLED_SELECTED);
container.addChild(btn);

var btn2:IconButton = new IconButton();
btn2.size = 100;
btn2.sizeMode = SizeUnit.PIXELS;
btn2.setIcon("assets/icon.png");
btn2.toggle = true;
container.addChild(btn2);</pre>
<p><em>BackButton</em> extends the LabelButton and you can set the label if you want (the default label is Back). It also has an arrow icon to the left of the button. As in the case of <em>LabelButton</em> you can use a <em>TextFormat</em> object and play with the <em>toggle</em> property.</p>
<p><img class="alignnone size-full wp-image-2582" title="buttons-2" src="http://corlan.org/wp-content/uploads/2011/02/buttons-2.jpg" alt="" width="137" height="68" /></p>
<pre>var btn3:BackButton = new BackButton();
btn3.label = "Go Back";
container.addChild(btn3);</pre>
<p><em>CheckBox</em> extends <em>LabelButton</em> too and has the toggle property set to true (you can&#8217;t change this one). However, you can control where to display the text relative to the check mark by using the <em>labelPlacement</em> property. Using the <em>labelPadding</em> property you can set the space between the label and icon. And of course <em>TextFormat</em> can be used to customize the label look. You have to pay attention to the <em>width</em> property if you don&#8217;t want to have the label cropped.</p>
<p><img class="alignnone size-full wp-image-2584" title="button-3" src="http://corlan.org/wp-content/uploads/2011/02/button-3.jpg" alt="" width="167" height="46" /></p>
<pre>var cb:CheckBox = new CheckBox();
cb.label ="Select Me";
cb.width = 150;
cb.labelPlacement = LabelPlacement.RIGHT;
cb.labelPadding = 30;
container.addChild(cb);</pre>
<p>The last component that extends the <em>LabelButton</em> is <em>RadioButton</em>. You use this component to force the user make a single selection from a group of at least two radio buttons. You can use TextFormat to customize the look of the label. You assign a radio button to a group by setting the same string to the <em>groupname</em> property. If you want to have one option preselected, you set the <em>selected</em> property to true.</p>
<p><img class="alignnone size-full wp-image-2586" title="buttons-4" src="http://corlan.org/wp-content/uploads/2011/02/buttons-4.jpg" alt="" width="202" height="85" /></p>
<pre>var rb1:RadioButton = new RadioButton();
rb1.size = 30;
rb1.sizeUnit = SizeUnit.PIXELS;
rb1.groupname = "group1";
rb1.label = "Yes";
rb1.selected = true;
container.addChild(rb1);

var rb2:RadioButton = new RadioButton();
rb2.size = 30;
rb2.sizeUnit = SizeUnit.PIXELS;
rb2.groupname = "group1";
rb2.label = "No";
container.addChild(rb2);</pre>
<p><em>SegmentedControl</em> displays a series of connected radio buttons and the user can select only one of them. As with lists you use a <em>DataProvider</em> to add the labels you want. An alternative is to add labels one by one using the  <em>addItem() </em>or <em>addItemAt()</em> methods. Each label is set using an instance of <em>Object</em> with one property named <em>label</em>. You can preselect an option using the <em>selectedIndex</em> property and you listen for user selection by registering an event listener for the <em>flash.events.Event.CHANGE</em> event. You can skin this component by setting up a new skin for the background and buttons.</p>
<p><img class="alignnone size-full wp-image-2588" title="buttons-5" src="http://corlan.org/wp-content/uploads/2011/02/buttons-5.jpg" alt="" width="388" height="73" /></p>
<pre>var segData:Array= [
		{label:"&lt; 10"},
  		{label:"10-19"},
  		{label:"&gt; 20"}
	];
var seg:SegmentedControl = new SegmentedControl();
seg.dataProvider = new DataProvider(segData);
seg.selectedIndex = 1;
container.addChild(seg);</pre>
<p>The last button is the <em>ToggleSwitch</em>. This component extends the Slider component. It enables you to create a button with two labels and slider that always hides one of the two labels. To set the label from the left you use the <em>selectedLabel</em> property, and for the one on the right you use the <em>defaultLabel</em> property. You can control the default selection by setting <em>selected</em> property to true/false and you react to component changes by listening for <em>Event.SELECT</em> events. You can see in the image below the component using the default skin in the two states:</p>
<p><img class="alignnone size-full wp-image-2590" title="buttons-6" src="http://corlan.org/wp-content/uploads/2011/02/buttons-6.jpg" alt="" width="344" height="53" /></p>
<pre>var tog:ToggleSwitch = new ToggleSwitch();
tog.selectedLabel = "On";
tog.defaultLabel = "Off";
tog.selected = true;
container.addChild(tog);</pre>
<h2>Text Controls</h2>
<p>In the package <em>qnx.ui.text</em> you&#8217;ll find two UI components: <em>Label</em> and <em>TextInput</em>. You can use the Label component for displaying text (it can&#8217;t receive focus). There are a number of properties you can use for fine control over how the text will be displayed:</p>
<ul>
<li>By default a label is 100 pixels wide. If you don&#8217;t set the <em>autoSize</em> property or adjust the width, then it is quite possible you will not see the whole text. The easiest way is to use the <em>autoSize</em> property and set how the label should grow so the text will be fitted; for example: <em>label.autoSize = TextFieldAutoSize.CENTER;</em></li>
<li>If you want to set the font family name/size/type-face/color you use an instance of <em>TextFormat</em> to set these values and then you assign it to the label&#8217;s <em>format</em> property</li>
<li>You set the text you want to be displayed using either the <em>text</em> property or the <em>htmlText</em> property. After playing with the htmlText property, I found that the main benefit is that you can throw in some HTML formatted text and it will be displayed just like text &#8211; this is useful if you don&#8217;t want to see the tags.</li>
<li>When you set the <em>multiline</em> property to true, and display HTML text like this &lt;p&gt;one&lt;/p&gt;&lt;br/&gt;&lt;p&gt;two&lt;/p&gt; then you will see the text in two paragraphs with one line between them</li>
<li>The <em>selectable</em> property, when set to true, allows user to select the text</li>
<li>You can use the <em>wordWrap</em> property to allow wrapping the words so the text can be displayed without increasing the width of the label</li>
</ul>
<p>Here is a code example and its rendering:</p>
<pre>var format:TextFormat = new TextFormat();
format.font = "BBAlpha Sans";
format.bold = true;
format.size = 19;
format.color = 0x000099;

var lbl:Label = new Label();
lbl.format = format;
lbl.autoSize = TextFieldAutoSize.CENTER;
lbl.wordWrap = true;
lbl.multiline = true;
lbl.selectable = true;
lbl.htmlText =
"&lt;p&gt;&lt;strong&gt;This is a label!!!&lt;/strong&gt;&lt;/p&gt;&lt;br/&gt;&lt;p&gt;Second Paragraph&lt;/p&gt;";
container.addChild(lbl);</pre>
<p><img class="alignnone size-full wp-image-2594" title="label" src="http://corlan.org/wp-content/uploads/2011/02/label.jpg" alt="" width="286" height="114" /></p>
<p>If you want to let the user type some text or edit it, then you&#8217;ll use the <em>TextInput</em> component. This component is pretty powerful because it lets you add custom icons inside of it (on the left/right sides) and control when they are displayed. You can also control what type of the keyboard should be displayed when the text field gets the focus (the keyboard is pulled out automatically when a TextInput is selected). Just set the <em>keyboardType</em> property to one of the following values; for example: <em>KeyboardType.DEFAULT, KeyboardType.EMAIL, KeyboardType.URL, KeyboardType.PIN</em>, or <em>KeyboardType.PHONE</em>. You can customize the label displayed on the Enter key by using the <em>returnKeyType</em> property: <em>txt.returnKeyType = ReturnKeyType.GO</em>. If you want to use the text field for passwords you can set the <em>displaysAsPassword</em> property to true.</p>
<p><img class="alignnone size-full wp-image-2597" title="textInput-2" src="http://corlan.org/wp-content/uploads/2011/02/textInput-2.jpg" alt="" width="600" height="310" /></p>
<p>When you want to format the text you use a <em>TextFormat </em>object, exactly as in the case of the <em>Label</em>. By default you can have a Clear icon inside of the text field that you can use for deleting the entire text. You can control when it is displayed using the <em>clearIconMode</em> property; for example: <em>txt.clearIconMode = TextInputIconMode.ALWAYS</em>. If you want to add a custom icon to the left or right side, one way to do it is to create a transparent PNG file with the icon you want and then embed the PNG file and set the class to the <em>leftIcon</em> or <em>rightIcon</em> properties. From my tests it seems that is better to have the icon bigger rahter than smaller compared to what will be actually rendered. And you can control when it is displayed using the <em>leftIconMode</em> or <em>rightIconMode</em> properties. For example:</p>
<pre>[Embed(source="assets/arrow48x48.png")]
private var ArrowIcon:Class;
...
txt.leftIcon = new ArrowIcon();
txt.leftIconMode = TextInputIconMode.UNLESS_EDITING;</pre>
<p><img class="alignnone size-full wp-image-2598" title="textInput-1" src="http://corlan.org/wp-content/uploads/2011/02/textInput-1.jpg" alt="" width="411" height="47" /></p>
<p>Here is the code used to create the example displayed in the pictures:</p>
<pre>var format:TextFormat = new TextFormat();
format.font = "BBAlpha Sans";
format.bold = true;
format.size = 19;
format.color = 0x000099;

var txt:TextInput = new TextInput();
txt.format = format;
txt.width = 400;
txt.keyboardType = KeyboardType.PHONE;
txt.returnKeyType = ReturnKeyType.GO;
txt.clearIconMode = TextInputIconMode.ALWAYS;
txt.leftIcon = new ArrowIcon();
txt.leftIconMode = TextInputIconMode.UNLESS_EDITING;</pre>
<p>If you want to do something when the user introduces or edits the text, then you have to register an event listener for the <em>Event.CHANGE</em> event:</p>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Monaco; color: #0fa416} --><em>txt.addEventListener(Event.CHANGE, onChange);</em></p>
<p>Here are the shortcomings I found so far for the <em>TextInput</em> (as of writing this post the SDK is in beta):</p>
<ol>
<li>You can&#8217;t test it outside of the emulator without a hack &#8211; see Renaun&#8217;s <a href="http://renaun.com/blog/2011/02/workaround-for-ppschannel-error-when-running-qnx-playbook-specific-apis-on-the-desktop/#more-1200" target="_blank">post</a> on this topic. This is  because this component requires a class that is part of the RIM AIR runtime.</li>
<li>When setting the <em>autoSize</em> property to <em>TextFieldAutoSize.CENTER </em>you can&#8217;t select the field and type in it.</li>
<li>It doesn&#8217;t support multiple lines. Some people found a <a href="http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Multiline-TextInput/m-p/671331/highlight/true#M2206" target="_blank">way</a> to get around this, but I think we need official support from RIM in the form of a different component or an addition to the <em>TextInput.</em></li>
</ol>
<h2>Sliders</h2>
<p>In the package <em>qnx.ui.slider</em> you&#8217;ll find <em>Slider</em> and <em>VolumeSlider</em> components. <em>VolumeSlider</em> extends the Slider and provides a default skin suited for media applications. You can set the <em>minimum</em> and <em>maximum</em> values using the properties with the same name. You can&#8217;t set the step when moving the thumb around. You can retrieve the current value using the <em>value</em> property and keep in mind it is a <em>Number</em> and not <em>Integer</em> (so you can get 6.7, for example). If you want to have the slider&#8217;s thumb position to something other than the left side by default, you set the <em>value</em> property to what you need.</p>
<pre>var slider:Slider = new Slider();
slider.width = 300;
slider.height = 40;
slider.minimum = 1;
slider.maximum = 10;
slider.value = 5.5;
slider.addEventListener(SliderEvent.START, onDragStart);
slider.addEventListener(SliderEvent.END, onDragEnd);
slider.addEventListener(SliderEvent.MOVE, onMove);

var volume:VolumeSlider = new VolumeSlider();
volume.minimum = 0;
volume.maximum = 1;</pre>
<p>While you can set the width of the component, setting the height doesn&#8217;t change anything. You need to create skins for thumb and track if you need more customization, and use the <em>setThumbSkin()</em> and <em>setTrackSin()</em> methods to apply them.</p>
<p><img class="alignnone size-full wp-image-2600" title="slider" src="http://corlan.org/wp-content/uploads/2011/02/slider.jpg" alt="" width="346" height="175" /></p>
<p>There are three events you can listen for: <em>SliderEvent.START</em> (when the thumb starts to move), <em>SliderEvent.END</em> (when the user has finished the dragging), and <em>SliderEvent.MOVE</em> (while the thumb is moving). It seems that both these sliders can be only horizontal.</p>
<h2>Progress Bars</h2>
<p>When you want to display progress to the user you can use components available in the <em>qnx.ui.progress</em> package. The <em>ActivityIndicator</em> component lets you display visual feedback when a time-consuming operation is executing. You start the animation by calling the <em>animate(true)</em> method and stop it with <em>animate(false)</em>. You can check if the animation is running by calling the<em> isAnimating() </em>method. It should be possible to skin it by extending <em>ActivityIndicatorSkin</em>.</p>
<p><img class="alignnone size-full wp-image-2602" title="activity" src="http://corlan.org/wp-content/uploads/2011/02/activity.jpg" alt="" width="186" height="48" /></p>
<pre>var activity:ActivityIndicator = new ActivityIndicator();
activity.setSize(30, 30);
activity.animate(true);</pre>
<p>Using the <em>ProgressBar</em> and <em>PercentageBar</em> you can give a sense of progress of how much of the work has been completed and how much is remaining. You change this by setting the <em>progress</em> property to a number between 0 and 1, where 1 represents 100% of the job done. <em>PercentageBar</em> has a label as well, so the user knows exactly what the progress is &#8211; you can hide it by setting the <em>showPercent</em> property to false.</p>
<p><img class="alignnone size-full wp-image-2603" title="prog" src="http://corlan.org/wp-content/uploads/2011/02/prog.jpg" alt="" width="246" height="64" /></p>
<pre>var prog:ProgressBar = new ProgressBar();
prog.width = 200;
prog.progress = 0.3;

var per:PercentageBar = new PercentageBar();
per.width = 200;
per.progress = 0.9;</pre>
<p>Extending the skins from the <em>qnx.ui.skins.progress</em> package is the way to customize the look and feel.</p>
<h2>Image Controls</h2>
<p>In the <em>qnx.ui.display</em> you&#8217;ll find two components: <em>Image</em> and <em>TilingBackground</em>. You use the <em>Image</em> class when you want to display an image. By calling the <em>setImage()</em> method you set a local path to an image, an URL, or a <em>Bitmap</em>/<em>BitmapData</em> object. There are two events you can listen for:</p>
<ul>
<li><em>Event.COMPLETE</em> &#8211; this event is triggered once the image was loaded and ready to use</li>
<li><em>IOErrorEvent.IO_ERROR</em> &#8211; dispatched when the image can&#8217;t be loaded</li>
</ul>
<p>If you plan to scale the image (up or down) you might want to set the <em>smoothing</em> property to true. To cache the images, create a single instance of <em>ImageCache</em> and assign it to the <em>Image.cache</em> property. You can force the cache to reload an image if you need.</p>
<p>Here is an example that loads an image from the application folder:</p>
<pre>private static var imageCache:ImageCache = new ImageCache();
private static const IMAGE_PATH:String =  "assets/picture.jpg";
...
var img:Image = new Image();
img.smoothing = true;
img.cache = imageCache;
img.addEventListener(Event.COMPLETE, onComplete);
img.setImage(IMAGE_PATH);
container.addChild(img);
...
private function onComplete(e:Event):void {
    container.layout();
}</pre>
<p><img class="alignnone size-full wp-image-2604" title="image" src="http://corlan.org/wp-content/uploads/2011/02/image.jpg" alt="" width="200" height="143" /></p>
<p>Please note that in the above example I didn&#8217;t explicitly set the width and height of the image. These were set automatically to the values taken from the loaded image. If you want to set them to something different you have to do it after the image is loaded when the <em>Event.COMPLETE</em> event is thrown. Otherwise they will be overwritten.</p>
<p>When you want to create a tile from images, you use the <em>TilingBackground</em> component. You don&#8217;t have much control on how the image will be tiled (it will be tiled on both X and Y depending on how much space it is available and how large the image to be tiled is). What surprised me was the way you set the image. I was expecting to have the same options available as for <em>Image.setImage()</em>. Instead, you use the <em>bitmapData</em> property and set it to a <em>BitmapData</em> object. In the following example I&#8217;m using the <em>ImageCache.getImage()</em> API to get the <em>BitmapData</em> object loaded by the Image object and set it to the <em>bitmapData</em> property of the <em>TilingBackground</em>:</p>
<pre>tile = new TilingBackground();
tile.containment = Containment.BACKGROUND;
container.addChild(tile);
//inside the complete event handler of the Image
tile.bitmapData = imageCache.getImage(IMAGE_PATH, false);</pre>
<p><img class="alignnone size-full wp-image-2608" title="tiling" src="http://corlan.org/wp-content/uploads/2011/02/tiling2.jpg" alt="" width="600" height="414" /></p>
<h2>Dialog</h2>
<p>The QNX UI library provides a number of classes for creating a floating window on top of your application. I think that this is a useful feature, because with the real estate available on the PlayBook tablet you may want to use one of these dialogs instead of &#8220;pushing&#8221; an entirely new screen (screen metaphor approach).</p>
<p>There are five dialog boxes to choose from, and you have to remember that the appearance is controlled by the BlackBerry Tablet OS. You can control the position, size, and the type of the window:</p>
<ul>
<li>system modal &#8211; blocks the entire tablet until the window is closed &#8211; use <em>Dialog.open()</em></li>
<li>application modal &#8211; blocks the interaction only with the application &#8211; use <em>Dialog.open(IowWindow.getAirWindow().group)</em></li>
</ul>
<p>Using <em>DialogAlign</em> and the <em>align</em> property of the dialog you can specify where on the vertical axis it should be placed (it is always centered horizontally). You can add buttons and set properties to them like this:</p>
<pre>var myDialog:AlertDialog = new AlertDialog();
myDialog.addButton("Yes");
myDialog.addButton("No");
myDialog.addButton("Cancel");
myDialog.setButtonPropertyAt("enabled", false, 2);</pre>
<p>Once the user clicks one of the buttons you add to the window, if you registered an event listener on the dialog box for the <em>Event.SELECT</em> event you can determine what button was pressed:</p>
<pre>myDialog.addEventListener(Event.SELECT, alertButtonClicked);
...
private function alertButtonClicked(e:Event):void {
	trace((e.target as AlertDialog).selectedIndex)
}</pre>
<p>The life cycle for a dialog box is:</p>
<ol>
<li>You create a new instance of the dialog you want</li>
<li>You configure the content (messages, buttons, labels&#8230;) and the positioning/sizing of the dialog</li>
<li>You register an event listener for the <em>Event.SELECT</em> event</li>
<li>You call the <em>show()</em> method on the dialog to display it</li>
</ol>
<p><em>AlertDialog</em> is the simplest window. You use this window in order to display some text to the user and allow him to click on one of the buttons you add to it. You set the title and message using the properties with the same names.</p>
<p><img class="alignnone size-full wp-image-2611" title="dialog-1" src="http://corlan.org/wp-content/uploads/2011/02/dialog-1.jpg" alt="" width="600" height="398" /></p>
<p>And here is the code:</p>
<pre>var myDialog:AlertDialog = new AlertDialog();
myDialog.title = "AlertDialog";
myDialog.message = "This is an alert dialog. Do you like it?";
myDialog.addButton("Yes");
myDialog.addButton("No");
myDialog.addButton("Cancel");
myDialog.setButtonPropertyAt("enabled", false, 2);
myDialog.dialogSize = DialogSize.SIZE_MEDIUM;
myDialog.align = DialogAlign.TOP;
myDialog.addEventListener(Event.SELECT, alertButtonClicked1);
myDialog.show(IowWindow.getAirWindow().group);
...
private function alertButtonClicked1(e:Event):void {
	trace((e.target as AlertDialog).selectedIndex)
}</pre>
<p><em>LoginDialog</em> presents the user an interface for providing the information necessary for a login operation: user name, password, remember me. It extends the <em>AlertDialog</em> class so everything you can do with it applies to <em>LoginDialog</em> too. Using the <em>rememberMe</em>, <em>password</em>, and <em>username</em> properties you can retrieve the information the user introduced. You can set the text used for username/password/remember me using these properties: <em>usernameLabel</em>, <em>passwordLabel</em>, <em>passwordPrompt</em>, and <em>rememberMeLabel</em>.</p>
<p><img class="alignnone size-full wp-image-2613" title="dialog-2" src="http://corlan.org/wp-content/uploads/2011/02/dialog-2.jpg" alt="" width="422" height="328" /></p>
<pre>var login:LoginDialog = new LoginDialog();
login.title = "Login";
login.message = "Please enter your username and password:";
login.addButton("OK");
login.addButton("Cancel");
login.passwordPrompt = "password";
login.rememberMeLabel = "Remember me";
login.rememberMe = true;
login.dialogSize = DialogSize.SIZE_SMALL;
login.addEventListener(Event.SELECT, alertButtonClicked2);
login.show(IowWindow.getAirWindow().group);
...
private function alertButtonClicked2(e:Event):void {
	var login:LoginDialog = e.target as LoginDialog;
	trace(login.password); //retrieve the password
	trace(login.username); //retrieve the username
	//retrieve whather the remember me option was selected
	trace(login.rememberMe);
	trace(login.selectedIndex); //retrieve the button was clicked
}</pre>
<p><em>PasswordChangeDialog</em>, as the name suggests, is handy when you want to let the user change his password. It extends the <em>LoginDialog</em>. As with its superclass, you can customize the labels of the predefined UI components.</p>
<p><img class="alignnone size-full wp-image-2614" title="dialog-3" src="http://corlan.org/wp-content/uploads/2011/02/dialog-3.jpg" alt="" width="585" height="379" /></p>
<p>Here is the code to create the dialog box above:</p>
<pre>var password:PasswordChangeDialog = new PasswordChangeDialog();
password.title = "Password Change";
password.message = "Please choose your new password:";
password.addButton("OK");
password.addButton("Cancel");
password.dialogSize= DialogSize.SIZE_MEDIUM;
password.addEventListener(Event.SELECT, alertButtonClicked3);
password.show(IowWindow.getAirWindow().group);</pre>
<p>And here is how you retrieve the user input:</p>
<pre>private function alertButtonClicked3(e:Event):void {
	var login:PasswordChangeDialog = e.target as PasswordChangeDialog;
	trace(login.password); //retrieve the old password
	trace(login.username); //retrieve the username
	trace(login.newPassword); //retrieve the new password
	trace(login.confirmation); //retrieve the confirmation for the new password
	trace(login.selectedIndex); //retrieve the button was clicked
}</pre>
<p>The <em>PromptDialog</em> extends <em>AlertDialog</em> and provides a way to capture user text input. You can set the hint to be used by the TextField using the <em>prompt</em> property. And you can retrieve the text entered using the <em>text</em> property.</p>
<p><img class="alignnone size-full wp-image-2616" title="dialog-4" src="http://corlan.org/wp-content/uploads/2011/02/dialog-4.jpg" alt="" width="397" height="317" /></p>
<p>Here is the code:</p>
<pre>var prompt:PromptDialog = new PromptDialog();
prompt.title = "Choose your username!";
prompt.message = "Please enter an username between 6-10 chars:";
prompt.prompt = "username";
prompt.addButton("OK");
prompt.addButton("Cancel");
prompt.dialogSize= DialogSize.SIZE_SMALL;
prompt.addEventListener(Event.SELECT, alertButtonClicked4);
prompt.show(IowWindow.getAirWindow().group);
...
private function alertButtonClicked4(e:Event):void {
	var d:PromptDialog = e.target as PromptDialog;
	//retrieve the text introduced by the user
	trace(d.text);
}</pre>
<p>The last dialog window is the <em>PopupList</em>component. This dialog creates a window that presents a scrollable list and the user can select either a single entry or multiple entries. You set the items that will be rendered in the list by assigning an <em>Array</em> of strings to the <em>items</em> property. If you want to allow multiple selections then you set the <em>multiSelect</em> property to true. If you want to preselect an item or a number of items, just set the <em>selectedIndices</em> property to an array of indices of the items you want selected.</p>
<p><img class="alignnone size-full wp-image-2618" title="dialog-5" src="http://corlan.org/wp-content/uploads/2011/02/dialog-5.jpg" alt="" width="369" height="291" /></p>
<p>Here is the code:</p>
<pre>var popUp:PopupList = new PopupList();
popUp.title = "Chose your title:";
popUp.items = ["Mr.", "Ms.", "Miss", "Dr.", "Phd"];
//allow multiple selection
popUp.multiSelect = true;
//preselect the second item
popUp.selectedIndices = [1];
popUp.addButton("OK");
popUp.addButton("Cancel");
popUp.dialogSize= DialogSize.SIZE_SMALL;
popUp.addEventListener(Event.SELECT, alertButtonClicked5);
popUp.show(IowWindow.getAirWindow().group);
...
private function alertButtonClicked5(e:Event):void {
	var d:PopupList = e.target as PopupList;
	//retrieve the selected index/indices
	trace(d.selectedIndex);
	trace(d.selectedIndices.toString());
}</pre>
<p>One last note on dialog box components: it doesn&#8217;t look like you can skin them or extend them. It would be nice to be able to create a custom dialog with the components you want in it. On the other hand they really cover most use cases you might think of.</p>
<h2>Download</h2>
<p>If you want the code used for this article, just download <a href="http://corlan.org/downloads/PlayBookUI.zip" target="_blank">this ActionScript mobile project</a> for Flash Builder 4.5 (you&#8217;ll need the PlayBook simulator and the BlackBerry plug-in for Flash Builder installed in order to run and compile the code).</p>
<h2>Conclusions</h2>
<p>These are not all the components available in the QNX libraries. Though I feel that with this post and the previous one on lists I&#8217;ve covered the vast majority. Check <a href="http://blog.digitalbackcountry.com" target="_blank">Ryan</a>&#8216;s and <a href="http://renaun.com/blog/" target="_blank">Renaun</a>&#8216;s blogs for articles on containers and playing multimedia.</p>
<p>I have to say that I really think that RIM did an amazing job with this QNX UI library. I think it includes pretty much all you need to create great applications. Especially the list components seemed to be almost complete and the dialog components are a nice touch particularly for tablet devices (though I&#8217;m not sure how well they will perform on smartphone screens).</p>
<p>In general everything seems to be well engineered and designed. The biggest caveat of all this is that we don&#8217;t have the library source code. Any Flex developer will tell you how important it is that the Flex framework is open source and you can inspect all the code you wish. It&#8217;s great when learning the framework and it is definitely great when debugging. Right now even a process that shouldn&#8217;t be that complicated (skinning) is a trial and error process.</p>
<p>What do you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/02/17/working-with-playbook-qnx-ui-components/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Cool AIR app for managing ASDoc offline</title>
		<link>http://corlan.org/2011/02/15/cool-air-app-for-managing-asdoc-offline/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cool-air-app-for-managing-asdoc-offline</link>
		<comments>http://corlan.org/2011/02/15/cool-air-app-for-managing-asdoc-offline/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 15:37:40 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2567</guid>
		<description><![CDATA[
			
				
			
		
Two days ago I stumbled upon a rather cool AIR application for managing ASDoc documentation offline and I thought it might help others too. Because sometimes I end up in a place without Wi-Fi, I needed a simple way to make ASDoc references, like the BlackBerry® Tablet OS SDK for Adobe® AIR® API Reference, available [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/02/15/cool-air-app-for-managing-asdoc-offline/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F15%2Fcool-air-app-for-managing-asdoc-offline%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F15%2Fcool-air-app-for-managing-asdoc-offline%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Two days ago I stumbled upon a rather cool AIR application for managing ASDoc documentation offline and I thought it might help others too. Because sometimes I end up in a place without Wi-Fi, I needed a simple way to make ASDoc references, like the <a href="http://www.blackberry.com/developers/docs/airapi/1.0.0/index.html" target="_blank">BlackBerry® Tablet OS SDK for Adobe® AIR® API Reference</a>, available offline.</p>
<p>I was happy to find that one solution is an AIR application called DOC?. You can download it from <a href="http://www.airdoc.be/" target="_blank">here</a>. You can add as many ASDoc sources you wish, the app will download and index them locally.</p>
<p><img class="alignnone size-full wp-image-2569" title="doc2" src="http://corlan.org/wp-content/uploads/2011/02/doc2.jpg" alt="" width="533" height="374" /></p>
<p>And then you can select the &#8220;book&#8221; you want and navigate to your heart&#8217;s content between the pages:</p>
<p><img class="alignnone size-full wp-image-2570" title="doc1" src="http://corlan.org/wp-content/uploads/2011/02/doc1.jpg" alt="" width="600" height="620" /></p>
<p>Of course it is not perfect (I wish I could use it for any type of documentation not only ASDoc) and occasionally you may hit a bug (it seems that a big documentat takes a lot of time to index). But for me, it is just perfect! Big kudos to Jeroen Beckers and Michiel Vancoillie, the creators of this nice little app. And, at the same time, this application illustrates perfectly the power of AIR and Flex. Well done Jeroen and Michiel.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/02/15/cool-air-app-for-managing-asdoc-offline/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Working with PlayBook QNX List Components</title>
		<link>http://corlan.org/2011/02/01/working-with-playbook-qnx-list-components/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-playbook-qnx-list-components</link>
		<comments>http://corlan.org/2011/02/01/working-with-playbook-qnx-list-components/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 15:06:01 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2537</guid>
		<description><![CDATA[
			
				
			
		
If you plan to create applications for PlayBook using the BlackBerry Tablet OS SDK for Adobe AIR then you&#8217;ll be happy to learn that the support for lists is quite extensive. If you look at the components from the qnx.ui.picker and qnx.ui.listClasses you will find nine UI components:

List
RoundList
ScrollPane
SectionList
TileList
SectionTileList
DropDown
PickerList
Picker


In this post I will discuss each one [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/02/01/working-with-playbook-qnx-list-components/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F01%2Fworking-with-playbook-qnx-list-components%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F02%2F01%2Fworking-with-playbook-qnx-list-components%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you plan to create applications for PlayBook using the BlackBerry Tablet OS SDK for Adobe AIR then you&#8217;ll be happy to learn that the support for lists is quite extensive. If you look at the components from the <em>qnx.ui.picker</em> and <em>qnx.ui.listClasses</em> you will find nine UI components:</p>
<ol>
<li>List</li>
<li>RoundList</li>
<li>ScrollPane</li>
<li>SectionList</li>
<li>TileList</li>
<li>SectionTileList</li>
<li>DropDown</li>
<li>PickerList</li>
<li>Picker</li>
</ol>
<p><img class="alignnone size-full wp-image-2556" title="list0" src="http://corlan.org/wp-content/uploads/2011/02/list0.jpg" alt="" width="590" height="357" /></p>
<p>In this post I will discuss each one of these components so you can get a sense of how to use them and when. I strongly believe that you need good &#8216;List&#8217; components if you want to create great mobile applications. Lists represent one of the most important mean you have to deal with the small size of tablet/phone screens.</p>
<p><span id="more-2537"></span></p>
<h2>Data Provider</h2>
<p>All these components (except <em>ScrollPane</em>) use a data provider in order to set the data used for displaying the items. For <em>List</em>, <em>RoundList</em>, <em>TileList</em>, <em>DropDown</em>, <em>Picker</em>, and <em>PickerList</em> you will use the <em>qnx.ui.data.DataProvider</em> class. Typically you wrap an <em>Array</em> into a <em>DataProvider</em>. For example:</p>
<pre>var arr:Array = new Array();
arr.push("item 1");
arr.push("item 2");
var dp:DataProvider = new DataProvider(arr);
myRoundList.dataProvider = dp;</pre>
<p><em>SectionList</em> and <em>SectionTileList</em> use an instance of <em>qnx.ui.data.SectionDataProvider</em> for setting the data.</p>
<h2>Dealing with Item Selection</h2>
<p>When you want to do something once an item (or multiple items) is selected, usually you have to register an event listener for <em>flash.events.Event.SELECT</em> or <em>qnx.ui.events.ListEvent.ITEM_CLICKED</em>.</p>
<p>For List, PickerList, SectionList, SectionTileList, TileList, and RoundList you will do something like this:</p>
<pre>list.addEventListener(ListEvent.ITEM_CLICKED, onSelected, false, 0, true);

private function onSelected(e:ListEvent):void {
    trace(e.index); //selected item index
    trace(e.section); //selected section for SectionList and SectionTileList
}</pre>
<p>For <em>DropDown</em> you will do:</p>
<pre>list.addEventListener(Event.SELECT, onDropDownSelection, false, 0, true);

private function onDropDownSelection(e:Event):void {
    //retrieve the selected item index
    trace((e.target as DropDown).selectedIndex);
}</pre>
<p>For <em>Picker</em> you want to listen for the<em> Event.CLOSE</em> event. Usually, you use <em>Picker</em> with at least two data providers and if you listen for the <em>Event.CLOSE</em> event, you can check the <em>selectedItems</em> property of the <em>Picker</em> to see what was selected.</p>
<h2>List</h2>
<p>This is the most basic list you can use. It allows you to set single selection, multiple selection, or no selection. The default skin for all lists looks for the <em>label</em> property for each item you supplied in the <em>dataProvider</em> property. If you don&#8217;t have a <em>label</em> property in your data, then you have to create a custom renderer and use the <em>list.setSkin(SkinName) </em>method to set it. Otherwise nothing will appear in your list.</p>
<pre>var arr:Array = [
        {label: "List"}
        {label: "RoundList"}
        {label: "ScrollPane"}
        {label: "SectionList"}
    ];
var list:List = new List();
list.dataProvider = new DataProvider(arr);
list.selectionMode = ListSelectionMode.SINGLE;
list.addEventListener(ListEvent.ITEM_CLICKED, onItemSelected, false, 0, true);</pre>
<p><img class="alignnone size-full wp-image-2544" title="list1" src="http://corlan.org/wp-content/uploads/2011/02/list1.jpg" alt="" width="202" height="425" /></p>
<h2>RoundList</h2>
<p>A <em>RoundList</em> is pretty much a List that continues to be scrollable after you reach the first/last element by displaying the same elements once again. In the image below you can see a <em>RoundList</em> that has 10 items; once you passed the 10th item, you will see the first items (1, 2, 3, 4).</p>
<p><img class="alignnone size-full wp-image-2545" title="list2" src="http://corlan.org/wp-content/uploads/2011/02/list2.jpg" alt="" width="105" height="189" /></p>
<p>Here is a snippet of code:</p>
<pre>var list:RoundList = new RoundList();
list.dataProvider = new DataProvider(arr);
list.rowHeight = 30;
//set width &amp; height; if not nothing will be rendered.
list.width = 100;
list.height = 300;
list.addEventListener(ListEvent.ITEM_CLICKED, onSelected, false, 0, true);</pre>
<h2>ScrollPane</h2>
<p><em>ScrollPane</em> components let you set a view port over a component. In the code example below I create an image, create a <em>ScrollPane</em> with the width/height smaller than the image, and then set the image as the <em>ScrollPane</em> content. You can control the direction of the scrolling (Horizontal/Vertical/Both).</p>
<p><img class="alignnone size-full wp-image-2547" title="list3" src="http://corlan.org/wp-content/uploads/2011/02/list3.jpg" alt="" width="250" height="260" /></p>
<pre>var img:Image = new Image();
img.setImage("assets/map.png");

var pane:ScrollPane = new ScrollPane();
pane.x = 30;
pane.y = 30;
pane.width = 300;
pane.height =  300;
pane.scrollDirection = ScrollDirection.BOTH;
pane.setScrollContent(img);</pre>
<p>As of writing this post, both in PlayBook Simulator and Flash Builder simulator the ScrollPane doesn&#8217;t seem to work as advertised. I wasn&#8217;t able to scroll the content.</p>
<h2>SectionList</h2>
<p>You will find <em>SectionList</em> quite useful when dealing with large collections of data that can be grouped by some criteria. For example a contact list can be grouped by the first letter or a play list could be grouped by the artist name. The list will be renderered with sections and each section will have a number of items.</p>
<p><img class="alignnone size-full wp-image-2549" title="list4" src="http://corlan.org/wp-content/uploads/2011/02/list4.jpg" alt="" width="199" height="493" /></p>
<p>You can control the section header row height and the item row height. You can also set a custom skin for the header or item. The only trick when using section lists is building the data provider because this list uses SectionDataProvider instead of DataProvider. Here is an example:</p>
<pre>//create the data provider
var data:ISectionDataProvider = new SectionDataProvider();
//create 3 sections
var s1:Object = new Object();
s1.label = "Section 1";
var s2:Object = new Object();
s2.label = "Section 2";
var s3:Object = new Object();
s3.label = "Section 2";
//add the sections
data.addItem(s1);
data.addItem(s2);
data.addItem(s3);
//add items to each section
for (var i:int = 0; i &lt; 5; i++) {
	data.addChildToItem({label: 1 + i}, s1);
	data.addChildToItem({label: 11 + i}, s2);
	data.addChildToItem({label: 21 + i}, s3);
}</pre>
<p>As you see you have two steps: one for adding a section (<em>data.addItem(section)</em>) and one for adding an item to a section (<em>data.addChildToItem(item, section)</em>).</p>
<p>And here is an example of how to create a list and handle item selection:</p>
<pre>var list:SectionList = new SectionList();
list.dataProvider = createSectionDataProvider();
list.selectionMode = ListSelectionMode.SINGLE;
list.width = 200;
list.height = 500;
list.headerHeight = 50;
list.rowHeight = 30;
list.setHeaderSkin(CustomHeader); //set a custom header skin
list.addEventListener(ListEvent.ITEM_CLICKED, onItem, false, 0, true);

private function onItem(e:ListEvent):void {
	trace(e.section);
	trace(e.index);
	var d:ISectionDataProvider = (e.target as SectionList).dataProvider as ISectionDataProvider;
	//retrieve the current selected section
	var tmp:Object = d.getItemAt(e.section);
	//retrieve the current selected item
	var item:Object = d.getChildInItemAt(tmp, e.index);
}</pre>
<h2>TileList</h2>
<p>You use <em>TileList</em> to display more than one item on a row. You do so by using the <em>columnCount</em> property. Here is an example:</p>
<pre>var list:TileList = new TileList();
//create a data provider with 1 to 10 numbers
list.dataProvider = createDataProvider();
list.width = 300;
list.height = 200;
//set 3 cells on a row
list.columnCount = 3;
list.cellPadding = 1;
list.selectionMode = ListSelectionMode.SINGLE;
list.addEventListener(ListEvent.ITEM_CLICKED, onItem, false, 0, true);</pre>
<p>This code will render a list that looks like this:</p>
<p><img class="alignnone size-full wp-image-2551" title="list5" src="http://corlan.org/wp-content/uploads/2011/02/list5.jpg" alt="" width="300" height="201" /></p>
<h2>SectionTileList</h2>
<p><em>SectionTileList</em> is a combination of <em>TileList</em> and <em>SectionList</em> &#8211; no big surprise is it? This means you create <em>SectionDataProvider</em> the same way as with <em>SectionList</em> and you use the <em>columnCount</em> property to set the number of items on a row as with <em>TileList</em>.</p>
<p><img class="alignnone size-full wp-image-2552" title="list6" src="http://corlan.org/wp-content/uploads/2011/02/list6.jpg" alt="" width="270" height="446" /></p>
<p>Here is an example:</p>
<pre>var list:SectionTileList = new SectionTileList();
list.dataProvider = createSectionDataProvider();
list.columnCount = 3;
list.cellPadding = 1;
list.selectionMode = ListSelectionMode.SINGLE;
list.width = 300;
list.height = 500;
list.addEventListener(ListEvent.ITEM_CLICKED, onItem, false, 0, true);

private function onItem(e:ListEvent):void {
	trace(e.section);
	trace(e.index);
	var d:ISectionDataProvider = (e.target as SectionList).dataProvider as ISectionDataProvider;
	//retrieve the current selected section
	var tmp:Object = d.getItemAt(e.section);
	//retrieve the current selected item
	var item:Object = d.getChildInItemAt(tmp, e.index);
}</pre>
<h2>DropDown</h2>
<p>DropDown list displays the currently selected item and when clicked, it expands and lets you scroll through the items and make a selection. Here you can see a DropDown in its normal and expanded state.</p>
<p><img class="alignnone size-full wp-image-2554" title="list7" src="http://corlan.org/wp-content/uploads/2011/02/list7.jpg" alt="" width="510" height="197" /></p>
<p>You use the <em>rowCount</em> property to set how many rows are displayed when the component is expanded. Code example:</p>
<pre>var list:DropDown = new DropDown();
list.rowHeight = 45;
list.rowCount=3;
list.width = 250;
list.dataProvider = createDataProvider();
//3 events: Event.OPEN / CLOSE / SELECT
list.addEventListener(Event.SELECT, onDropDownSelection, false, 0, true);

private function onDropDownSelection(e:Event):void {
	trace((e.target as DropDown).selectedIndex);
}</pre>
<h2>PickerList</h2>
<p><em>PickerList</em> is used by the <em>Picker</em> component (though you can use it too). It offers the same behavior as the <em>RoundList</em> (you can&#8217;t reach the end of the list; the elements will be repeated forever). The difference is that by default, it displays the currently selected item, and only when pressed it opens and displays more items. In the expanded state it uses a mask with variable Alpha to give some sense of depth.</p>
<p>Code example:</p>
<pre>var list:PickerList = new PickerList();
list.dataProvider = createDataProvider();
list.selectionMode = ListSelectionMode.SINGLE;
list.width = 50;
list.height = 40;
list.opaqueBackground = 0xFFFFFF;
//you can listen for Event.SELECT
list.addEventListener(ListEvent.ITEM_CLICKED, onSelected, false, 0, true);</pre>
<h2>Picker</h2>
<p>A <em>Picker</em> uses a number of <em>PickerList</em>. <em>Picker</em> has two states: a compact one for displaying the current selection and an expanded one for making the selection. Here is an example with the two states:</p>
<p><img class="alignnone size-full wp-image-2558" title="list9" src="http://corlan.org/wp-content/uploads/2011/02/list9.jpg" alt="" width="599" /></p>
<p>It is quite useful for situations when you want to present related lists together; like in the picture above where you want to provide a way for setting the date. Or you want to provide a way for selecting the time.</p>
<p>As in the case of the <em>SectionList</em>/<em>SectionTileList</em> the trickiest part is to create the data provider. Basically for each PickerList you want you need a <em>qnx.ui.data.DataProvider</em> object. So, for creating the data provider used by the <em>Picker </em>(it uses three PickerList components) from the image above you&#8217;d do something like this:</p>
<pre>private function createPickerDataProvider():IDataProvider {
	// Create three arrays to handle days, months, years.
	var day:Array = new Array();
	var month:Array = new Array();
	var year:Array = new Array();

	// Populate the month
	for (var i:int=1; i&lt;32; i++) {
		day.push({label: i.toString()});
	}

	// Populate and month array and create the month
	month.push({label: "January"});
	month.push({label: "February"});
	month.push({label: "March"});
	month.push({label: "April"});
	month.push({label: "May"});
	month.push({label: "June"});
	month.push({label: "July"});
	month.push({label: "August"});
	month.push({label: "September"});
	month.push({label: "October"});
	month.push({label: "November"});
	month.push({label: "December"});

	// Create the year DataProvider
	for (var i:int=1950; i&lt;2012; i++) {
		year.push({label: i.toString()});
	}

	// create the data provider
	var data:Array = new Array();
	data.push(new DataProvider(day));
	data.push(new DataProvider(month));
	data.push(new DataProvider(year));
	return new DataProvider(data);
}</pre>
<p>You create a <em>Picker</em> like this:</p>
<pre>var list:Picker = new Picker();
list.dataProvider = createPickerDataProvider();
list.width = 400;
list.height = 50;
//you can set the width for each section
list.setListWidth(0, 100);
list.setListWidth(1, 200);
list.setListWidth(2, 100);
list.selectedIndices = [1,1,45];
list.addEventListener(Event.SELECT, onPickerSelection, false, 0, true);
list.addEventListener(Event.OPEN, onPickerSelection, false, 0, true);
list.addEventListener(Event.CLOSE, onPickerSelection, false, 0, true);

private function onPickerSelection(e:Event):void {
       trace(e.type);
       if (e.type == Event.CLOSE) {
           var p:Picker = (e.target as Picker);
           for (var i:int = 0; i &lt; p.selectedItems.length; i++) {
                trace("Picker.selectedItems " + p.selectedItems[i].label);
            }
            trace("Picker.selectedIndices " + p.selectedIndices);
            trace("Picker.data " + p.data);
       }
}</pre>
<p>If you want to take an action when the user has finished making a selection, you should register an event listener for the <em>Event.CLOSE</em> event. This is triggered when the user taps outside the component boundaries and makes the component return to the compact state.</p>
<h2>Skinning Lists</h2>
<p>There aren&#8217;t many resources for skinning list components. And so far I haven&#8217;t played enough to talk about this. However, there is one thing I want to say about lists. In general they expect to be fed them with a data provider of objects that have a <em>label</em> property.</p>
<p>If you want to use an array of Strings as the source for the data provider you have to create a custom CellRenderer:</p>
<pre>package org.corlan.renderers {
	import qnx.ui.listClasses.AlternatingCellRenderer;

	public class CellRenderer extends qnx.ui.listClasses.AlternatingCellRenderer {

		public function CellRenderer() {
			super();
		}

		override public function set data(value:Object):void {
			super.data = value;
			setLabel(value as String);
		}

	}
}</pre>
<p>You can use this renderer like this:</p>
<pre>var optionsArr:Array = ["item 1", "item 2", "item 3"];

var list:List = new List();
list.setSkin(CellRenderer);
list.dataProvider = new DataProvider(optionsArr);</pre>
<h2>Download</h2>
<p>You can download a Flash Builder project with examples for all these components from <a href="http://corlan.org/downloads/PlayBookContainers.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/02/01/working-with-playbook-qnx-list-components/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Android Pictures and MP3 Remote Control Reloaded</title>
		<link>http://corlan.org/2011/01/30/android-pictures-and-mp3-remote-control-reloaded/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=android-pictures-and-mp3-remote-control-reloaded</link>
		<comments>http://corlan.org/2011/01/30/android-pictures-and-mp3-remote-control-reloaded/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 08:31:33 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2528</guid>
		<description><![CDATA[
			
				
			
		
Last year, I made two Android applications that connect to desktop apps: AndroidPictures (you can see the phone&#8217;s camera roll on a desktop) and Remote Control for desktop MP3 player (you can control an AIR desktop MP3 player from your mobile phone). At that time, Flex &#8220;Hero&#8221; wasn&#8217;t available, so last week I decided to [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/01/30/android-pictures-and-mp3-remote-control-reloaded/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F30%2Fandroid-pictures-and-mp3-remote-control-reloaded%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F30%2Fandroid-pictures-and-mp3-remote-control-reloaded%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Last year, I made two Android applications that connect to desktop apps: <a href="http://corlan.org/2010/07/08/androidpictures-or-how-to-share-phone-pictures-with-desktops/" target="_blank">AndroidPictures</a> (you can see the phone&#8217;s camera roll on a desktop) and <a href="http://corlan.org/2010/07/02/creating-multi-screen-apps-for-android-and-desktop-using-air/" target="_blank">Remote Control</a> for desktop MP3 player (you can control an AIR desktop MP3 player from your mobile phone). At that time, Flex &#8220;Hero&#8221; wasn&#8217;t available, so last week I decided to rewrite these apps, this time using the mobile components from Flex &#8220;Hero&#8221;.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/androidMedia.jpg"><img class="alignnone size-medium wp-image-2530" style="border: 0pt none;" title="androidMedia" src="http://corlan.org/wp-content/uploads/2011/01/androidMedia-193x300.jpg" alt="" width="193" height="300" /></a> <a href="http://corlan.org/wp-content/uploads/2011/01/mp3rc.jpg"><img class="alignnone size-medium wp-image-2531" style="border: 0pt none;" title="mp3rc" src="http://corlan.org/wp-content/uploads/2011/01/mp3rc-191x300.jpg" alt="" width="191" height="300" /></a></p>
<p>The reason I rewrote them with Flex &#8220;Hero&#8221; is quite simple: to see if it simpler or more complicated compared to plain Flex. And not surprisingly it is much simpler with Flex &#8220;Hero&#8221;. Actually I like the Views and ViewNavigator so much, that I&#8217;d love to have them available for desktop applications too.</p>
<p>One note on how these apps connect to each other: I used the new Peer 2 Peer capabilities from AIR/Flash Player. This part is extremely simple actually and if you have a look at the source code you&#8217;ll find that I wrap this functionality in a library that is used in both projects.</p>
<p>You can download them from here:</p>
<ul>
<li>AndroidMedia &#8211; <a href="http://corlan.org/downloads/AndroidMedia.apk" target="_self">APK file</a> / <a href="http://corlan.org/downloads/AndroidMedia.fxp" target="_self">source code</a> / <a href="http://corlan.org/downloads/androidpictures/PicturesViewer.air" target="_self">desktop app</a></li>
<li>MP3RemoteControl &#8211; <a href="http://corlan.org/downloads/MP3RemoteControl.apk" target="_self">APK file</a> / <a href="http://corlan.org/downloads/MobileMP3RemoteControl.fxp" target="_self">source code</a> / <a href="http://corlan.org/downloads/MusicPlayer.air" target="_self">desktop app</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/01/30/android-pictures-and-mp3-remote-control-reloaded/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Working with Flex RPC Services in ActionScript Mobile Projects</title>
		<link>http://corlan.org/2011/01/19/working-with-flex-rpc-services-in-actionscript-mobile-projects/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-flex-rpc-services-in-actionscript-mobile-projects</link>
		<comments>http://corlan.org/2011/01/19/working-with-flex-rpc-services-in-actionscript-mobile-projects/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 09:18:02 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2520</guid>
		<description><![CDATA[
			
				
			
		
In a previous post I showed you how you can use  QNX UI components in a Flex Mobile project that uses Flex RPC services (REST Style Services/Web Services/Remoting). What if you want to use Flex RPC services in an ActionScript Mobile Project? It isn&#8217;t possible, isn&#8217;t it? Wrong, you can make it work with a [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/01/19/working-with-flex-rpc-services-in-actionscript-mobile-projects/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F19%2Fworking-with-flex-rpc-services-in-actionscript-mobile-projects%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F19%2Fworking-with-flex-rpc-services-in-actionscript-mobile-projects%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In a previous <a href="http://corlan.org/2011/01/18/working-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air/" target="_self">post</a> I showed you how you can use  QNX UI components in a Flex Mobile project that uses Flex RPC services (REST Style Services/Web Services/Remoting). What if you want to use Flex RPC services in an ActionScript Mobile Project? It isn&#8217;t possible, isn&#8217;t it? Wrong, you can make it work with a little bit of extra work.</p>
<p>This works because, as my colleague Renaun Erickson said, Flex != MXML. In other words if you add the right parts from the Flex framework to your project you will be able to reuse these Flex services. Though, you won&#8217;t be able to write MXML code. Everything will be just ActionScript code.</p>
<p>Once you created a new ActionScript Mobile Project (these project supports Android and BlackBerry Tablet OS as target platforms) there are two steps you have to complete to enable Flex RPC support.</p>
<p><strong>Step 1.</strong> Right-click on the project name and choose Properties. Then click on the ActionScript Build Path entry. You will notice there are already some parts of the Flex framework added.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/rpc-01.jpg"><img class="alignnone size-medium wp-image-2521" style="border: 0pt none;" title="rpc-01" src="http://corlan.org/wp-content/uploads/2011/01/rpc-01-300x200.jpg" alt="" width="300" height="200" /></a></p>
<p><span id="more-2520"></span></p>
<p>Expand the first entry (Flex Hero) and add these two SWCs: framework.swc and rpc.swc (on my computer these SWCs are in /Applications/AdobeBeta/Adobe Flash Builder Burrito/sdks/4.5.0/frameworks/libs). Then you have to add the bundles for the default locale. So, this time, click on the &#8220;Add SWC Folder&#8230;&#8221; button and add the locale folder from Flex SDK (on my computer this is the path: /Applications/AdobeBeta/Adobe Flash Builder Burrito/sdks/4.5.0/frameworks/locale/en_US).</p>
<p><img class="alignnone size-full wp-image-2522" title="rpc-02" src="http://corlan.org/wp-content/uploads/2011/01/rpc-02.jpg" alt="" width="599" height="366" /></p>
<p>Once you apply these changes your project should compile with no errors.</p>
<p><strong>Step 2.</strong> You have to do some of the work the Flex compiler does for you automatically when you work with Flex projects. Remember, this project is an ActionScript project. You have to register a number of classes used by the AMF3 protocol. If you don&#8217;t do this, HTTPService will work, but when you try to use RemoteObject (this method uses AMF3 for encoding the messages) you will get this error:</p>
<p>TypeError: Error #1034: Type Coercion failed: cannot convert Object@3779ee1 to mx.messaging.messages.ErrorMessage.</p>
<p>Fortunately, this is an easy fix. You can register the classes needed at the top of your ActionScript application (in my project this class is named PlaybookRPC):</p>
<pre>[SWF(height="600",width="1024")]
public class PlaybookRPC extends Sprite {

   registerClassAlias("flex.messaging.messages.RemotingMessage", RemotingMessage);
   registerClassAlias("flex.messaging.messages.CommandMessage",CommandMessage);
   registerClassAlias("flex.messaging.messages.AcknowledgeMessage",
           AcknowledgeMessage);
   registerClassAlias("flex.messaging.messages.ErrorMessage", ErrorMessage);
   registerClassAlias("DSC", CommandMessageExt);
   registerClassAlias("DSK", AcknowledgeMessageExt);
   registerClassAlias("flex.messaging.io.ArrayList", ArrayList);
   registerClassAlias("flex.messaging.config.ConfigMap", ConfigMap);
   registerClassAlias("flex.messaging.io.ArrayCollection", ArrayCollection);
   registerClassAlias("flex.messaging.io.ObjectProxy", ObjectProxy);

   // You may want to register pub/sub and other rpc message types too...
   registerClassAlias("flex.messaging.messages.HTTPMessage", HTTPRequestMessage);
   registerClassAlias("flex.messaging.messages.SOAPMessage", SOAPMessage);
   registerClassAlias("flex.messaging.messages.AsyncMessage", AsyncMessage);
   registerClassAlias("DSA", AsyncMessageExt);
   registerClassAlias("flex.messaging.messages.MessagePerformanceInfo",
           MessagePerformanceInfo);

   public function PlaybookRPC() {
      super();

      // support autoOrients
      stage.align = StageAlign.TOP_LEFT;
      stage.scaleMode = StageScaleMode.NO_SCALE;

   }
}</pre>
<p><img class="alignnone size-full wp-image-2523" title="rpc-03" src="http://corlan.org/wp-content/uploads/2011/01/rpc-03.jpg" alt="" width="599" height="361" /></p>
<p>Now, you are ready to use Flex RPC services in this project. You can write something along these lines if you want to use Remoting:</p>
<pre>var remoting:mx.rpc.remoting.RemoteObject = new RemoteObject("AuthorsService");
remoting.source = "AuthorsService";
remoting.endpoint = BASE_URL + "remoting/gateway.php";
var token:AsyncToken = remoting.getData();
var responder:Responder = new Responder(onResult, onFault);
token.addResponder(responder);</pre>
<p>You can download my project from <a href="http://corlan.org/downloads/PlaybookRPC.zip">here</a> (server side services are not included). I haven&#8217;t tried Web Services (WSDL/SOAP) or Messaging (Producer/Consumer) but I don&#8217;t see any reason for them not to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/01/19/working-with-flex-rpc-services-in-actionscript-mobile-projects/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Working with Flex Services and BlackBerry Tablet OS SDK for Adobe AIR</title>
		<link>http://corlan.org/2011/01/18/working-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air</link>
		<comments>http://corlan.org/2011/01/18/working-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 17:00:39 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2510</guid>
		<description><![CDATA[
			
				
			
		
If you are an experienced developer, it&#8217;s easy to connect your Flex applications to almost everything. You can use REST Style services, remoting (Remote Procedure Call), and Web Services (WSDL/SOAP). Using a server library like BlazeDS you can use messaging (Producer/Consumer) as well.
What about using these methods with an AIR project for PlayBook created using [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/01/18/working-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F18%2Fworking-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F18%2Fworking-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you are an experienced developer, it&#8217;s easy to connect your Flex applications to almost everything. You can use REST Style services, remoting (Remote Procedure Call), and Web Services (WSDL/SOAP). Using a server library like BlazeDS you can use messaging (Producer/Consumer) as well.</p>
<p>What about using these methods with an AIR project for PlayBook created using the BlackBerry Tablet OS SDK for Adobe AIR and the QNX UI library? In this post I will show you how you can create a PlayBook application using QNX components for the UI and HTTPService/RemoteObject for reading data from a server.</p>
<p><strong>Note:</strong> In theory, it should be possible to use HTTPService, RemoteObject, and WebService even in a Mobile ActionScript project. <span style="text-decoration: line-through;">I will write another post on this matter.</span> See this <a href="http://corlan.org/2011/01/19/working-with-flex-rpc-services-in-actionscript-mobile-projects/" target="_self">post</a> on how to do it.</p>
<p><span id="more-2510"></span></p>
<h2>Prerequisites</h2>
<p>If you want to try this tutorial you will need to have Flash Builder &#8220;Hero&#8221; installed and enabled for PlayBook development. See this <a href="http://corlan.org/2011/01/13/updating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1/" target="_self">post</a> for more info on this topic.</p>
<h2>Creating the application</h2>
<p>The first step is to create a Flex Mobile Project. Choose File &gt; New &gt; Flex Mobile Project, enter a name for your project, and click the Next button. In the second page of the wizard make sure you select BlackBerry Tablet OS and Blank for &#8220;Application template&#8221;.</p>
<p><img class="alignnone size-full wp-image-2512" title="remoting-01" src="http://corlan.org/wp-content/uploads/2011/01/remoting-01.jpg" alt="" width="453" height="481" /></p>
<p>Once the project is created, you have to enable it for using QNX UI components. To do this, right-click on the project name and choose Properties. Then select the Flex Build Packaging &gt; BlackBerry Tablet OS entry and check the &#8220;Include BlackBerry Tablet OS libraries in build path&#8221; option.</p>
<p><img class="alignnone size-full wp-image-2514" title="remoting-02" src="http://corlan.org/wp-content/uploads/2011/01/remoting-02.jpg" alt="" width="599" height="350" /></p>
<p>Now, you are ready to create the application UI using QNX UI components. Open the MXML file if it isn&#8217;t already opened (mine is called MobileRemoting.mxml).</p>
<p><img class="alignnone size-full wp-image-2515" title="remoting-03" src="http://corlan.org/wp-content/uploads/2011/01/remoting-03.jpg" alt="" width="536" height="193" /></p>
<p>Now, it is time to create the application UI. I want to have a radio button group to choose from Remoting/HTTPService, a label, and a list for displaying the results. The finished result will look like this:</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/remoting-04.jpg"><img class="alignnone size-full wp-image-2517" style="border: 0pt none;" title="remoting-04" src="http://corlan.org/wp-content/uploads/2011/01/remoting-04.jpg" alt="" width="599" /></a></p>
<p>I created a function named createUI() and I registered this function for the ApplicationComplete event. Inside this function I created the UI using the QNX building blocks, just as you would do in a Mobile ActionScript Project.</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    applicationComplete="createUI()" backgroundColor="0xffffff"&gt;

   &lt;fx:Script&gt;
      &lt;![CDATA[
private function createUI():void {
    this.stage.align = StageAlign.TOP_LEFT;
    this.stage.scaleMode = StageScaleMode.NO_SCALE;

    base = new Container();
    base.flow = ContainerFlow.HORIZONTAL;

    var bottom:Container = new Container();
    bottom.size = 100;
    bottom.sizeUnit = SizeUnit.PERCENT;

    var header:Container = new Container();
    header.size = 60;
    header.sizeUnit = SizeUnit.PIXELS;
    header.containment = Containment.DOCK_TOP;
    header.flow = ContainerFlow.HORIZONTAL;
    header.opaqueBackground = 0x999999;

    var headerLeft:Container = new Container();
    headerLeft.align = ContainerAlign.NEAR;
    headerLeft.containment = Containment.BACKGROUND;

    var headerRight:Container = new Container();
    headerRight.flow = ContainerFlow.HORIZONTAL;
    headerRight.align = ContainerAlign.FAR;
    headerRight.containment = Containment.CONTAINED;

    var label:Label = new Label();
    label.format.bold = true;
    label.format.color = 0x0000ff;
    label.width = 170;
    label.text = " Read Data Using:";

    var spacer:Spacer = new Spacer();
    spacer.size = 50;
    spacer.sizeUnit = SizeUnit.PERCENT;

    var rb1:RadioButton = new RadioButton();
    rb1.size = 100;
    rb1.sizeUnit = SizeUnit.PERCENT;
    rb1.sizeMode = SizeMode.BOTH;
    rb1.groupname = "group1";
    rb1.label = METHOD_1;
    rb1.selected = true;
    rb1.addEventListener(MouseEvent.CLICK, onMethodSelection);

    var rb2:RadioButton = new RadioButton();
    rb2.size = 100;
    rb2.sizeUnit = SizeUnit.PERCENT;
    rb2.sizeMode = SizeMode.BOTH;
    rb2.groupname = "group1";
    rb2.label = METHOD_2;
    rb2.addEventListener(MouseEvent.CLICK, onMethodSelection);

    headerLeft.addChild(spacer);
    headerLeft.addChild(label);
    headerRight.addChild(new Spacer());
    headerRight.addChild(rb1);
    headerRight.addChild(rb2);
    header.addChild(headerLeft)
    header.addChild(headerRight)

    list = new List();
    list.setSkin(CellRenderer);
    list.containment = Containment.BACKGROUND;

    bottom.addChild(list);
    base.addChild(header);
    base.addChild(bottom);
    this.stage.addChild(base);

    base.setSize(stage.stageWidth,stage.stageHeight);
    //read the data using the current selected method
    getData();
}

 ]]&gt;
 &lt;/fx:Script&gt;</pre>
<p>Once the createUI() function is executed, the application should have the entire UI in place. The last line of this function calls a method named getData(). This is where the HTTPService and RemoteObject classes will be used. When you use these classes in Flex, you usually use the mx.rpc.http.mxml.HTTPService and mx.rpc.remoting.mxml.RemoteObject. But these objects are meant to be used in MXML, so what you&#8217;ll need is the super classes of these (which can be used in ActionScript): mx.rpc.remoting.RemoteObject and mx.rpc.http.HTTPService.</p>
<p>Now, it is pretty straightforward to read data from the server (there is some code for handling the switch between RemoteObject/HTTPService which I haven&#8217;t include it in snippet below):</p>
<pre>private function getData():void {
     //HTTP Service
     if (method == METHOD_1) {
        if (!http) {
           http = new HTTPService();
           http.method = "GET"; //this is the default method anyway
           http.url = BASE_URL + "rest/index.php";
           http.resultFormat = HTTPService.RESULT_FORMAT_OBJECT;
           http.addEventListener(FaultEvent.FAULT, onFault);
           http.addEventListener(ResultEvent.RESULT, onResult);
        }
        var param:Object = {what: "getAuthors"};
        http.send(param);
    //remoting
    } else {
        if (!remoting) {
           remoting = new RemoteObject("AuthorsService");
           remoting.source = "AuthorsService";
           remoting.endpoint = BASE_URL + "remoting/gateway.php";
        }
        var token:AsyncToken = remoting.getData();
        var responder:mx.rpc.Responder = new mx.rpc.Responder(onResult, onFault);
        token.addResponder(responder);
    }
 }</pre>
<p>I used this project to play a little bit with QNX lists, more precisely with CellRenderer. The default renderer looks for a property &#8220;label&#8221; as the source for the text. My data structure is different, depending on the method used to read the data. I created a new renderer by extending AlternatingCellRenderer:</p>
<pre>package org.corlan.renderers {
    import qnx.ui.listClasses.AlternatingCellRenderer;  

    public class CellRenderer extends qnx.ui.listClasses.AlternatingCellRenderer {
        public function CellRenderer() {    
            super();
        }

        override public function set data(value:Object):void {  
            super.data = value;
            var str:String = "";
            if (data["id_aut"])
                str = data.fname_aut + " " + data.lname_aut + " (" + data.id_aut + ")";
            else
                str = data.first + " " + data.last;
            setLabel(str);
        }
    }
}</pre>
<p>And I set this custom renderer by calling the setSkin() method on the list. For the complete code, please have a look at the Download section.</p>
<h2>Conclusions</h2>
<p>With all these new devices that keep coming, it is a good idea to be able to reuse the code you wrote for other applications as much as possible from. If you&#8217;ve created Flex projects using Remoting/REST style services/Web Services and you need the same data in a mobile project for PlayBook then you now know one way to do it. I will write another post about how to use the same methods in a mobile ActionScript project.</p>
<h2>Download</h2>
<p>You can download the project archive file from <a href="http://corlan.org/downloads/MobileRemoting.fxp" target="_self">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/01/18/working-with-flex-services-and-blackberry-tablet-os-sdk-for-adobe-air/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Updating to BlackBerry Tablet SDK 0.9.2 from 0.9.1</title>
		<link>http://corlan.org/2011/01/13/updating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1</link>
		<comments>http://corlan.org/2011/01/13/updating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 10:35:43 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2472</guid>
		<description><![CDATA[
			
				
			
		
Yesterday, RIM released version 0.9.2 of their BlackBerry Tablet OS SDK for Adobe AIR. This was just one of the bits announced yesterday &#8211; my fellow evangelist, Renaun Erickson, already wrote about this.
So what&#8217;s new for AIR development for PlayBook? Here is a list of what caught my eye:

New tablet simulator. If you don&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/01/13/updating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F13%2Fupdating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F13%2Fupdating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Yesterday, RIM released version 0.9.2 of their BlackBerry Tablet OS SDK for Adobe AIR. This was just one of the bits announced yesterday &#8211; my fellow evangelist, <a href="http://renaun.com/blog/2011/01/blackberry-tablet-os-sdk-for-adobe-air-updates-0-9-2/" target="_blank">Renaun Erickson</a>, already wrote about this.</p>
<p>So what&#8217;s <a href="http://docs.blackberry.com/en/developers/deliverables/21880/New_in_this_release_1398756_11.jsp" target="_blank">new</a> for AIR development for PlayBook? Here is a list of what caught my eye:</p>
<ul>
<li>New tablet simulator. If you don&#8217;t have a physical device you can use this simulator (this is just a virtual machine) to test and debug your application. This new version brings support for screen orientation (you just swipe up from the bottom-right corner to rotate the screen). You enable the support for screen orientation support by adding &lt;autoOrients&gt;true&lt;/autoOrients&gt; in the application descriptor file.</li>
<li>Application control permissions. If you want to use the camera, then you have to explicitly opt in by adding <samp>&lt;permission&gt;use_camera&lt;/permission&gt;</samp> in the blackberry-tablet.xml descriptor file.</li>
<li>Support for splash screens, <a href="http://corlan.org/2011/01/17/making-ssh-connections-to-playbook-simulator/" target="_self">SSH connection</a> to the tablet simulator, and development on Linux.</li>
<li>New APIs and .</li>
<li>A number of bugs <a href="http://docs.blackberry.com/en/developers/deliverables/21880/Fixed_issues_1398740_11.jsp" target="_blank">fixed</a>, like the infamous: &#8220;Dialog boxes moved when users typed text in a text input field&#8221;.</li>
</ul>
<p><span id="more-2472"></span></p>
<h2>Updating your environment to 0.9.2</h2>
<p>If you want to try all these new goodies the first thing is to go <a href="http://us.blackberry.com/developers/tablet/adobe.jsp" target="_blank">here</a> and download the BlackBerry Tablet OS SDK Beta3 for Adobe AIR and BlackBerry PlayBook Simulator Beta2 &#8211; make sure you select the versions for your operating system.</p>
<p>If you have Flash Builder 4 or Flash Builder &#8220;Burrito&#8221; (the preview version we&#8217;ve made available last year at Adobe MAX) then you can enable PlayBook development for your Flash Builder installation. On my machine I have installed &#8220;Burrito&#8221; and the previous version (0.9.1) of the BlackBerry Tablet OS SDK. To update the version I just unzipped the BlackBerryTabletSDK-Air-Installer-0.9.2-Mac.zip file,  started the installer, and followed the steps (specifying the &#8220;Burrito&#8221; location, AIR 2.5 SDK, and so on).</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/playbook092-1.jpg"><img class="alignnone size-medium wp-image-2477" style="border: 0pt none;" title="playbook092-1" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-1-300x209.jpg" alt="" width="300" height="209" /></a></p>
<p>Once the installation has finished, if you, open Flash Builder, go to &#8220;About Flash Builder&#8221;, and click the &#8220;Installation Details&#8221; button. You should see an entry for BlackBerry Tablet OS Platform features with a version like 0.9.2.XXX.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/playbook092-2.jpg"><img class="alignnone size-medium wp-image-2479" style="border: 0pt none;" title="playbook092-2" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-2-300x175.jpg" alt="" width="300" height="175" /></a></p>
<p>Although you could use the previous simulator version, I recommend upgrading the BlackBerry PlayBook simulator to the most recent version. So grab the BlackBerryPlayBookSimulator 2 for your operating system and start the installation process.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/playbook092-3.jpg"><img class="alignnone size-medium wp-image-2481" style="border: 0pt none;" title="playbook092-3" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-3-300x210.jpg" alt="" width="300" height="210" /></a></p>
<p>I used the default options and after the installation finished on my Mac, I got a new ISO file inside of my user folder: BlackBerryPlayBookSimulator-0.9.2.iso. The next step is to configure a new virtual machine using this file. So I started VMWare Fusion and chose New Virtual Machine. This will start a wizard. On the first page, just click the &#8220;Continue without disk&#8221; button.</p>
<p><img class="alignnone size-full wp-image-2482" title="playbook092-4" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-4.jpg" alt="" width="500" height="369" /></p>
<p>On the second page of the wizard choose the &#8220;Use operating system installation disk image file&#8221; option, select the BlackBerryPlayBookSimulator-0.9.2.iso file from your hard disk, and then click Continue.</p>
<p><img class="alignnone size-full wp-image-2483" title="playbook092-5" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-5.jpg" alt="" width="500" height="373" /></p>
<p>In the third step just make sure you&#8217;ve selected Other for both options (Operating System and Version) and click Continue. On the last step of the wizard if you click the &#8220;Customize Settings&#8221; button you can set up the amount of memory and support for 3D (I advise you to do so). Also you can change the name of the virtual machine (by default it will be named &#8220;Other&#8221; or &#8220;Other 2&#8243;).</p>
<p><img class="alignnone size-full wp-image-2484" title="playbook092-6" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-6.jpg" alt="" width="590" height="344" /></p>
<p>The next step is to start this new virtual machine. After a couple of seconds you will be presented with the screen below &#8211; type Y and press Enter (don&#8217;t worry, this is not deleting your files, it is just preparing the virtual machine files). This process will take some time, so be patient. After a couple more minutes you&#8217;ll be prompted to press Enter to reboot the virtual machine.</p>
<p><img class="alignnone size-full wp-image-2485" title="playbook092-7" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-7.jpg" alt="" width="590" height="365" /></p>
<p>Once the virtual machine has rebooted (this process that can take couple of minutes too) you are ready to use it.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/playbook092-8.jpg"><img class="alignnone size-medium wp-image-2488" style="border: 0pt none;" title="playbook092-8" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-8-300x189.jpg" alt="" width="300" height="189" /></a></p>
<p>Before being able to deploy applications from Flash Builder, you have to set up the device password, enable development mode, and retrieve the virtual machine IP address (don&#8217;t worry this is a one-time operation). Click the top-left icon and choose Security from the left list on the left. First set up a password, and then in the same screen enable development mode. You&#8217;ll be asked to enter a password, so enter the password you&#8217;ve just provided in the previous step.</p>
<p><img class="alignnone size-full wp-image-2489" title="playbook092-9" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-9.jpg" alt="" width="599" height="322" /></p>
<p>Finally, choose the About entry from the left menu and scroll down to retrieve the VMWare Network Address. You&#8217;ll use this information to configure the run configuration in Flash Builder.</p>
<p><img class="alignnone size-full wp-image-2490" title="playbook092-91" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-91.jpg" alt="" width="599" height="319" /></p>
<p>If you want to test screen orientation just swipe with your mouse cursor (holding the left button) from the bottom-right corner towards the center of the screen.</p>
<p><img class="alignnone size-full wp-image-2491" title="playbook092-92" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-92.jpg" alt="" width="345" height="599" /></p>
<p>If you want to test the whole setup (Flash Builder and Simulator) the easiest way is to create the PlayBook example project (choose File &gt; New &gt; Project expand Examples &gt; BlackBerry Tablet OS Examples, and select the BlackBerry Tablet OS Example AIR Project).</p>
<p><img class="alignnone size-full wp-image-2492" title="playbook092-93" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-93.jpg" alt="" width="454" height="373" /></p>
<p>Once you have the HelloWorld project created, choose the &#8220;Run Configurations&#8230;&#8221; option from the Run icon. This will open a configuration window. Choose Mobile Application from the left list and then click the &#8220;New launch configuration&#8221; icon (from the top-left). Then select the HelloWorld project (if it isn&#8217;t already selected), choose the &#8220;On device&#8221; option, and fill in the device IP address and password you set up earlier.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/playbook092-94.jpg"><img class="alignnone size-medium wp-image-2493" style="border: 0pt none;" title="playbook092-94" src="http://corlan.org/wp-content/uploads/2011/01/playbook092-94-300x274.jpg" alt="" width="300" height="274" /></a></p>
<p>If you click Run you should have the application compiled, installed on the device, and opened in a matter of seconds. Now you have a working development environment for PlayBook AIR development.</p>
]]></content:encoded>
			<wfw:commentRss>http://corlan.org/2011/01/13/updating-to-blackberry-tablet-sdk-0-9-2-from-0-9-1/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Understanding Flex Mobile View and ViewNavigator</title>
		<link>http://corlan.org/2011/01/12/understanding-flex-mobile-views-and-viewnavigator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=understanding-flex-mobile-views-and-viewnavigator</link>
		<comments>http://corlan.org/2011/01/12/understanding-flex-mobile-views-and-viewnavigator/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 10:33:08 +0000</pubDate>
		<dc:creator>Mihai Corlan</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://corlan.org/?p=2401</guid>
		<description><![CDATA[
			
				
			
		
The Flex framework &#8220;Hero&#8221; makes the task of creating mobile applications for BlackBerry Tablet OS, Android, and soon iOS extremely simple. I think that one of the best looking apps for Android is MAX Companion 2010 and please bear in mind that this app was created using an early build of Flex &#8220;Hero&#8221;.
  
This [...]]]></description>
			<content:encoded><![CDATA[<div class="none" style="float: right; margin-left: 10px;"><g:plusone href="http://corlan.org/2011/01/12/understanding-flex-mobile-views-and-viewnavigator/" size="tall" count="true"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F12%2Funderstanding-flex-mobile-views-and-viewnavigator%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcorlan.org%2F2011%2F01%2F12%2Funderstanding-flex-mobile-views-and-viewnavigator%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The Flex framework &#8220;Hero&#8221; makes the task of creating mobile applications for BlackBerry Tablet OS, Android, and soon iOS extremely simple. I think that one of the best looking apps for Android is MAX Companion 2010 and please bear in mind that this app was created using an early build of Flex &#8220;Hero&#8221;.</p>
<p><a href="http://corlan.org/wp-content/uploads/2011/01/maxcom-1.jpg"><img class="alignnone size-medium wp-image-2423" title="maxcom-1" src="http://corlan.org/wp-content/uploads/2011/01/maxcom-1-179x300.jpg" border="0" alt="" width="179" height="300" /></a> <a href="http://corlan.org/wp-content/uploads/2011/01/maxcom-2.jpg"><img class="alignnone size-medium wp-image-2424" title="maxcom-2" src="http://corlan.org/wp-content/uploads/2011/01/maxcom-2-178x300.jpg" border="0" alt="" width="178" height="300" /></a> <a href="http://corlan.org/wp-content/uploads/2011/01/maxcom-3.jpg"><img class="alignnone size-medium wp-image-2425" title="maxcom-3" src="http://corlan.org/wp-content/uploads/2011/01/maxcom-3-178x300.jpg" border="0" alt="" width="178" height="300" /></a></p>
<p>This is a reasonably complex application with lots of screens and social integration (Twitter) and yet on my Nexus One and Samsung Galaxy Tab it still works great. This is exactly where the Flex framework can shine on mobile devices: fast and easy development of applications that can connect to virtually anything (web services, REST services, RPC).</p>
<p>In this article I will talk about Flex Mobile <em>Views</em> and <em>ViewNavigator</em>. If you want to use Flex &#8220;Hero&#8221; to create mobile apps you need to understand how these components work.</p>
<p>Oh and one more thing, if you want to try this yourself you&#8217;ll need the Flash Builder &#8220;Burrito&#8221;. You can download it from <a href="http://labs.adobe.com/technologies/flashbuilder_burrito/" target="_blank">here</a>.<span id="more-2401"></span></p>
<h2>Screen Metaphor</h2>
<p>Before talking about Flex mobile components let&#8217;s talk a little bit about a concept called <em>screen metaphor</em>. This is basically a neat solution for a very big problem any developer encounters when developing for mobile devices: screen real estate.</p>
<p>On a desktop computer we have enough resolution to fit all the information we want on the screen. By using hierarchical menus and pop-up windows we can push a lot to the screen. Compared to this, a smartphone screen feels (almost) like a stamp. Besides resolution, pixel density plays an important role  &#8211; my Nexus one has a resolution of 480X800 pixels and 254 pixels per inch. This means that you have to enlarge the text roughly two to four times compared to the same resolution on a desktop/laptop screen when building apps for mobile devices. Thus you end up with less space to display information.</p>
<p>Using the <em>screen metaphor</em> you can split the information/UI of your application on multiple screens. For example when a user wants to see details for a particular session (see the above pictures of MAX Companion 2010 app) another screen is presented. When he wants to go back to the session list, the previous screen is presented.</p>
<p>Elegant though it might be, the <em>screen metaphor</em> is not rocket science. However there are some things to be considered such as:</p>
<ul>
<li>memory management &#8211; pushing dozens of screens can eat up all the memory available on the device</li>
<li>transitions from one screen to another &#8211; those nice effects that help you create an application like a professional UX Designer</li>
<li>passing data from one screen to another</li>
<li>preserving application state when the OS choose to close it</li>
<li>integration with hardware buttons &#8211; for example using the Back button of the phone to navigate to the previous screen</li>
</ul>
<p>Fortunately, the Flex framework has built-in support for the screen metaphor so you don&#8217;t have to reinvent the wheel.</p>
<h2>Flex Mobile Project</h2>
<p>When you install Flash Builder &#8220;Burrito&#8221; you will notice that there are two new types of projects related to mobile: Flex Mobile Project and ActionScript Mobile Project.</p>
<p><img class="alignnone size-full wp-image-2436" title="fmobproject" src="http://corlan.org/wp-content/uploads/2011/01/fmobproject.jpg" alt="" width="574" height="185" /></p>
<p>If you want to use Flex support for mobile development you should choose Flex Mobile Project and on the second page of the wizard make sure you select Mobile Application (this option makes a project that has uses Flex built-in support for the <em>screen metaphor</em>). As you can see in the screen capture below, you can choose to target both BlackBerry Tablet OS and Google Android platforms or just one of these platforms (as I said before we are working to extend the reach of the Flex framework to iOS &#8211; sometime in 2011).</p>
<p><img class="alignnone size-full wp-image-2437" title="mobproject" src="http://corlan.org/wp-content/uploads/2011/01/mobproject.jpg" alt="" width="450" height="412" /></p>
<p>Once you click Finish you will have a project structured like this:</p>
<p><img class="alignnone size-full wp-image-2439" title="mobileprostructure" src="http://corlan.org/wp-content/uploads/2011/01/mobileprostructure.jpg" alt="" width="237" height="125" /></p>
<p>Compared to a desktop AIR project you have one extra file: <em>views/MobileProjectHome.mxml</em>. The other two files are the &#8220;usual suspects&#8221;: the main application file (<em>MobileProject.mxml</em>) and the application descriptor file (<em>MobileProject-app.xml</em>). So what you have here is a skeleton for a Flex mobile application that has a single screen/View for now: <em>MobileProjectHome.mxml</em>. And if you open the main application file (<em>MobileProject.mxml</em>) you&#8217;ll see that on the MobileApplication tag there is an attribute named <em>firstView</em> and its value is set to <em>views.MobileProjectHome</em> &#8211; this is how you set the default screen for your mobile app.</p>
<p><img class="alignnone size-full wp-image-2441" title="defaultapp" src="http://corlan.org/wp-content/uploads/2011/01/defaultapp.jpg" alt="" width="522" height="139" /></p>
<p>Now, I&#8217;d like to step back and tell you about the two options you have when building Flex mobile apps. The first one is to use <em>MobileApplication</em> like in the project above. However if you work on an application that has lots of screens, it might be a good idea to use <em>TabbedMobileApplication</em>. As the name suggests you&#8217;ll have an application with support for tabs and for each tab you can have a stack of screens/Views (for each tab you can define the default/first screen). Here is an example:</p>
<p><img class="alignnone size-full wp-image-2442" title="t
