<?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>Jonathan Campos&#039; Blog &#187; Best Practices</title>
	<atom:link href="http://www.unitedmindset.com/jonbcampos/category/development/best-practices/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unitedmindset.com/jonbcampos</link>
	<description>Blog on technology and software development typically around Adobe Flash, Flex, and AIR.</description>
	<lastBuildDate>Mon, 07 Nov 2011 22:32:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Customizable Busy Indicator</title>
		<link>http://www.unitedmindset.com/jonbcampos/2011/08/05/customizable-busy-indicator/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2011/08/05/customizable-busy-indicator/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 14:44:05 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Busy Indicator]]></category>

		<guid isPermaLink="false">http://www.unitedmindset.com/jonbcampos/?p=2531</guid>
		<description><![CDATA[A good friend of mine, Antonio Holguin, inspired me to write this blog post when he wanted a good, customized busy indicator for a new application that he is creating &#8211; and he wanted to know what the heck I did with Queue Manager. If you&#8217;ve seen my Queue Manager application you&#8217;ve probably noticed that [...]]]></description>
			<content:encoded><![CDATA[<p>A good friend of mine, <a href="http://blog.swfhead.com/" target="_blank">Antonio Holguin</a>, inspired me to write this blog post when he wanted a good, customized busy indicator for a new application that he is creating &#8211; and he wanted to know what the heck I did with Queue Manager. If you&#8217;ve seen my Queue Manager application you&#8217;ve probably noticed that I have a custom busy indicator that looks like an &#8220;N&#8221; as it&#8217;s loading (Designed by <a href="http://feedgrids.com/" target="_blank">Dimi Arhontidis</a>). </p>
<p><a href="http://www.unitedmindset.com/jonbcampos/wp-content/uploads/2011/08/Screen-shot-2011-08-05-at-9.21.42-AM.png"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/uploads/2011/08/Screen-shot-2011-08-05-at-9.21.42-AM.png" alt="" title="Screen shot 2011-08-05 at 9.21.42 AM" width="375" height="146" class="alignnone size-full wp-image-2537" /></a></p>
<p>In this post I&#8217;m going to show you a class that I made after studying the Flex &#8220;BusyIndicator&#8221; class. Adobe has spent a great amount of time creating a great Busy Indicator, however I didn&#8217;t feel that the BusyIndicator was easily customizable, so I changed that.</p>
<p>Below is my code and some implementations.</p>
<p><span id="more-2531"></span></p>
<p>First, my custom class. The class is fairly straight forward and a slight modification of the Adobe provided BusyIndicator, however the thing that I did was add an easy way to override the shape creation function and give you two options to know where the loader is in progress, either through the selected index or the current rotation value. If you are using a circular loader then the &#8220;currentRotation&#8221; value may be better for you. For anything else the selectedIndex value may be better for you.</p>
<p>Use these values when you draw your symbols.</p>
<p><strong>CustomizableBusyIndicator</strong></p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">components</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Graphics</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">TimerEvent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Timer</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">DPIClassification</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">DesignLayer</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">FlexGlobals</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">IUIComponent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">IVisualElement</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlexEvent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">PropertyChangeEvent</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;The interval to delay, in milliseconds, between rotations of this<br />
&nbsp; &nbsp; &nbsp;* &nbsp;component. Controls the speed at which this component spins. <br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* &nbsp;@default 50<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* &nbsp;@langversion 3.0<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion AIR 2.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@productversion Flex 4.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp; <br />
&nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Style<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;rotationInterval&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Number&quot;</span>, format=<span style="color: #ff0000;">&quot;Time&quot;</span>, inherit=<span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Color of the symbols of the spinner.<br />
&nbsp; &nbsp; &nbsp;* &nbsp; <br />
&nbsp; &nbsp; &nbsp;* &nbsp;@default 0x000000<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* &nbsp;@langversion 3.0<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion AIR 2.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@productversion Flex 4.5<br />
&nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Style<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;symbolColor&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;uint&quot;</span>, format=<span style="color: #ff0000;">&quot;Color&quot;</span>, inherit=<span style="color: #ff0000;">&quot;yes&quot;</span>, theme=<span style="color: #ff0000;">&quot;spark,mobile&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Busy Indicator with easy to customize symbols.<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* Just override the drawSymbol() method to customize your symbols.<br />
&nbsp; &nbsp; &nbsp;* Override the measure method to adjust the sizes of the<br />
&nbsp; &nbsp; &nbsp;* busyindicator for different dpis. This is slightly modified code<br />
&nbsp; &nbsp; &nbsp;* from the Flex framework to make the busy indicator easier to customize<br />
&nbsp; &nbsp; &nbsp;* in my opinion while still being as lightweight as possible.<br />
&nbsp; &nbsp; &nbsp;* &nbsp;<br />
&nbsp; &nbsp; &nbsp;* @author jonbcampos<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomizableBusyIndicator <span style="color: #0066CC;">extends</span> UIComponent<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Constructor</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CustomizableBusyIndicator<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Listen to added to stage and removed from stage.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Start rotating when we are on the stage and stop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// when we are removed from the stage.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, addedToStageHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">REMOVED_FROM_STAGE</span>, removedFromStageHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Class constants</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">static</span> <span style="color: #0066CC;">private</span> const DEFAULT_ROTATION_INTERVAL:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">50</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">static</span> <span style="color: #0066CC;">private</span> const DEFAULT_MINIMUM_WIDTH_SIZE:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">28</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">static</span> <span style="color: #0066CC;">private</span> const DEFAULT_MINIMUM_HEIGHT_SIZE:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">38</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Variables</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> effectiveVisibility:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> effectiveVisibilityChanged:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> oldUnscaledHeight:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> oldUnscaledWidth:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> rotationTimer:Timer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Current rotation of this component in degrees.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Mimicked by the selectedIndex, though in index form.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> currentRotation:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Current selected index of the symbols.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Mimicked by the currentRotation, though in degrees. <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> selectedIndex:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _symbolQuantity:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _symbolQuantityChanged:<span style="color: #0066CC;">Boolean</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The fewer the symbols the less the drawing<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* the faster the component.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> symbolQuantity<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">int</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> _symbolQuantity; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> symbolQuantity<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_symbolQuantity == value<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _symbolQuantity = value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _symbolQuantityChanged = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invalidateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Private Properties </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Cache the last value of applicationDPI.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _applicationDPI:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Get the applicationDPI in use.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> applicationDPI<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_applicationDPI<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _applicationDPI;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> application:<span style="color: #0066CC;">Object</span> = FlexGlobals.<span style="color: #006600;">topLevelApplication</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;applicationDPI&quot;</span> <span style="color: #b1b100;">in</span> application<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _applicationDPI = application<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;applicationDPI&quot;</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _applicationDPI; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Overridden properties: UIComponent</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> designLayer<span style="color: #66cc66;">&#40;</span>value:DesignLayer<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">designLayer</span> = value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibilityChanged = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invalidateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Overridden methods: UIComponent</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> commitProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">commitProperties</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>effectiveVisibilityChanged<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// if visibility changed, re-compute them here</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; computeEffectiveVisibility<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>canRotate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stopRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibilityChanged = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>_symbolQuantityChanged<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _symbolQuantityChanged = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updateSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> measure<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">measure</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Set the default measured size depending on the</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// applicationDPI</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>applicationDPI == DPIClassification.<span style="color: #006600;">DPI_320</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//12x12</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredWidth = <span style="color: #cc66cc;">42</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredHeight = <span style="color: #cc66cc;">42</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>applicationDPI == DPIClassification.<span style="color: #006600;">DPI_240</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//10x10</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredWidth = <span style="color: #cc66cc;">34</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredHeight = <span style="color: #cc66cc;">34</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>applicationDPI == DPIClassification.<span style="color: #006600;">DPI_160</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//8x8</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredWidth = <span style="color: #cc66cc;">28</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredHeight = <span style="color: #cc66cc;">28</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredWidth = DEFAULT_MINIMUM_WIDTH_SIZE;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredHeight = DEFAULT_MINIMUM_HEIGHT_SIZE;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredMinWidth = DEFAULT_MINIMUM_WIDTH_SIZE;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredMinHeight = DEFAULT_MINIMUM_HEIGHT_SIZE;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Override so we know when visibility is set. The initialized<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;property calls setVisible() with noEvent == true<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;so we wouldn't get a visibility event if we just listened<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;for events.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setVisible<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">Boolean</span>, noEvent:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">setVisible</span><span style="color: #66cc66;">&#40;</span>value, noEvent<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibilityChanged = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invalidateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> styleChanged<span style="color: #66cc66;">&#40;</span>styleProp:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">styleChanged</span><span style="color: #66cc66;">&#40;</span>styleProp<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> allStyles:<span style="color: #0066CC;">Boolean</span> = <span style="color: #66cc66;">!</span>styleName <span style="color: #66cc66;">||</span> styleName == <span style="color: #ff0000;">&quot;styleName&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Check for skin/icon changes here.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// We could only throw out any skins that change,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// but since dynamic re-skinning is uncommon, we'll take</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the simpler approach of throwing out all skins.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>allStyles <span style="color: #66cc66;">||</span> styleName == <span style="color: #ff0000;">&quot;rotationInterval&quot;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Update the timer if the rotation interval has changed.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>isRotating<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stopRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>allStyles <span style="color: #66cc66;">||</span> styleName == <span style="color: #ff0000;">&quot;symbolColor&quot;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updateSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> updateDisplayList<span style="color: #66cc66;">&#40;</span>unscaledWidth:<span style="color: #0066CC;">Number</span>, unscaledHeight:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">updateDisplayList</span><span style="color: #66cc66;">&#40;</span>unscaledWidth, unscaledHeight<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// If the size changed, then create a new spinner.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>oldUnscaledWidth <span style="color: #66cc66;">!</span>= unscaledWidth <span style="color: #66cc66;">||</span> oldUnscaledHeight <span style="color: #66cc66;">!</span>= unscaledHeight<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> newDiameter:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updateSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oldUnscaledWidth = unscaledWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oldUnscaledHeight = unscaledHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Methods</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; Update the spinner properties and redraw.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> updateSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> isRotating:<span style="color: #0066CC;">Boolean</span> = isRotating<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>isRotating<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stopRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>isRotating<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Draw the spinner using the graphics property of this component.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> drawSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> g:Graphics = graphics;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span> = -<span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>++index<span style="color: #66cc66;">&lt;</span>symbolQuantity<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawSymbol<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Draws the symbol, use the index to determine the position, color, etc.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param index<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> drawSymbol<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> startRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>rotationTimer<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> rotationInterval:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;rotationInterval&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>rotationInterval<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationInterval = DEFAULT_ROTATION_INTERVAL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>rotationInterval <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">16.6</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationInterval = <span style="color: #cc66cc;">16.6</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationTimer = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span>rotationInterval<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>rotationTimer.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationTimer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span>, timerHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationTimer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> stopRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>rotationTimer<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationTimer.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span>, timerHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationTimer.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotationTimer = <span style="color: #000000; font-weight: bold;">null</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> isRotating<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> rotationTimer <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;The BusyIndicator can be rotated if it is both on the display list and <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;visible.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@returns true if the BusyIndicator can be rotated, false otherwise.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> canRotate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>effectiveVisibility <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #0066CC;">stage</span> <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> computeEffectiveVisibility<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Check our design layer first.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>designLayer <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">!</span>designLayer.<span style="color: #006600;">effectiveVisibility</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibility = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Start out with true visibility and enablement</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// then loop up parent-chain to see if any of them are false.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibility = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> current:IVisualElement = <span style="color: #0066CC;">this</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>current<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>current.<span style="color: #0066CC;">visible</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #66cc66;">&#40;</span>current is IUIComponent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">!</span>IUIComponent<span style="color: #66cc66;">&#40;</span>current<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">isPopUp</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Treat all pop ups as if they were visible. This is to </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// fix a bug where the BusyIndicator does not spin when it </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// is inside modal popup. The problem is in we do not get </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// an event when the modal window is made visible in </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// PopUpManagerImpl.fadeInEffectEndHandler(). When the modal</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// window is made visible, setVisible() is passed &quot;true&quot; so </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// as to not send an event. When do get events when the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// non-modal windows are popped up. Only modal windows are</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// a problem.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// The downside of this fix is BusyIndicator components that are</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// inside of hidden, non-modal, popup windows will paint themselves</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// on a timer.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibility = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current = current.<span style="color: #006600;">parent</span> as IVisualElement;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Add event listeners for SHOW and HIDE on all the ancestors up the parent chain.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Adding weak event listeners just to be safe.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> addVisibilityListeners<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> current:IVisualElement = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">parent</span> as IVisualElement;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>current<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// add visibility listeners to the parent</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FlexEvent.<span style="color: #0066CC;">HIDE</span>, visibilityChangedHandler, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FlexEvent.<span style="color: #0066CC;">SHOW</span>, visibilityChangedHandler, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current = current.<span style="color: #006600;">parent</span> as IVisualElement;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Remove event listeners for SHOW and HIDE on all the ancestors up the parent chain.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> removeVisibilityListeners<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> current:IVisualElement = <span style="color: #0066CC;">this</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>current<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>FlexEvent.<span style="color: #0066CC;">HIDE</span>, visibilityChangedHandler, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>FlexEvent.<span style="color: #0066CC;">SHOW</span>, visibilityChangedHandler, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current = current.<span style="color: #006600;">parent</span> as IVisualElement;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Overridden event handlers: UIComponent</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> layer_PropertyChange<span style="color: #66cc66;">&#40;</span>event:PropertyChangeEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">layer_PropertyChange</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">property</span> == <span style="color: #ff0000;">&quot;effectiveVisibility&quot;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibilityChanged = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invalidateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Event Handlers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> addedToStageHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Check our visibility here since we haven't added</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// visibility listeners yet.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; computeEffectiveVisibility<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>canRotate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addVisibilityListeners<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> removedFromStageHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stopRotation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; removeVisibilityListeners<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Event call back whenever the visibility of us or one of our ancestors <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;changes<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> visibilityChangedHandler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effectiveVisibilityChanged = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invalidateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;@private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;Rotate the spinner once for each timer event.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> timerHandler<span style="color: #66cc66;">&#40;</span>event:TimerEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentRotation += <span style="color: #cc66cc;">360</span><span style="color: #66cc66;">/</span>symbolQuantity;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedIndex++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>currentRotation <span style="color: #66cc66;">&gt;</span>= <span style="color: #cc66cc;">360</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentRotation = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedIndex = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event.<span style="color: #0066CC;">updateAfterEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Next we need to customize and subclass the CustomizableBusyIndicator by overriding the <strong>drawSymbol</strong> method. Below are two examples of the customized busy indicator. The first I modeled after the Nintendo DS Loader &#8211; I was just playing Zelda, it&#8217;s all I could come up with.</p>
<p>The second is modeled after another loader I&#8217;ve seen, can&#8217;t remember where.</p>
<p>Customizing is easy and best of all the loader has been performance optimized. So you can create something custom is with the mental security you&#8217;re not screwing anything up. <img src='http://www.unitedmindset.com/jonbcampos/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="attachment_2532" class="wp-caption alignnone" style="width: 171px"><a href="http://www.unitedmindset.com/jonbcampos/wp-content/uploads/2011/08/Screen-shot-2011-08-05-at-9.13.56-AM.png"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/uploads/2011/08/Screen-shot-2011-08-05-at-9.13.56-AM.png" alt="Busy Indicators" title="Busy Indicators" width="161" height="184" class="size-full wp-image-2532" /></a><p class="wp-caption-text">Busy Indicators</p></div>
<p><strong>DS Loader</strong></p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">components</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Graphics</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Busy Indicator modeled after the Nintendo DS Busy Indicator.<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* @author jonbcampos<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;*/</span> <br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DSBusyIndicator <span style="color: #0066CC;">extends</span> CustomizableBusyIndicator<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> DSBusyIndicator<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//the quantity of symbols for this indicator.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//8 squares</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; symbolQuantity = <span style="color: #cc66cc;">8</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _symbolPadding:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _symbolWidth:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _symbolHeight:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Measures and sets size based on DPI. <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> measure<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//use the default sizes.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//I could also make different</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//sizes for my component by overriding.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">measure</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//I only want to make this</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//calculation when the measurement</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//changes, but it isn't super</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//necessary here. I would put it in the</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//drawSymbols method.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _symbolHeight = <span style="color: #66cc66;">&#40;</span>measuredHeight - <span style="color: #66cc66;">&#40;</span>_symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">3</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _symbolWidth = <span style="color: #66cc66;">&#40;</span>measuredWidth - <span style="color: #66cc66;">&#40;</span>_symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">3</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Kick starts drawing all the individual symbols. <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> drawSymbols<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">drawSymbols</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> symbolColor:uint = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;symbolColor&quot;</span><span style="color: #66cc66;">&#41;</span> as uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//make center square</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> g:Graphics = graphics;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>symbolColor, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> centerX:<span style="color: #0066CC;">Number</span> = <span style="color: #66cc66;">&#40;</span>measuredWidth - _symbolWidth<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> centerY:<span style="color: #0066CC;">Number</span> = <span style="color: #66cc66;">&#40;</span>measuredHeight - _symbolHeight<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span>centerX, centerY, _symbolWidth, _symbolHeight<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Draws one symbol.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param index The index shows which symbol in the matrix you are making. <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* This value is arbitrary and you can layout your symbols however you want<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* in whatever index order you want.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> drawSymbol<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">_alpha</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _posX:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _posY:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _alpha1:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0.4</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _alpha2:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0.6</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">0</span>: <span style="color: #808080; font-style: italic;">//top left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//default pos</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span>: <span style="color: #808080; font-style: italic;">//top center</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = _symbolWidth + _symbolPadding;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span>: <span style="color: #808080; font-style: italic;">//top right</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = _symbolWidth<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + _symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">3</span>: <span style="color: #808080; font-style: italic;">//mid right</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = _symbolWidth<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + _symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = _symbolHeight + _symbolPadding;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">4</span>: <span style="color: #808080; font-style: italic;">//bottom right</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = _symbolWidth<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + _symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = _symbolHeight<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + _symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">5</span>: <span style="color: #808080; font-style: italic;">//bottom center</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = _symbolWidth + _symbolPadding;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = _symbolHeight<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + _symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">6</span>: <span style="color: #808080; font-style: italic;">//bottom left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = _symbolHeight<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + _symbolPadding<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">7</span>: <span style="color: #808080; font-style: italic;">//mid left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set alpha if it is the selected symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>selectedIndex==<span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = _alpha2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//position symbol</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = _symbolHeight + _symbolPadding;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//get the symbol style color</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> symbolColor:uint = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;symbolColor&quot;</span><span style="color: #66cc66;">&#41;</span> as uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//with all my positions determined,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//now actual draw the graphic</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> g:Graphics = graphics;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>symbolColor, <span style="color: #0066CC;">_alpha</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span>_posX, _posY, _symbolWidth, _symbolHeight<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><strong>Other Loader</strong></p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">components</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Graphics</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Busy Indicator modeled after ?. <br />
&nbsp; &nbsp; &nbsp;* @author jonbcampos<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CirclesBusyIndicator <span style="color: #0066CC;">extends</span> CustomizableBusyIndicator<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CirclesBusyIndicator<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//the quantity of symbols for this indicator.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//6 circles</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; symbolQuantity = <span style="color: #cc66cc;">6</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//make it just a bit slower</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//you could also adjust the</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//speed by setting the style on</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//the component instance.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;rotationInterval&quot;</span>, <span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _symbolWidth:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _symbolHeight:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _radius:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Measures and sets size based on DPI. <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> measure<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//use the default sizes.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//I could also make different</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//sizes for my component by overriding.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">measure</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//I only want to make this</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//calculation when the measurement</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//changes, but it isn't super</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//necessary here. I would put it in the</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//drawSymbols method.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _symbolHeight = measuredHeight<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">3</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _symbolWidth = measuredWidth<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">3</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _radius = measuredWidth <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">7</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Draws one symbol.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param index The index shows which symbol in the matrix you are making. <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* This value is arbitrary and you can layout your symbols however you want<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* in whatever index order you want.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> drawSymbol<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">_alpha</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _posX:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _posY:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//if the selected index</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//is the index we are drawing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set it's alpha lower</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>==selectedIndex<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;">0.5</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">0</span>: <span style="color: #808080; font-style: italic;">//top left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = measuredWidth <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">3</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = measuredHeight <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">6</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span>: <span style="color: #808080; font-style: italic;">//top right</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = measuredWidth - _symbolWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = measuredHeight <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">6</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span>: <span style="color: #808080; font-style: italic;">//mid right</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = <span style="color: #66cc66;">&#40;</span>measuredWidth + measuredWidth<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span> - _symbolWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = measuredHeight <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">3</span>: <span style="color: #808080; font-style: italic;">//bottom right</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = measuredWidth - _symbolWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = <span style="color: #66cc66;">&#40;</span>measuredHeight + measuredHeight<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span> - _symbolHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">4</span>: <span style="color: #808080; font-style: italic;">//bottom left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = measuredWidth <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">3</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = <span style="color: #66cc66;">&#40;</span>measuredHeight + measuredHeight<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span> - _symbolHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">5</span>: <span style="color: #808080; font-style: italic;">//mid left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posX = measuredWidth <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">6</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _posY = measuredHeight <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//get the symbol style color</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> symbolColor:uint = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;symbolColor&quot;</span><span style="color: #66cc66;">&#41;</span> as uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//with all my positions determined,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//now actual draw the graphic</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> g:Graphics = graphics;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>symbolColor, <span style="color: #0066CC;">_alpha</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span>_posX, _posY, _radius<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2011%2F08%2F05%2Fcustomizable-busy-indicator%2F&amp;title=Customizable%20Busy%20Indicator" id="wpa2a_2"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2011/08/05/customizable-busy-indicator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learn from my mobile mistakes</title>
		<link>http://www.unitedmindset.com/jonbcampos/2010/12/28/learn-from-my-mobile-mistakes/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2010/12/28/learn-from-my-mobile-mistakes/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 15:02:59 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Air for Android]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Netflix Flex API]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[queue manager]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=2393</guid>
		<description><![CDATA[This blog post could also be &#8220;how to lower your stars in the marketplace&#8221;. I say this because now looking back at having an application in the marketplace for a few months I see many places that I have screwed up and things that I could do much better next time. At the point of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://unitedmindset.com/jonbcampos/wp-content/uploads/2010/10/icon128.png" alt="" title="icon128" width="128" height="128" class="alignleft size-full wp-image-2237" />This blog post could also be &#8220;how to lower your stars in the marketplace&#8221;. I say this because now looking back at having an application in the marketplace for a few months I see many places that I have screwed up and things that I could do much better next time.</p>
<p>At the point of writing this I&#8217;m actually really happy with where Queue Manager has gone.<br />
- Queue Manager has almost 50k users<br />
- Queue Manager is listed highly in the Android Market<br />
- Queue Manager is listed as the top Air for Android app on <a href="http://www.appbrain.com/app/queue-manager/air.com.unitedmindset.QueueManager">AppBrain</a><br />
- Queue Manager is listed highly in <a href="http://appaware.org/app.php?packagename=air.com.unitedmindset.QueueManager">AppAware</a><br />
- Queue Manager is awaiting acceptance into the BlackBerry App World<br />
- <a href="http://www.androidcentral.com/android-central-editors-app-picks-october-28-2010?utm_source=feedburner&#038;utm_medium=feed&#038;utm_campaign=Feed:+androidcentral+(Android+Central)">Android Central</a> listed Queue Manager as a top pick in October and it was stated &#8220;it [Queue Manager] has proven to me the viability of Adobe Air as a development platform for Android&#8221;</p>
<p><img src="http://qrcode.kaywa.com/img.php?s=5&#038;d=market%3A%2F%2Fsearch%3Fq%3Dpname%3Aair.com.unitedmindset.QueueManager" alt="qrcode"/><br />
<span id="more-2393"></span></p>
<p>All this success has not been due to my efforts though, I feel that my efforts have only hindered the application&#8217;s success rather than bolster it. I&#8217;m going to go through the things that I&#8217;ve done &#8211; or have been done to me &#8211; that have hurt Queue Manager and what I have done to fix my mistakes.</p>
<p>Some of these mistakes are embarrassing to admit, especially from a developer that has made multiple applications / products before, yet the old issues still creep up if you let them.</p>
<p><strong>Releasing Too Early</strong><br />
This issue was due to my ego more than anything else. I wanted to have the first Air for Android application on the market and guess what? I did it. The second that Air was pushed to the market I followed right up with Queue Manager. What issues did this cause? You can assume and assume correctly that the initial release was buggy, feature depleted, and could have used some good ole&#8217; optimization. In subsequent releases I fixed up these bugs but due to my buggy release I ended up on triage duty for the first week.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Release when the app is ready, not based on some other date</li>
</ul>
<p><strong>Frequent Releases</strong><br />
Part of this issue was due to how far I needed to go to compete with other Netflix applications on the Android market, part of this issue was that I was trying to have a specific feature set out by Adobe Max, part of this issue was that I wasn&#8217;t testing thoroughly enough and had to constantly release bug fixes, and part of this issue was that every time I finished a feature I wanted it out to the market as fast as possible. All of these &#8220;parts&#8221; lead to one thing: upset users. While some users appreciated the frequent releases most told me that they would have preferred if they weren&#8217;t quite as frequent as I was making them. As time has gone on my releases have been less frequent as the amount of changes needed to the application have decreased. Along with that I have been testing more on my application prior to release &#8211; not just testing the feature that I worked on. Finally my app has grown to a very stable state so the bugs have been worked out over time.</p>
<p>I currently sit on releases a day or two just to feel good about them.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Plan releases</li>
<li>- Test throughly so that you&#8217;re not having to follow up a feature release with an immediate bug fix</li>
<li>- Even if you have good code to release, spread it out and possibly merge feature releases</li>
</ul>
<p><strong>Work closely with your API provider</strong><br />
This has actually been one of my biggest problems and a problem I am completely helpless to &#8211; hopefully the app that you make isn&#8217;t dependent on a public API.</p>
<p>The issue is that Netflix provides me X amount of calls against their servers in one day. If Queue Manger gets featured somewhere or a bunch of people decide to use Queue Manager for an extended period of time and Queue Manager hits it&#8217;s Netflix limit then the application starts giving back an error from Netflix. Each time this has happened I have contacted Netflix and they have given me a bump in my limit, yet another few weeks pass by and I start hitting my limit again. I feel for my users, they just want an application that works, yet this is an area that I am completely hopeless.</p>
<p>When this happens I usually end up with a string of 1 star comments in my market reviews.</p>
<blockquote><p>This is particularly bad when I put out a new release because everyone goes and plays with the app to see what has changed. A quarter of my user base could easily put me over my API limit.</p></blockquote>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Give good feedback to the user</li>
<li>- Limit calls to the server</li>
</ul>
<p><strong>Condense your trips</strong><br />
Mobile is great because it is on the go however you can quickly come across places that on the go doesn&#8217;t equal on the web. With this spotty service possibility even the smallest service call may take quite a long time to fully get back. I learned this the hard way with my initial release.</p>
<p>On my testing computer I received each service call I made almost instantly and the computer was quickly able to parse and visualize the data. When my users started working with my application the initial comments I got back were that they didn&#8217;t know if anything was going on. Even after adding visual loading indicators I had users complaining that the application was &#8220;sluggish&#8221; and the data was taking too long to get back.</p>
<p>This lead to another place for optimization and I spent some long nights working on reorganizing the service calls that I made to the Netflix service. This reduced the data that I was receiving from Netflix, sped up the application and especially the loading time. I still have users that say it takes to long, but eventually there is only so much that I can do about the network, their location, and their device.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Give good feedback to the user</li>
<li>- Reduce the amount of data you rely on</li>
</ul>
<p><strong>Double check your app id prior to release!</strong><br />
I thought that I would be the only person to hit this but alas my good friend <a href="http://twitter.com/flashcanon" target="_blank">FlashCanon</a> also fell prey to this. Prior to releasing your app to the Android Market double check your app id in the application descriptor file and make sure you are perfectly happy with it <strong>BECAUSE YOU CAN&#8217;T CHANGE IT LATER!</strong> The name of the app, the programming, the colors, and basically everything else about your app can change between releases but your app id will stay the same and can&#8217;t be changed.</p>
<blockquote><p>I know there are rumors that you can contact Google and ask them to help change your app id but I would recommend just getting this right from the beginning.</p></blockquote>
<p>If you need to change the app id you will just have to put up a new application with the right id and get your users to reinstall the new app. Obviously you will lose the stats and whatever else from your initial release but you will get the id that you were wanting.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Double check your application id!</li>
</ul>
<p><strong>Double check your application descriptor prior to every release</strong><br />
With every release you can remove your application from the Android Market based on the options that are in your application descriptor. There was about a two week period that I removed Queue Manager from the Marketplace because I updated my Flash Builder version and the application descriptor changed just slightly. This slight change altered the filtering options on my application and even my users couldn&#8217;t find the application in a search.</p>
<blockquote><p>Always check your application descriptor and the application manifest. These details lead to filtering in the Android Market.</p></blockquote>
<p>Now prior to every release I read through my application manifest,  double check that the install location is set to auto, and that my user permissions are set properly.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Double check your permissions</li>
<li>- Make sure that the install location is set to auto for app2sd functionality</li>
<li>- Ensure that your icons stay consistent between releases (and exist)</li>
</ul>
<p><strong>Have error tracking code</strong><br />
As I hinted at earlier there are many things that may go wrong with an application. The device may malfunction, the internet signal may fade, or &#8211; the most obvious &#8211; your code may break. Your users will probably be quick to tell you that your application sucks or has failed but be unclear as to what happened. As I am limited and don&#8217;t know what has happened on the server side (delivered by Netflix) I have an entire section of my application that I am unaware of any issues.</p>
<p>That being said I&#8217;ve had to construct an error tracking system within my application to give the users details as to what happened and ultimately deliver to me the error. All this extra work is very helpful to narrowing down the problem. As an added bonus, if you make error reporting very easy on your users they are more apt to sending you the generated error report.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Give good feedback to the user</li>
<li>- Make it easy for the user to submit bugs/issues</li>
</ul>
<p><strong>Have statistics gathering code</strong><br />
I love statistics gathering code because once I know what my users are doing on a statistical level I know where to focus my efforts for development. I&#8217;ve recently learned that my users do two things: search for titles and browse through new instant titles. That&#8217;s it. Knowing this I can focus my development practices around making sure that my application can do what my users want.</p>
<p>Where did I fail on this? Well I didn&#8217;t put in my tracking information till recently. If you are working on an application I recommend <a href="http://code.google.com/p/gaforflash/">GA for Flash</a>.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Add in code to gather use statistics</li>
<li>- Don&#8217;t gather more information than is necessary, this just will cause extra unneeded application chatter</li>
</ul>
<p><strong>Optimize Visuals</strong><br />
My good friend <a href="http://feedgrids.com">Dimi</a> would be proud of me and all the work I did on the icons. Just for the record he designed most of the app and how it looked, I just pieced it all together. The issue was that some of the icons came out as &#8220;crunchy&#8221; (thanks <a href="http://blog.swfhead.com/">Antonio</a>).</p>
<p>I knew to not scale the images yet the icons still came out as &#8220;crunchy&#8221;.</p>
<p>One night I decided to sit down and figure out the problem, it didn&#8217;t take long. The icons that I was using was built at an odd size. Due to the odd size the device has having issues displaying the icon as the device also does some scaling of the icon. However when I rebuilt the icons with their size based on a power of 2 (specifically 36&#215;36) the icon&#8217;s &#8220;crunchy&#8221; look went away and was smooth again.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Look over all images, make sure they are a multiple of 2 (16&#215;16, 36&#215;36, etc)</li>
</ul>
<p><strong>Test on multiple screens</strong><br />
Testing on multiple devices is the bane of my existence. No matter how many devices I get my hands on there is always one more device that makes my app look just a little bit different and horrible at the same time. At a certain point you are going to need to decide for yourself how many devices is &#8220;good enough&#8221; and move forward.</p>
<p>I&#8217;d recommend testing on at least 3 different phones and 1 tablet. These different sizes and resolutions should help get most of the kinks out. When you see your app on these different resolutions and sizes you&#8217;ll probably realize the same two things that I did. Things that were &#8220;a bit&#8221; on the small size are unusable on some devices and things that &#8220;a bit&#8221; on the large size actually look okay.</p>
<blockquote><p>For the most part I&#8217;ve been really happy with the look of my app across many devices. The Flex Team is doing a good job of keeping design stable across multiple screens.</p></blockquote>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Get devices</li>
<li>- Test on devices</li>
</ul>
<p><strong>Never accept &#8220;okay&#8221;</strong><br />
There are a few times that I&#8217;ve had to make the hard decision &#8220;I will cut a corner here so I can get this important bug fixed there&#8221;. I thought that my users wouldn&#8217;t notice and that they would be happy to get one bug fixed even if it meant that the update wasn&#8217;t very significant.</p>
<p>I was wrong.</p>
<p>My users did notice and they punished me for it. Users aren&#8217;t happy for incremental changes and they will comment and rate your application on two levels. The first is an overall score while the second is how much has the app improved from the last update. If the user doesn&#8217;t deem the update important enough you&#8217;ll get a nice 1-star rating for wasting their time with the update. Not nice but it is reality.</p>
<p>After seeing this phenomenon I&#8217;ve been very happy to rate applications that I enjoy with 5 stars, even if the updates seem trivial.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Plan your updates</li>
<li>- Realize that everything is significant and you can&#8217;t skip out anywhere</li>
</ul>
<p><strong>Accept that your users are going to destroy your app</strong><br />
This point was very interesting and something I didn&#8217;t expect. I had a user contact me that the app didn&#8217;t work for them. After a few more emails back and forth I couldn&#8217;t understand what the problem was and was left to just apologizing to the user. Then the user gave me a break through. He had a custom build of the Android OS that gave him a few extra abilities &#8211; including the ability to turn on and off permissions to applications.</p>
<p>Apparently he decided that my application didn&#8217;t need the ability to access the internet but was upset with me when the application couldn&#8217;t access the Netflix API.</p>
<p>The lesson? Sometimes there is nothing you can do.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Accept defeat</li>
</ul>
<p><strong>Unit Test (where possible)</strong><br />
Don&#8217;t have to go far into this subject. Unit tests work, use them. Even if you think you&#8217;re a &#8220;good developer&#8221; they will help.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Write your tests</li>
</ul>
<p><strong>Have a release checklist</strong><br />
This may not seem like very important but I&#8217;ve always found release checklists to be helpful. There were a few times in early releases that I didn&#8217;t follow any checklist and I accidentally left in debug information or my testing api key or a few other issues. All of these caused for some bad releases followed by an immediate secondary release followed by upset users.</p>
<p>I recommend writing a script for you to follow when you are making a release. Make sure all of your testing bits are in the script, any settings you have to change, and double check your application descriptor. Once your checklist is completed then make your release.</p>
<p>I originally didn&#8217;t do all this with my app as I considered it a &#8220;small&#8221; app and suspected I could remember all these steps off the cuff. I quickly learned that there is no such thing as a small app and every detail matters.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Make a script</li>
<li>- Follow your script each time</li>
</ul>
<p><strong>Include your contact information</strong><br />
Finally, give your users a way to contact you. I&#8217;ve found over the entire process that I have some very kind users and also some users that have great ideas and points for improvements. They appreciate that the ability to give feedback and contribute often. I receive roughly 10 emails a day from my users with ideas and requests.</p>
<p><em>To Do Item(s):</em></p>
<ul>
<li>- Include your contact information somewhere</li>
</ul>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2010%2F12%2F28%2Flearn-from-my-mobile-mistakes%2F&amp;title=Learn%20from%20my%20mobile%20mistakes" id="wpa2a_4"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2010/12/28/learn-from-my-mobile-mistakes/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Flex 4.5 PersistenceManager</title>
		<link>http://www.unitedmindset.com/jonbcampos/2010/11/01/flex-4-5-persistencemanager/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2010/11/01/flex-4-5-persistencemanager/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 15:26:48 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Air for Android]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[air for android]]></category>
		<category><![CDATA[flex 4.5]]></category>
		<category><![CDATA[ipersistencemanager]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[persistencemanager]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=1981</guid>
		<description><![CDATA[The PersistenceManager is the data center backbone to your mobile Flex application. The reason you need to think about the persistance layer of your mobile app more than you needed to before in web and desktop development is because of the high probability of interruption and application closure. In web and desktop development if something [...]]]></description>
			<content:encoded><![CDATA[<p>The PersistenceManager is the data center backbone to your mobile Flex application. The reason you need to think about the persistance layer of your mobile app more than you needed to before in web and desktop development is because of the high probability of interruption and application closure.</p>
<p>In web and desktop development if something else happened on the user&#8217;s computer the user could simply switch windows to handle the interruption and continue their task. This happens so frequently that developers actually never think of this as a issue. However with mobile development there is always the chance of a phone call coming in, or email, or any other application that may take focus away from your application. While you application is not in immediate use you now fall prey to the operating system&#8217;s whim. If the OS decides that your application needs to close for memory or power reasons then the state of your application and any data it was holding may now be lost unless you have created an aggressive data persistance layer.</p>
<p><img src="http://unitedmindset.com/jonbcampos/wp-content/uploads/2010/11/applicationSessionCut.png" alt="" title="applicationSessionCut" width="582" height="225" class="alignnone size-full wp-image-2343" /></p>
<p>On top of that, the views within your application are created and destroyed quite frequently. That means if you were a developer that was used to grabbing data from offscreen or invisible views then your data will no longer be available when these other views are destroyed. Another reason why you need to be very aggressive about moving data into a proper data model and away from the view.</p>
<p>Getting into it let&#8217;s look at the PersistenceManager, what it is, and how we can alter it to do our bidding.<br />
<span id="more-1981"></span><br />
<strong>PersistenceManager</strong><br />
First off the PersistenceManager is a simple way to interact with an LSO (Local Shared Object). This is the default way to persist data across views and sessions. There are only a handful of functions to worry about to get use this class.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &nbsp;Methods</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//--------------------------------------------------------------------------</span><br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Clears all the data that is being stored by the persistence<br />
&nbsp; &nbsp; &nbsp;* &nbsp;manager.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@langversion 3.0<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion Flash 10.1<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion AIR 2.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@productversion Flex 4.5<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Flushes the data being managed by the persistence manager to<br />
&nbsp; &nbsp; &nbsp;* &nbsp;disk or another external storage file.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@langversion 3.0<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion Flash 10.1<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion AIR 2.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@productversion Flex 4.5<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">flush</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Initializes the persistence manager.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@langversion 3.0<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion Flash 10.1<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion AIR 2.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@productversion Flex 4.5<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> initialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Returns the value of a property stored in the persistence manager.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@param key The property key<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@langversion 3.0<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion Flash 10.1<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion AIR 2.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@productversion Flex 4.5<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">getProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">key</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Stores a value in the persistence manager.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@param key The key to use to store the value<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@param value The value object to store<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@langversion 3.0<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion Flash 10.1<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@playerversion AIR 2.5<br />
&nbsp; &nbsp; &nbsp;* &nbsp;@productversion Flex 4.5<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">setProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">key</span>:<span style="color: #0066CC;">String</span>, value:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;</div></div>
<p>This makes it very easy to set and get data from the persistence layer.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> p:PersistanceManager = <span style="color: #000000; font-weight: bold;">new</span> PersistenceManager<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* this is a singleton */</span><br />
p.<span style="color: #0066CC;">setProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key&quot;</span>, <span style="color: #cc66cc;">1232131.123</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
...<br />
...<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> p:PersistanceManager = <span style="color: #000000; font-weight: bold;">new</span> PersistenceManager<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* this is a singleton */</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">key</span>:<span style="color: #0066CC;">Number</span> = p.<span style="color: #0066CC;">getProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key&quot;</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Number</span>;</div></div>
<p><strong>Roll Your Own</strong><br />
Don&#8217;t like using LSOs? Prefer SQLite Databases or some other storage plan? No problem. You don&#8217;t have to roll your own completely if you don&#8217;t want to &#8211; though you could. You can still use the PersistenceManager, just make sure to use the interface: <em>IPersistenceManager</em>. The functions are all the same but now you can make your own and do whatever you want. This is a wonderful example of programming to an interface rather than an implementation.</p>
<p>While the simple functions provided by the <em>IPersistenceManager</em> may not be robust enough for your application then you can just completely write your own class. I prefer to stick to the provided interfaces because then other developers that help out don&#8217;t have to learn an entire new set of methods.</p>
<blockquote><p>
Looking at getting started with Flash Builder Burrito and the new Flex SDK? Check out this post on <a href="http://unitedmindset.com/jonbcampos/2010/10/25/flex-4-5-mobile-development-post-burrito/">Flex Hero development</a>.
</p></blockquote>
<blockquote><p>
Looking at getting going with non-Hero development or don&#8217;t have the new Flash Builder Burrito? Check out this post on <a href="http://unitedmindset.com/jonbcampos/2010/07/19/android-mobile-development/">getting started with Air for Android</a>.
</p></blockquote>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2010%2F11%2F01%2Fflex-4-5-persistencemanager%2F&amp;title=Flex%204.5%20PersistenceManager" id="wpa2a_6"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2010/11/01/flex-4-5-persistencemanager/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Optimization Techniques for Air for Android apps</title>
		<link>http://www.unitedmindset.com/jonbcampos/2010/09/08/optimization-techniques-for-air-for-android-apps/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2010/09/08/optimization-techniques-for-air-for-android-apps/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 14:53:57 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Air for Android]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[air for android]]></category>
		<category><![CDATA[battery use]]></category>
		<category><![CDATA[memory consumption]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=1954</guid>
		<description><![CDATA[Day one everything I heard about mobile development was performance, memory optimization, and battery consumption. Spread all over the internet are a variety of articles and presentations with a variety of [great] optimization techniques. As with my previous posts on performance optimization I like to focus on the big gains and these techniques that are [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://unitedmindset.com/jonbcampos/wp-content/uploads/2010/07/airforandroid1.png" alt="" title="AIR for Android Logo" width="228" height="200" class="alignleft size-full wp-image-1766" />Day one everything I heard about mobile development was performance, memory optimization, and battery consumption. Spread all over the internet are a variety of articles and presentations with a variety of [great] optimization techniques.</p>
<p>As with my previous posts on <a href="http://unitedmindset.com/jonbcampos/2009/11/30/practical-performance-tweaks/">performance optimization</a> I like to focus on the big gains and these techniques that are practical. I say practical because you can&#8217;t always spend a year working on each component and optimizing every interaction, but what you can do is focus on the big gains and when time permits &#8211; the details. I don&#8217;t mean to play down the importance of code optimization; especially for mobile applications optimization is of the highest importance.</p>
<p>In no particular order of importance let&#8217;s look at some excellent places for performance and memory allocation gains.<br />
<span id="more-1954"></span><br />
<strong>Keep framerate as low as possible</strong><br />
For anyone that hasn&#8217;t looked into it, the default framerate for the Flash Player is 24 frames per second. That means that 24 times every second new code is being executed, regions are being redrawn, and user interactions are being calculated. So it stands to reason that the quickest way to reduce memory consumption, code execution, and redrawing algorithms is to reduce the framerate and therefore the amount of times per second that all these calculations are being run.</p>
<p>What few developers know is that you can change your framerate dynamically dependent on what is happening within your application. The first recommendation is to set your framerate to something low but tolerable &#8211; like 4 frames per second. Then when a transition or other animation is going to play increase your framerate to keep your animation smooth.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">frameRate</span> = <span style="color: #cc66cc;">4</span>;</div></div>
<blockquote><p>
Monitoring your framerate is very important as many flash designers want to ramp up the framerate to 60 frames per second because it will make the animations &#8220;pretty&#8221;.
</p></blockquote>
<p><strong>Avoid timers</strong><br />
<img src="http://unitedmindset.com/jonbcampos/wp-content/uploads/2010/09/LiquidTimers-150x150.jpg" alt="" title="LiquidTimers" width="150" height="150" class="alignright size-thumbnail wp-image-2068" />Each timer that you add and use in your application connects into the Flash Player environment and calculates time on each frame, thus adding additional computations on each frame for each timer you create. Real fast you can multiply these calculations if you aren&#8217;t careful.</p>
<p>To improve performance avoid high rate timers, this will reduce the amount of events being fired and the quantity of code being executed.</p>
<p>The second performance increase is to have one timer for the entire application. Think of it as a heartbeat for your application keeping the internal timing for all your functions. This will reduce the amount of timers you have and the amount of time calculations taken from the Flash Player environment.</p>
<p><strong>Blends and Filters</strong><br />
It has long been known that as filters and blends cause for an extra amount of lifting from the Flash Player, lifting that can truly slow down performance. So where possible avoid blends and filters. <em>&#8220;But I want to have a 2px drop shadow around this box.&#8221;</em> Does it really need to be a filter? Can you not use a dark line that is 2 pixels thick? I know this sounds elementary but many people seem to forget that there are other more creative solutions that might get you to the same goal.</p>
<p><strong>Cache As Bitmap</strong><br />
If you&#8217;ve been in the Flash Player world for a while you will remember the day you saw Adobe&#8217;s <em>cacheAsBitmap</em> presentation and how quickly everything rendered. My mind was blown and I had found my magic bullet to all my slow rendering woes.</p>
<p>Well not exactly. <em>cacheAsBitmap</em> is amazing and in many situations can be very helpful. How does it achieve it&#8217;s amazing win? By caching a bitmap off screen that can be used as opposed to needing to recreate the bitmap over and over again. The issue comes if you change the alpha/rotation/colors on your bitmap. Now the renderer needs to make a new bitmap to cache and you are doing extra lifting to cache and draw rather than just draw. What this means for you is if you are going to be making lots of alpha/rotation/colors changes then you might not want to set <em>cacheAsBitmap</em> to <em>true</em>.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">myBall.<span style="color: #006600;">cacheAsBitmap</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div></div>
<p>One other little used cache method is <em>cacheAsBitmapMatrix</em>. Similar to the <em>cacheAsBitmap</em> this will also cache the x, y, rotation, scale, skew properties. Keeping the Flash Player from having to redraw the object. Again, if you make any changes to alpha/color or the children sprites matrix the object will be redrawn and you will be spending more time and memory to cache an object that is constantly redrawn.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">myBall.<span style="color: #006600;">cacheAsBitmap</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
myBall.<span style="color: #006600;">cacheAsBitmapMatrix</span> = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p><strong>Asset Management</strong><br />
Asset management is extremely important with mobile because all those images can eat up memory quick.</p>
<p>First: Make sure your images are the right size. I&#8217;ve seen many developers take icons that are 40&#215;40 and just resize them to 20&#215;20 at runtime. I know this seems picky and obvious but this is a quick way to double your memory and hurt rendering performance with unnecessary calculations. Just make sure that images are set to their proper size.</p>
<p>Second: Don&#8217;t embed fonts/images/media you aren&#8217;t using. It&#8217;s easy to forget about all the items you are embedding. Be an asset nazi.</p>
<p>Third: Compress Compress Compress. Do you really need that high quality sound file? Or that PNG with the transparency layer when there is no transparency? Compress those media files. Use JPGs rather than PNG when possible. And if you are just trying to see the background through an icon, think or building the icon with the correct background already in the file. Transparency is another calculation that isn&#8217;t necessary if you can be sure of the end goal.</p>
<blockquote><p>
Don&#8217;t forget that images split by the power of 2 are going to be more efficient on memory than odd sized images. This can&#8217;t always be avoided by it&#8217;s good to remember. This is definitely a nit-picky thing.</p>
<p>&#8220;Make bitmaps in sizes that are close to, but less than, 2n by 2m bits. The dimensions do not have to be power of 2, but they should be close to a power of 2, without being larger. For example, a 31-by-15–pixel image renders faster than a 33-by-17–pixel image. (31 and 15 are just less than powers of 2: 32 and 16.)&#8221;<br />
-From the Developing Air Apps for Android Guide.
</p></blockquote>
<p><strong>Events and Bubbling</strong><br />
I&#8217;m really interested to see how <a href="http://mate.asfusion.com/">Mate</a> responds to this one. We&#8217;ve known for a long time that events are costly and that lots of events and event bubbling through deeply nested component trees can lead to bottle necks and performance issues.</p>
<p>A quick way to deal with these issues is to not bubble your events when possible and when you do need to bubble, stop propagation when the events have reached a point that they don&#8217;t need to bubble anymore.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">event.<span style="color: #006600;">stopPropagation</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<blockquote><p>
Simplifying your display tree whenever possible is a great way to improve performance. Don&#8217;t do this for just the events but for your entire application.
</p></blockquote>
<p>One other thing you can do is prevent mouse events (that are set to bubble by default) from effecting children you weren&#8217;t intending. Try setting <em>mouseChildren</em> and <em>mouseEnabled</em> to <em>false</em>.</p>
<p><strong>Drawing API</strong><br />
For you masochists that love to write out Actionscript drawings I&#8217;d take particular notice of this part. Watch out how much you draw dynamically because each drawing is drawn to the stage and then rendered in the rasterizer. When you build assets at authoring time your assets are rendered and stored in memory rather than created on the fly.</p>
<p><img src="http://unitedmindset.com/jonbcampos/wp-content/uploads/2010/09/Screen-shot-2010-09-08-at-9.44.35-AM.png" alt="" title="Screen shot 2010-09-08 at 9.44.35 AM" width="600" height="181" class="alignnone size-full wp-image-2071" /><br />
<strong>Color Selection</strong><br />
This gain is specifically to do with battery life. The color <em>white</em> takes more power to show than the color <em>black</em>. Am I saying to have all your applications look like tributes to The Dark Knight? Nope. Just giving your designers a warning that their decisions directly effect performance and battery consumption.</p>
<p><strong>Embedded Fonts and Device Fonts</strong><br />
Android devices have fonts that are embedded within the system, these fonts will require the smallest amount of memory because it won&#8217;t require embedding any additional fonts and they render remarkably fast. Use these fonts when possible.</p>
<p>But what if you have a picky designer that has to have the fonts his way? Embed your fonts for the fastest rendering and follow <a href="http://unitedmindset.com/jonbcampos/2009/11/24/getting-through-black-magic-font-embedding/">best practices to limit the glyphs that you include with your embed</a>.</p>
<blockquote><p>
You can find out what fonts your Android system has in the <strong>/system/fonts</strong> folder.
</p></blockquote>
<p><strong>Garbage Collection</strong><br />
First off I think I need to say &#8220;stop running the garbage collection&#8221;. Yes developers, I know you want your application to clean itself up immediately. However, I&#8217;ve seen more than one app become sluggish because of an over worked garbage collector. So all those tricks that you&#8217;ve found to run the garbage collector, stop. The Flash Player runs the garbage collection when it needs to. If something isn&#8217;t going away the way you expect maybe you should check for other leaks caused by listener references or other common leaks.</p>
<p><strong>Memory Allocation</strong><br />
Not enough programmers take advantage of Object Pooling. This is probably why I was impressed with <a href="http://pushbuttonengine.com/">PushButton Engine</a> right from day one, everything is based off object pools. This is an easy and tested way to reuse objects and save your application from the costly &#8216;new&#8217; function.</p>
<p>What do I mean by the <em>costly new function</em>? Whenever you use the &#8220;new&#8221; function and create a new object you are running a costly operation. Multiple things happen deep within the Flash Player including heap/memory allocation, garbage collection, and component creation. If you know you are going to be creating and destroying something frequently make the change to Object Pools early and save yourself the memory and performance woes.</p>
<blockquote><p>
A few months back I wrote another article doing a series of performance tests. I devote an entire section of tests to the &#8220;new&#8221; operator in <a href="http://unitedmindset.com/jonbcampos/2009/11/30/practical-performance-tweaks/">Practical Performance Tweaks</a>.
</p></blockquote>
<p><strong>Video</strong><br />
This is something that your designers are going to hate: stop messing with the video player! All those crazy graphics, overlays, and blends that you may put over your video to add the grunge border will need to go. If you are worried about performance these are a quick way to cause redraws and layering calculations on each video frame.</p>
<p>When encoding your video thing of the final endpoint. Most devices have a native codec (usually H.264) that will help improve decompression and playback on the hardware level rather than the software level. Make sure to target these native codecs and see the performance and battery life improvement.</p>
<p><strong>Show Redraw Regions</strong><br />
This is pretty low on the priority list but very important if you get it wrong. Flex visual components build off of the Flash Sprite class. As such they are interactive objects without animation timelines. However, when working with Flash based components, Flex developers often forget the MovieClip Class &#8211; the lowest class to include a timeline. This class can be set to run causing all sorts of redraws on each frame of animation until it is eventually told to stop playing.</p>
<p>When working with visual components from Flash or especially components that are based off of Movieclip make sure to stop the timeline when the component is not visible. Even when invisible the timeline is running and redraws are occurring. Using the <em>Show Redraw Regions</em> will expose this.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">movieClipComponent.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>It is also best practices to look over your application as a whole and make sure that components aren&#8217;t needlessly being redrawn. This may be caused by a bad property or a misbehaving function. Check that only regions that change are actually getting redrawn for some pretty nice performance increases.</p>
<p><strong>Open To Comments</strong><br />
I&#8217;d be interested to see where else others have seen visible improvements when using specific performance improvement methods. Feel free to comment! All the methods displayed above I have personally tested and seen the difference between using them and not using them.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2010%2F09%2F08%2Foptimization-techniques-for-air-for-android-apps%2F&amp;title=Optimization%20Techniques%20for%20Air%20for%20Android%20apps" id="wpa2a_8"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2010/09/08/optimization-techniques-for-air-for-android-apps/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>@includeExample</title>
		<link>http://www.unitedmindset.com/jonbcampos/2010/08/10/includeexample/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2010/08/10/includeexample/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 14:00:02 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[asdoc]]></category>
		<category><![CDATA[component creation]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[includeexample]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=1653</guid>
		<description><![CDATA[In my continuing quest to do everything I can to make components I make easier to understand and quicker to use, my most recent addition to my docs was to use @includeExample. Adding in @includeExample is super simple if you&#8217;ve been actively testing your component. There are a few things you may need to do [...]]]></description>
			<content:encoded><![CDATA[<p>In my continuing quest to do everything I can to make components I make easier to understand and quicker to use, my most recent addition to my docs was to use <em>@includeExample</em>.</p>
<p>Adding in <em>@includeExample</em> is super simple if you&#8217;ve been actively testing your component. There are a few things you may need to do to enable the examples inclusion but the process should only take a few moments to set up.</p>
<blockquote><p>
I have an <a href="https://bugs.adobe.com/jira/browse/FLEXDOCS-1302">open ASDoc Jira Bug</a> around this topic. The issue is that I want to see the example working in the asdoc but the current asdoc tool doesn&#8217;t actually make the SWFs and the embed information. It is partially there and commented out. I would like to see this completed.<br />
<a href="https://bugs.adobe.com/jira/browse/FLEXDOCS-1302">Link To Jira Bug &#8211; vote for it</a>
</p></blockquote>
<p><span id="more-1653"></span></p>
<p>To include your examples is simple.</p>
<p><strong>First, your need to duplicate your <em>src</em> directory.</strong> On the base directory add in a folder called <em>examples</em>. This is where your examples will go &#8211; in the same structure as your library classes.<br />
<img src="http://unitedmindset.com/jonbcampos/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-3.16.25-PM.png" alt="Directory Structure" title="Directory Structure" width="264" height="521" class="size-full wp-image-1857" /></p>
<p><strong>Second, you need to write your example.</strong> For my example I am building an example for my <a href="http://github.com/jonbcampos/UnitedMindsetFx4Library/blob/master/src/com/unitedmindset/components/AutocompleteList.as">AutocompleteList</a>.</p>
<p>The example:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>s:Application xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns:unitedmindset=<span style="color: #ff0000;">&quot;library://ns.unitedmindset.com&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;creationComplete=<span style="color: #ff0000;">&quot;application1_creationCompleteHandler(event)&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlexEvent</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> dataProvider:ArrayCollection;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> application1_creationCompleteHandler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> source:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Adult&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Aeroplane&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Air&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Aircraft Carrier&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Airforce&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Airport&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Album&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Alphabet&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Apple (is evil)&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Arm&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Army&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Baby&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Backpack&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Balloon&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Banana&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bank&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Barbecue&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bathroom&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bathtub&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bed&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bee&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bible&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bird&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bomb&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Book&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Boss&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bottle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bowl&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Box&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Boy&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Brain&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Bridge&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Butterfly&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Button&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Cappuccino&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Car&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Car-race&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Carpet&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Carrot&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Cave&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Chair&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Chess Board&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Chief&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Child&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Chisel&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Chocolates&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Church&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Circle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Circus&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Clock&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Clowns are scary&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Coffee&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Coffee-shop&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Comet&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Compact Disc&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Compass&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Computer&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Crystal&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Cup&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Cycle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Data Base&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Desk&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Diamond&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Dress&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Drill&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Drink&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Drum&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Dung&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Ears&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Earth&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Egg&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Electricity&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Elephant&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Eraser&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Explosive&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Eyes&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Family&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Fan&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Feather&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Festival&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Film&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Finger&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Fire&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Floodlight&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Flower&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Foot&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Fork&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Freeway&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Fruit&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Fungus&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Game&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Garden&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Gas&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Gate&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Gemstone&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Girl&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Gloves&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;God&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Grapes&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Guitar&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Hammer&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Hat&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Hieroglyph&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Highway&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Horoscope&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Horse&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Hose&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Ice&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Ice-cream&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Insect&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Jet fighter&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Junk&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Kaleidoscope&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Kitchen&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Knife&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Leather jacket&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Leg&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Library&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Liquid&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Magnet&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Man&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Map&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Maze&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Meat&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Meteor&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Microscope&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Milk&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Milkshake&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Mist&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Money $$$$&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Monster&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Mosquito&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Mouth&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Nail&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Navy&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Necklace&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Needle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Onion&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;PaintBrush&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Pants&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Parachute&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Passport&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Pebble&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Pendulum&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Pepper&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Perfume&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Pillow&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Plane&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Planet&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Pocket&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Post-office&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Potato&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Printer&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Prison&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Pyramid&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Radar&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Rainbow&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Record&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Restaurant&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Rifle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Ring&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Robot&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Rock&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Rocket&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Roof&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Room&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Rope&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Saddle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Salt&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sandpaper&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sandwich&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Satellite&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;School&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sex&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Ship&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Shoes&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Shop&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Shower&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Signature&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Skeleton&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Slave&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Snail&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Software&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Solid&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Space Shuttle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Spectrum&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sphere&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Spice&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Spiral&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Spoon&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sports-car&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Spot Light&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Square&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Staircase&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Star&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Stomach&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sun&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sunglasses&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Surveyor&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Swimming Pool&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Sword&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Table&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Tapestry&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Teeth&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Telescope&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Television&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Tennis racquet&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Thermometer&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Tiger&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Toilet&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Tongue&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Torch&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Torpedo&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Train&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Treadmill&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Triangle&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Tunnel&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Typewriter&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Umbrella&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Unitedmindset&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Vacuum&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Vampire&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Videotape&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Vulture&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Water&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Weapon&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Web&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Wheelchair&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Window&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Woman&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Worm&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;X-ray&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataProvider = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span>source<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>fx:Declarations<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span>-- Place non-visual elements <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">g</span>., services, value objects<span style="color: #66cc66;">&#41;</span> here --<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>fx:Declarations<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:layout<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:VerticalLayout paddingBottom=<span style="color: #ff0000;">&quot;20&quot;</span> paddingLeft=<span style="color: #ff0000;">&quot;20&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;20&quot;</span> paddingTop=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:layout<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>unitedmindset:AutocompleteList dataProvider=<span style="color: #ff0000;">&quot;{dataProvider}&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>s:Application<span style="color: #66cc66;">&gt;</span></div></div>
<p><strong>Thirdly, you need to specify that there is an example in the class level asdoc.</strong> All you need to do is give the name of the example file. Since the examples files are mirrored against the original classes the asdoc tool knows the folder structure to find the example.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&lt;/</span>pre<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*</span> <span style="color: #66cc66;">@</span>see com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">skins</span>.<span style="color: #006600;">AutocompleteListSkin</span>.<span style="color: #006600;">mxml</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*</span> <span style="color: #66cc66;">@</span>includeExample AutocompleteList.<span style="color: #006600;">mxml</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*</span> <span style="color: #66cc66;">@</span>author jonbcampos<br />
&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">*/</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AutocompleteList <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">List</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const COMPARELABEL_CHANGE_EVENT:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;compareLabelChange&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const COMPAREFUNCTION_CHANGE_EVENT:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;compareFunctionChange&quot;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> AutocompleteList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p><strong>- Optional &#8211; Adjust your compiler arguments.</strong> If for whatever reason your examples aren&#8217;t part of your project or live somewhere else you may need to add some arguments to your compiler. Specifically the <em>-examples-path</em>. By default the asdoc tool looks for the <em>examples</em> folder, but if you put the examples in a different folder just specify it as such:</p>
<p>Your folder is titled &#8220;myexamples&#8221; in the base directory, the compiler:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-examples-path myexamples</div></div>
<p>Or if your folder is at <em>c:/myexamples</em>, the compiler:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-examples-path c:/myexamples</div></div>
<p>The rest of the structure is matched for you.</p>
<p>And now your example is included with your asdocs page.<br />
<img src="http://unitedmindset.com/jonbcampos/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-3.32.46-PM-300x115.png" alt="Built Example" title="Built Example" width="300" height="115" class="size-medium wp-image-1864" /></p>
<blockquote><p>
Related Posts:<br />
<a href="http://unitedmindset.com/jonbcampos/2009/08/03/intellisense-making-your-components-work-with-the-flash-builder-ide/">Intellisense – Making your components work with the Flash Builder IDE</a><br />
<a href="http://unitedmindset.com/jonbcampos/2010/01/28/building-asdocs-with-ant/">Building ASDocs with ANT</a>
</p></blockquote>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2010%2F08%2F10%2Fincludeexample%2F&amp;title=%40includeExample" id="wpa2a_10"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2010/08/10/includeexample/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Practical Performance Tweaks</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/11/30/practical-performance-tweaks/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2009/11/30/practical-performance-tweaks/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 16:02:39 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[performance testing]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=1018</guid>
		<description><![CDATA[I&#8217;ve had a little bit of time on my hands in my day job *cough choke laugh* and thought I would spend some time doing some low level improvements on the performance of my applications. Though there were some changes I made that might have improved the performance of a function by a few milliseconds [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a little bit of time on my hands in my day job *cough choke laugh* and thought I would spend some time doing some low level improvements on the performance of my applications. Though there were some changes I made that might have improved the performance of a function by a few milliseconds on average there were a few things that I changed that made large improvements. These are the sorts of fixes that you commit to memory and just always keep them as time moves forward.</p>
<p>I&#8217;m not talking about making sure that you removeEventListeners and nullify unused objects for garbage collection, that is a given. These are common tweaks that people could use in every application but often we don&#8217;t because we suspect that the performance hit isn&#8217;t as big as it is. Here we will look at how big that hit actually is.<br />
<span id="more-1018"></span><br />
For all these tests I used <a href="http://www.gskinner.com/blog/archives/2009/04/as3_performance.html">Grant Skinner&#8217;s Performance Testing Harness</a>. The numbers for the tests are provided along with the source code and the test available to run. I slightly modified the Testing Harness so that I could also get the times and numbers out of each test for graphing purposes.</p>
<p><strong>Array vs ArrayCollection vs ICollectionView</strong><br />
These tests all started when I wondered how much slower iterating through an ArrayCollection was than iterating through an Array. The numbers were staggering. In some cases, iterating through the Array was <strong>1/50th</strong> of the time or <strong>5000% faster</strong>.</p>
<p>For my test I also was curious if using an interface instead of using the actual object made a difference. As you can see from the numbers that the difference wasn&#8217;t hugely significant, but actual.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.ArraysTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different array tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
findLastArray &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 81 &nbsp; &nbsp;16.20<br />
findLastArrayCollection &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4484 &nbsp; 896.80<br />
findLastICollectionView &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4405 &nbsp; 881.00<br />
findLastVector &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 106 &nbsp; &nbsp;21.20<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p>One rumor that I heard was that ArrayCollections are faster at finding a specific index value than Array&#8217;s due to some sort of magical optimization. So I tested that rumor also, below are the results. As you will see, this rumor is false. Arrays are faster at accessing a specific index value than ArrayCollections.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.ArraysTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different array tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
findObjectAtArray &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 64 &nbsp; &nbsp;12.80<br />
findObjectAtArrayCollectionOperand &nbsp; &nbsp; &nbsp; &nbsp;4200 &nbsp; 840.00<br />
findObjectAtArrayCollectionGetItemAt &nbsp; &nbsp; &nbsp;1700 &nbsp; 340.00<br />
findObjectAtICollectionView &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4151 &nbsp; 830.20<br />
findObjectAtVector &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;84 &nbsp; &nbsp;16.80<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p>Already there are additional tests I am thinking about running, but on the whole you can see that using the base Array over ArrayCollection will yield large performance improvements.</p>
<p>However, I again want to point out that whenever you set an Array as the dataProvider of a Flex component, Flex components convert Arrays to ArrayCollections. So don&#8217;t try to get a performance increase from a component specifically by setting the dataProvider as an Array, the Array will be transformed either way.</p>
<p><strong>Loops</strong><br />
The next section that I was going to test was the age old debate about the perfect loop: For Loops vs While Loops, iterating before the loop vs after the loop, etc etc. Luckily for me, as soon as I started looking at Grant&#8217;s testing harness, he had already created most of the test cases for me (Thanks). So the only extension to the test that I had to make was to also test against iterating before or after the loop (++i vs i++). The results can be seen below.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.LoopsTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different loop structures.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
forIncrementAfter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;439 &nbsp; &nbsp;87.80<br />
forDecrementAfter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;439 &nbsp; &nbsp;87.80<br />
forIncrementBefore &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 445 &nbsp; &nbsp;89.00<br />
forDecrementBefore &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 435 &nbsp; &nbsp;87.00<br />
*<br />
whileIncrementAfter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;647 &nbsp; 129.40<br />
whileDecrementAfter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;456 &nbsp; &nbsp;91.20<br />
whileIncrementBefore &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 649 &nbsp; 129.80<br />
whileDecrementBefore &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 456 &nbsp; &nbsp;91.20<br />
*<br />
doWhileIncrementAfter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;465 &nbsp; &nbsp;93.00<br />
doWhileDecrementAfter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;480 &nbsp; &nbsp;96.00<br />
doWhileIncrementBefore &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 483 &nbsp; &nbsp;96.60<br />
doWhileDecrementBefore &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 479 &nbsp; &nbsp;95.80<br />
*<br />
forIn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;623 &nbsp; 124.60<br />
forEachIn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;669 &nbsp; 133.80<br />
forEachInUntyped &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 647 &nbsp; 129.40<br />
forEachInPosttyped &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1255 &nbsp; 251.00<br />
*<br />
arrForEach &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1722 &nbsp; 344.40<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p>What you will probably notice is that no specific loop includes massive performance improvements, though the simple for loop seemed to be the fastest on average. So take your pick and run with it.</p>
<p><strong>Unrolled Loops</strong><br />
The next tests that I came up with was to see how efficient rolled vs unrolled loops were. The reason I felt this was important is there are times that we needlessly iterate through a loop when we know there will always be X number of elements. When this is a the case I&#8217;ve found (and the tests prove) that it is faster to just do what you need with the X elements rather than write a loop to iterate through the elements.</p>
<p>Remember to check the source to see the implementations of these different tests.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.LoopsTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different loop structures.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
rolledUpLoop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1585 &nbsp; 317.00<br />
unRolledLoop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 864 &nbsp; 172.80<br />
rolledUpLongLoop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1134 &nbsp; 226.80<br />
unRolledUpLongLoop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 803 &nbsp; 160.60<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Length Reference Variable</strong><br />
This is definitely a nit picky test, but I had to know the truth! When iterating through a loop is it significantly better to get a reference to the length of the loop, or is it okay just to use <em>array.length</em> in each iteration. As proven, using a variable to store the length is significantly better.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.LoopsTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different loop structures.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
lengthReferenceTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;512 &nbsp; 102.40<br />
noLengthReferenceTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;926 &nbsp; 185.20<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Reference Variables</strong><br />
When iterating through a loop I often like to pull a reference to the current value that is being evaluated in a loop. I do this mainly to make reading the code easier, but I was curious if this creation of a new reference would be harmful to performance. On top of that I was curious if giving these temporary variables a type was helpful for performance or not. Below are the results.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.LoopsTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different loop structures.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
noTemporaryLoopVariableUntyped &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1988 &nbsp; 397.60<br />
noTemporaryLoopVariableTyped &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1937 &nbsp; 387.40<br />
temporaryLoopVariableUntyped &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1849 &nbsp; 369.80<br />
temporaryLoopVariableTyped &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1897 &nbsp; 379.40<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p>As you can see I&#8217;ve figured that there isn&#8217;t a significant performance increase or loss with using temporary variables. I think I&#8217;ll keep using my temporary variables to make reading easier.</p>
<p><strong>Type, Cast and toX</strong><br />
The next series of tests are extremely geeky tests with some startling results. Is it faster to say <em>(object as String)</em> or <em>String(object)</em> or <em>object.toString</em>? This test case and many others are included below for each of the base types. May this help you decide how to type and cast your variables.</p>
<p>The big one to notice is the amount of time it takes to <em>String(number)</em> instead of saying <em>(number as String)</em>.</p>
<p>Included with each test is the control case of casting and typing each type to the same base type.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.TypesTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different type, casting, and manipulation tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
stringToString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;96 &nbsp; &nbsp;19.20<br />
stringCastString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;68 &nbsp; &nbsp;13.60<br />
stringAsString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;76 &nbsp; &nbsp;15.20<br />
objectStringToString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 153 &nbsp; &nbsp;30.60<br />
objectStringCastString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;70 &nbsp; &nbsp;14.00<br />
objectStringAsString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;78 &nbsp; &nbsp;15.60<br />
numberCastString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 888 &nbsp; 177.60<br />
numberAsString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 104 &nbsp; &nbsp;20.80<br />
intCastString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;229 &nbsp; &nbsp;45.80<br />
intAsString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 86 &nbsp; &nbsp;17.20<br />
uIntCastString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 229 &nbsp; &nbsp;45.80<br />
uIntAsString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;86 &nbsp; &nbsp;17.20<br />
*<br />
numberCastNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;46 &nbsp; &nbsp; 9.20<br />
numberAsNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 103 &nbsp; &nbsp;20.60<br />
objectNumberCastNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;50 &nbsp; &nbsp;10.00<br />
objectNumberAsNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;81 &nbsp; &nbsp;16.20<br />
intCastNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 46 &nbsp; &nbsp; 9.20<br />
intAsNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 84 &nbsp; &nbsp;16.80<br />
uIntCastNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;46 &nbsp; &nbsp; 9.20<br />
uIntAsNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;86 &nbsp; &nbsp;17.20<br />
stringCastNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;76 &nbsp; &nbsp;15.20<br />
stringAsNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;84 &nbsp; &nbsp;16.80<br />
*<br />
uintCastUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;45 &nbsp; &nbsp; 9.00<br />
uintAsUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;86 &nbsp; &nbsp;17.20<br />
objectUintCastUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;48 &nbsp; &nbsp; 9.60<br />
objectUintAsUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;82 &nbsp; &nbsp;16.40<br />
numberCastUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;47 &nbsp; &nbsp; 9.40<br />
numberAsUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 113 &nbsp; &nbsp;22.60<br />
intCastUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 45 &nbsp; &nbsp; 9.00<br />
intAsUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 84 &nbsp; &nbsp;16.80<br />
stringCastUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;82 &nbsp; &nbsp;16.40<br />
stringAsUint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;90 &nbsp; &nbsp;18.00<br />
*<br />
intCastInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;46 &nbsp; &nbsp; 9.20<br />
intAsInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;82 &nbsp; &nbsp;16.40<br />
objectIntCastInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;48 &nbsp; &nbsp; 9.60<br />
objectIntAsInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;80 &nbsp; &nbsp;16.00<br />
numberCastInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 47 &nbsp; &nbsp; 9.40<br />
numberAsInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;106 &nbsp; &nbsp;21.20<br />
uintCastInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 46 &nbsp; &nbsp; 9.20<br />
uintAsInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 86 &nbsp; &nbsp;17.20<br />
stringCastInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 77 &nbsp; &nbsp;15.40<br />
stringAsInt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 88 &nbsp; &nbsp;17.60<br />
*<br />
arrayAsArray &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;77 &nbsp; &nbsp;15.40<br />
objectArrayAsArray &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;81 &nbsp; &nbsp;16.20<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<blockquote><p>Remember when using &#8220;as&#8221;, if the conversion fails, you will receive a null rather than the value. Unless you explicitly know what the type will be, it is always good to make this check.</p></blockquote>
<p><strong>The &#8220;new&#8221; operator</strong><br />
I&#8217;ve always been told that when creating a new base type that you should use the value rather than <em>new</em> because it saves the need for the VM to allocate the memory in the heap. But what was the ACTUAL performance improvements. Again, the numbers are staggering. For the next tests I created each of the simple types 3 different ways.</p>
<p>The first way I used the <em>new</em> operator as such: var s:String = new String();<br />
The second way I used the new value as such: var s:String = &#8220;&#8221;;<br />
And the final test was to create the variable with the <em>new</em> operator without the final parenthesis, such as: var s:String = new String;</p>
<p>For every test setting the value rather than using the <em>new</em> operator was almost twice as fast. The biggest difference being with creating a new Array, using the <em>[]</em> operand instead of the <em>new</em> operator was almost 3 times as fast.</p>
<p>I should also point out that for almost each test, using the parenthesis was slower than leaving them off when creating a new variable, though this is considered bad practice. Though the difference was marginal.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.TypesTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different type, casting, and manipulation tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
newUintTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 75 &nbsp; &nbsp;15.00<br />
newUintValueTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;44 &nbsp; &nbsp; 8.80<br />
newUintTestNoParams &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 76 &nbsp; &nbsp;15.20<br />
*<br />
newIntTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;75 &nbsp; &nbsp;15.00<br />
newIntValueTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 45 &nbsp; &nbsp; 9.00<br />
newIntTestNoParams &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;74 &nbsp; &nbsp;14.80<br />
*<br />
newNumberTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 72 &nbsp; &nbsp;14.40<br />
newNumberValueTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;45 &nbsp; &nbsp; 9.00<br />
newNumberTestNoParams &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 75 &nbsp; &nbsp;15.00<br />
*<br />
newStringTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 71 &nbsp; &nbsp;14.20<br />
newStringValueTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;45 &nbsp; &nbsp; 9.00<br />
newStringTestNoParams &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 74 &nbsp; &nbsp;14.80<br />
*<br />
newArrayTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 711 &nbsp; 142.20<br />
newArrayValueTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;249 &nbsp; &nbsp;49.80<br />
newArrayTestNoParams &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 709 &nbsp; 141.80<br />
*<br />
newObjectTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;267 &nbsp; &nbsp;53.40<br />
newObjectValueTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 230 &nbsp; &nbsp;46.00<br />
newObjectTestNoParams &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;263 &nbsp; &nbsp;52.60<br />
*<br />
newXMLTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1032 &nbsp; 206.40<br />
newXMLValueTest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1023 &nbsp; 204.60<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Static Methods vs Class Methods</strong><br />
As a side curiosity I was wanted to know if there was any performance loss or gain based on the types of functions used within a class. I was able to see that there weren&#8217;t any significant performance improvements over one type of function or another. So stick with best practices within your classes and only make methods and properties public when they absolutely have to be.</p>
<p>This test does not include testing whether creating the class and then accessing the function is better than a static function which does not need to instantiate a class.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.ClassTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different class method tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
publicMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 141 &nbsp; &nbsp;28.20<br />
privateMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;143 &nbsp; &nbsp;28.60<br />
protectedMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;144 &nbsp; &nbsp;28.80<br />
publicStaticMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 141 &nbsp; &nbsp;28.20<br />
privateStaticMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;142 &nbsp; &nbsp;28.40<br />
protectedStaticMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;141 &nbsp; &nbsp;28.20<br />
publicInternalMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 142 &nbsp; &nbsp;28.40<br />
publicFinalMethod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;144 &nbsp; &nbsp;28.80<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Using &#8220;this&#8221; and Other Class Curiosities</strong><br />
This next section includes many different tests to improve my class creation.</p>
<p><strong>Setting the default values</strong><br />
In this test I was curious if it is better to initially set a variable in the constructor or at the variable, and also if setting the variable defaults inside the class vs outside the class was better. What I found is that it is faster to initially just set the variables to their default value rather than making this change in the constructor.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.VariablesTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different variables and vo based tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
defaultVarsSetVO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 400 &nbsp; &nbsp;80.00<br />
varsSetInConstructorVO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 490 &nbsp; &nbsp;98.00<br />
varsSetOutsideConstructorThisVO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;499 &nbsp; &nbsp;99.80<br />
varsSetOutsideConstructorNoThisVO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;496 &nbsp; &nbsp;99.20<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Is using &#8220;this&#8221; wrong?</strong><br />
Checking whether it was faster to use the &#8220;this&#8221; identifier was harmful to performance I concluded that there was no significant performance loss or gain in using the &#8220;this&#8221; identifier.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.VariablesTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different variables and vo based tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
thisToString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2395 &nbsp; 479.00<br />
noThisToString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2441 &nbsp; 488.20<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Getters and Setters vs Direct Accessors</strong><br />
Lots of good ole&#8217; boy Java developers will tell you that every property has to have a getter and setter. Other programmers will say that this is only necessary if there is some logic that needs to run in the get/set process. Now you can see that by using a getter/setter when a direct accessor can be used is wasteful for performance and typing. Therefore, only create getters/setters when it is important to run some logic in the getting/setting process.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.VariablesTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different variables and vo based tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
noGetSetAccessors &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2382 &nbsp; 476.40<br />
getSetAccessors &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2786 &nbsp; 557.20<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Size really doesn&#8217;t matter&#8230; in variables.</strong><br />
Finally, the stigma from writing Javascript applications always left me feeling guilty about using full words when a letter can do. In Javascript this was a performance issue and caused many programmers to use single incomprehensible letters instead of easy to read words. To elevate my guilt I decided to test if using long variable names made any difference at runtime. The answer is no. No savings, no loss. Now, guilt free, I will always use well written variable names instead of short single letter descriptors.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.VariablesTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different variables and vo based tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
shortVarNames &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 45 &nbsp; &nbsp; 9.00<br />
longVarNames &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;45 &nbsp; &nbsp; 9.00<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>If..Then vs Switch..Case</strong><br />
Like loops, developers argue which logical test is better: <em>if..then</em> vs <em>switch..case</em>. Pitting the two against each other, apples vs apples, I&#8217;ve found that <em>if..then</em> statements are slightly faster than <em>switch..case</em> statements. I will still use each statement where appropriate though, but it is good to know in the situations that I have the choice that I should use <em>if..then</em> statements.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.LogicalTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different logical structure tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
switchCaseStatement &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;411 &nbsp; &nbsp;82.20<br />
ifThenElseStatement &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;378 &nbsp; &nbsp;75.60<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Math.max() vs Math.max.apply()</strong><br />
One little known secret to AS3 is the apply method. Most classes have more than one way to skin a cat, and the apply method is that function. In the case of <em>Math.max</em> (or <em>Math.min</em>) I was curious how much faster the apply method was vs logically finding the largest (or smallest) value. The numbers were staggering. From now on I will be using the apply method whenever possible as it is a very low level and fast function.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
com.unitedmindset.tests.ApplyTest (5 iterations)<br />
Player version: MAC 10,0,32,18 (debug)<br />
Test different apply method tests.<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––<br />
method..................................ttl ms...avg ms<br />
findMaxLogically &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2093 &nbsp; 418.60<br />
findMaxApply &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 131 &nbsp; &nbsp;26.20<br />
–––––––––––––––––––––––––––––––––––––––––––––––––––––––</div></div>
<p><strong>Final Thoughts</strong><br />
Obviously the things in this list I see as some of the greatest offenders and also the easiest to fix. It all comes down to you and which changes you feel comfortable making in your daily coding practices. Some of the more &#8220;nit picky&#8221; performance changes I feel can effect code readability and reusability, and which you implement into your code is up to you and your coding practices. Hopefully this ends the debate between some techniques as being the end all be all technique.</p>
<p>If there are other coding techniques that have left you wondering which is better, let me know and I&#8217;ll add it in. I&#8217;m sure over time I&#8217;ll revisit these test cases.</p>
<p><strong>The Test, Run It For Yourself Or View Source</strong><br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="800" height="650">
      <param name="movie" value="http://unitedmindset.com/jonbcampos/wp-content/flex_content/performance/PerformanceApp.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://unitedmindset.com/jonbcampos/wp-content/flex_content/performance/PerformanceApp.swf" width="800" height="650">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
<br />
<a href="http://unitedmindset.com/jonbcampos/wp-content/flex_content/performance/srcview/index.html">View Source</a> (or right click swf)</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2009%2F11%2F30%2Fpractical-performance-tweaks%2F&amp;title=Practical%20Performance%20Tweaks" id="wpa2a_12"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2009/11/30/practical-performance-tweaks/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Getting Through Black Magic: Font Embedding</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/11/24/getting-through-black-magic-font-embedding/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2009/11/24/getting-through-black-magic-font-embedding/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 15:59:40 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[font embedding]]></category>
		<category><![CDATA[unicode ranges]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=1022</guid>
		<description><![CDATA[Be it in Fx2, Fx3 or Fx4, Font Embedding is an integral part of any application due to the annoying issues you will start running into by just using device fonts. And once you get your embedded font into the application you&#8217;ll never look back at the issue, but getting the embedded font into the [...]]]></description>
			<content:encoded><![CDATA[<p>Be it in Fx2, Fx3 or Fx4, Font Embedding is an integral part of any application due to the annoying issues you will start running into by just using device fonts. And once you get your embedded font into the application you&#8217;ll never look back at the issue, but getting the embedded font into the application seems bring some developers to their knees.</p>
<p>There are two main ways that I see people embed fonts.</p>
<p>1) Straight @font-face embed via Flex CSS<br />
2) Embedding the font into a Flash File, selecting the glyphs to embed, and then embedding the resulting SWF into Flex.</p>
<p>People use the first one for simplicity and the second (definitely more difficult route) for optimization. Yet people keep forgetting (or never knew) that there is a third route that provides simplicity and optimization.<br />
<span id="more-1022"></span><br />
<strong>First, the basics&#8230;</strong><br />
In your Flex CSS file (or in the style block) start up a new font face block.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Next provide a direct path from your application&#8217;s root folder to the font. For ease I usually make a copy of the font and stick it in my assets folder so that other people connected to my project can still build the app.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdana.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Now name the new font-face so it can be referenced as a font family.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdana.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Next you need to add some description to the font. Is it a normal font?</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdana.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: normal;<br />
&nbsp; &nbsp; &nbsp;fontWeight: normal;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><strong>Bold</strong>?</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdanab.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: normal;<br />
&nbsp; &nbsp; &nbsp;fontWeight: <span style="color: #0066CC;">bold</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><em>Italic</em>?</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdanai.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: <span style="color: #0066CC;">italic</span>;<br />
&nbsp; &nbsp; &nbsp;fontWeight: normal;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><em><strong>Bold and Italic?</strong></em></p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdanaz.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: <span style="color: #0066CC;">italic</span>;<br />
&nbsp; &nbsp; &nbsp;fontWeight: <span style="color: #0066CC;">bold</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>To have all four of these options you would need to embed each of the different fonts that include all these options. They can all be under the same fontFamily name, but with different configurations. But if you are missing the <strong>bold</strong> font and trying to make your text <strong>bold</strong> you will not be getting the desired look.</p>
<p>If you are confused at all by the different @font-face blocks below make sure to look at the actually font file name. You will notice each is just slightly different with the different look.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdana.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: normal;<br />
&nbsp; &nbsp; &nbsp;fontWeight: normal;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdanab.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: normal;<br />
&nbsp; &nbsp; &nbsp;fontWeight: <span style="color: #0066CC;">bold</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdanai.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: <span style="color: #0066CC;">italic</span>;<br />
&nbsp; &nbsp; &nbsp;fontWeight: normal;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdanaz.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: <span style="color: #0066CC;">italic</span>;<br />
&nbsp; &nbsp; &nbsp;fontWeight: <span style="color: #0066CC;">bold</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Next you need to set whether your font is using advanced anti aliasing. This takes slightly more processing, but can make your fonts look nicer at larger sizes. This is dependent also on whether the font type supports it. Usually, I just set this to <em>true</em>.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdana.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: normal;<br />
&nbsp; &nbsp; &nbsp;fontWeight: normal;<br />
&nbsp; &nbsp; &nbsp;advancedAntiAliasing: <span style="color: #000000; font-weight: bold;">true</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Now with Fx4 you have something new to worry about: CFF. If this is set to true, the font will be available to the new TLF engine and Fx4 (Spark) components. If CFF is set to false then it will be available to Fx3 (Halo) components. Yes, right now you need to embed two fonts to get this to work for both. In the future this may change.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdana.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: normal;<br />
&nbsp; &nbsp; &nbsp;fontWeight: normal;<br />
&nbsp; &nbsp; &nbsp;advancedAntiAliasing: <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp;cff: <span style="color: #000000; font-weight: bold;">true</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><strong>And now, the optimization&#8230;</strong><br />
You may have hit some issues with all the previous steps, or not &#8211; but here is the optimizations. Within the @font-face tag you can set which unicode characters to embed &#8211; this is like selecting the glyphs in Flash. To find a helpful table of common unicode characters and ranges that people use refer back to your flex sdk, specifically: <em>flex-sdk-folder</em>/frameworks/flash-unicode-table.xml. After looking through the table you can select your desired ranges that you want included with the font embed. The more unicode characters the larger the final SWF file will be, the fewer, the smaller.<br />
My final @font-face embed statement.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">@</span>font-face <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;src: <span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/assets/fonts/verdana.ttf&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;fontFamily: verdanaEmbed;<br />
&nbsp; &nbsp; &nbsp;fontStyle: normal;<br />
&nbsp; &nbsp; &nbsp;fontWeight: normal;<br />
&nbsp; &nbsp; &nbsp;advancedAntiAliasing: <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp;cff: <span style="color: #000000; font-weight: bold;">true</span><br />
&nbsp; &nbsp; &nbsp;unicodeRange:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;U+0041-U+005A, <span style="color: #808080; font-style: italic;">/* Upper-Case [A..Z] */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;U+0061-U+007A, <span style="color: #808080; font-style: italic;">/* Lower-Case a-z */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;U+0030-U+0039, <span style="color: #808080; font-style: italic;">/* Numbers [0..9] */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;U+0020-U+002F,U+003A-U+0040,U+005B-U+0060,U+007B-U+007E; <span style="color: #808080; font-style: italic;">/* Puctuation */</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><strong>Profit!</strong><br />
That&#8217;s it, embedded and optimized fonts. I&#8217;ve actually tested the size of the resulting Flex App SWF files after going the long route and the route shown here. Both resulting sizes are exactly the same, down to the last byte.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2009%2F11%2F24%2Fgetting-through-black-magic-font-embedding%2F&amp;title=Getting%20Through%20Black%20Magic%3A%20Font%20Embedding" id="wpa2a_14"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2009/11/24/getting-through-black-magic-font-embedding/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Lockable List and Tree</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/10/23/lockable-list-and-tree/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2009/10/23/lockable-list-and-tree/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 15:05:04 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[custom component development]]></category>
		<category><![CDATA[custom components]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=892</guid>
		<description><![CDATA[Anyone that knows me knows that I like making little test cases and components. Before I start showing off some of my custom spark components I wanted to make sure and share this custom component that I call the Lockable List. But, as every developer knows, when you have a list it is almost assured [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone that knows me knows that I like making little test cases and components. Before I start showing off some of my custom spark components I wanted to make sure and share this custom component that I call the <em>Lockable Lis</em>t. But, as every developer knows, when you have a list it is almost assured that you will need a tree. So I followed up with the list and built the <em>Lockable Tree</em>.<br />
<span id="more-892"></span><br />
I have left the source code and everything available for these components, but wanted to draw people&#8217;s attention to the itemrenderers here. This is where the real magic is. Yes there is some functionality to List and Tree components that I have added, but the item renderers are really what make things possible. The List and Tree mainly add a wrapper to the data that is set (so the itemrenderers can work off the data provided) and retreive the data back in it&#8217;s original manner. Pretty simple.</p>
<p>The itemrenderers are nice. Lightweight. Definitely check out the itemrenderer&#8217;s code. Very simple.</p>
<p>What these components do is &#8220;hold&#8221; or &#8220;lock&#8221; a selection. In these examples you may say &#8220;well that is similar to shift/ctrl select&#8221;. Yes and no. If you need to hold nodes that may become difficult in large lists and in my apps I do lots of list filtering and sorting, so now I can filter for a specific node AND keep locked nodes. Very helpful.</p>
<p>Special thank you to <a href="http://blog.killerspaz.com/">John Gorena</a> who already pointed out that this is something helpful for mobile development. Enjoy!</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_1" width="500" height="400" align="none">
      <param name="movie" value="http://unitedmindset.com/jonbcampos/wp-content/uploads/2009/10/LockableListApp.swf" />
      <param name="align" value="none" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://unitedmindset.com/jonbcampos/wp-content/uploads/2009/10/LockableListApp.swf" width="500" height="400" align="none">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>


    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_2" width="500" height="400" align="none">
      <param name="movie" value="http://unitedmindset.com/jonbcampos/wp-content/uploads/2009/10/LockableTreeApp.swf" />
      <param name="align" value="none" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://unitedmindset.com/jonbcampos/wp-content/uploads/2009/10/LockableTreeApp.swf" width="500" height="400" align="none">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2009%2F10%2F23%2Flockable-list-and-tree%2F&amp;title=Lockable%20List%20and%20Tree" id="wpa2a_16"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2009/10/23/lockable-list-and-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAX Presentation &#8211; Tackling Memory &amp; Performance in Flash, Flex, and AIR</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/10/08/max-presentation-tackling-memory-performance-in-flash-flex-and-air/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2009/10/08/max-presentation-tackling-memory-performance-in-flash-flex-and-air/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 22:44:21 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[max09]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=777</guid>
		<description><![CDATA[Let&#8217;s start by saying thank you to everyone that attended my MAX presentation: Tackling Memory &#038; Performance with Flash, Flex, and AIR. This presentation was made possible by a joint effort of Jun Heider and myself. Below is a link to the Adobe.Tv recording of this presentation. This was a presentation that almost wasn&#8217;t though. [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s start by saying thank you to everyone that attended my MAX presentation: Tackling Memory &#038; Performance with Flash, Flex, and AIR. This presentation was made possible by a joint effort of <a href="http://iheartair.com/">Jun Heider</a> and myself. Below is a link to the Adobe.Tv recording of this presentation.</p>
<p><object width="425" height="256"><param name="movie" value="http://images.tv.adobe.com//swf/player.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="FlashVars" value="fileID=2445&#038;context=162&#038;embeded=true&#038;environment=production"></param><embed src="http://images.tv.adobe.com//swf/player.swf" flashvars="fileID=2445&#038;context=162&#038;embeded=true&#038;environment=production" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="256"></embed></object><br />
<span id="more-777"></span><br />
This was a presentation that almost wasn&#8217;t though. For those who don&#8217;t know, this presentation was originally planned to be presented by <a href="http://craftymind.com">Sean Chistmann</a> of EffectiveUI, yet as he fell sick Adobe called Jun and myself to fill in the gap. Working closely with Jun and Sean (when available) we added our own personal touches to the presentation and presented on Tuesday and Wednesday of Max. Again, thank you to everyone that attended either of the sessions and all the great feedback we received.</p>
<p><a href='http://unitedmindset.com/jonbcampos/wp-content/uploads/2009/10/tacklingmemoryandperformance.pdf'>Tackling Memory and Performance in Flash, Flex, and AIR</a><br />
<a href='http://unitedmindset.com/jonbcampos/wp-content/uploads/2009/10/archive.zip'>Presentation Source Files</a></p>
<p>Below is a list of helpful resources for continued education in this subject:</p>
<p><strong>Livedocs</strong></p>
<ul>
<li><a href="http://livedocs.adobe.com/flex/gumbo/html/WS6f97d7caa66ef6eb1e63e3d11b6c4d0169-8000.html">http://livedocs.adobe.com/flex/gumbo/html/WS6f97d7caa66ef6eb1e63e3d11b6c4d0169-8000.html</a></li>
<li><a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/sampler/package-detail.html">http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/sampler/package-detail.html</a></li>
</ul>
<p><strong>Flex Profiler and flash.sampler.* classes:</strong></p>
<ul>
<li><a href="http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html">http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html</a></li>
<li><a href="http://www.slideshare.net/srp1970/overview-of-flex-profiler/">http://www.slideshare.net/srp1970/overview-of-flex-profiler/</a></li>
<li><a href="http://lists.motion-twin.com/pipermail/haxe/2007-August/011362.html">http://lists.motion-twin.com/pipermail/haxe/2007-August/011362.html</a></li>
<li><a href="http://www.jinten.net/blog/archives/47">http://www.jinten.net/blog/archives/47</a></li>
<li><a href="http://ticore.blogspot.com/2008/05/as3-observe-object-size.html">http://ticore.blogspot.com/2008/05/as3-observe-object-size.html</a></li>
<li><a href="http://www.insideria.com/2008/06/profiling-flex-applications-sa.html">http://www.insideria.com/2008/06/profiling-flex-applications-sa.html</a></li>
<li><a href="http://stopcoding.wordpress.com/2008/04/26/lets-talk-about-the-flex-profiler/">http://stopcoding.wordpress.com/2008/04/26/lets-talk-about-the-flex-profiler/</a></li>
</ul>
<p><strong>AVM2 and MMgc:</strong></p>
<ul>
<li><a href="http://www.adobe.com/devnet/actionscript/articles/avm2overview.pdf" class="broken_link">http://www.adobe.com/devnet/actionscript/articles/avm2overview.pdf</a></li>
<li><a href="http://developer.mozilla.org/en/docs/MMgc">http://developer.mozilla.org/en/docs/MMgc</a></li>
<li><a href="http://www.gskinner.com/blog/archives/2006/09/garbage_collect.html">http://www.gskinner.com/blog/archives/2006/09/garbage_collect.html</a></li>
</ul>
<p><strong>Performance and Memory Management:</strong></p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Performance_analysis">http://en.wikipedia.org/wiki/Performance_analysis</a></li>
<li><a href="http://en.wikipedia.org/wiki/Memory_management">http://en.wikipedia.org/wiki/Memory_management</a></li>
<li><a href="http://www.adobe.com/devnet/flashplayer/articles/resource_management.html">http://www.adobe.com/devnet/flashplayer/articles/resource_management.html</a></li>
<li><a href="http://www.slideshare.net/dcoletta/optimizing-flex-applications/">http://www.slideshare.net/dcoletta/optimizing-flex-applications/</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/as3_tuning.html" class="broken_link">http://www.adobe.com/devnet/flex/articles/as3_tuning.html</a></li>
<li><a href="http://adobedev.adobe.acrobat.com/p71169528/">http://adobedev.adobe.acrobat.com/p71169528/</a></li>
<li><a href="http://www.insideria.com/jun-heider/">http://www.insideria.com/jun-heider/</a></li>
<li><a href="http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html">http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html</a></li>
<li><a href="http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html">http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html</a></li>
<li><a href="http://www.moock.org/blog/archives/000223.html">http://www.moock.org/blog/archives/000223.html</a></li>
<li><a href="http://blog.flexmonkeypatches.com/2007/03/28/flash-player-memory-management-and-garbagecollection-redux-2/" class="broken_link">http://blog.flexmonkeypatches.com/2007/03/28/flash-player-memory-management-and-garbagecollection-redux-2/</a></li>
<li><a href="http://olegfilipchuk.com/2009/07/24/unload-you-module/">http://olegfilipchuk.com/2009/07/24/unload-you-module/</a></li>
<li><a href="http://www.colettas.org/?p=115">http://www.colettas.org/?p=115</a></li>
</ul>
<p><strong>Data Transfer and Performance:</strong></p>
<ul>
<li><a href="http://www.jamesward.org/census">http://www.jamesward.org/census</a></li>
</ul>
<p><strong>Elastic Racetrack:</strong></p>
<ul>
<li><a href="http://www.onflex.org/ted/2005/07/flash-player-mental-model-elastic.php">http://www.onflex.org/ted/2005/07/flash-player-mental-model-elastic.php</a></li>
<li><a href="http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/">http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/</a></li>
</ul>
<p><strong>AIR/Flash Player Mac Idle CPU:</strong></p>
<ul>
<li><a href="http://www.gskinner.com/blog/archives/2009/05/idle_cpu_usage.html">http://www.gskinner.com/blog/archives/2009/05/idle_cpu_usage.html</a></li>
<li><a href="http://blogs.adobe.com/air/2009/05/performance_tips_for_adobe_air.html">http://blogs.adobe.com/air/2009/05/performance_tips_for_adobe_air.html</a></li>
</ul>
<p>Flexcoders:</p>
<ul>
<li><a href="http://www.mail-archive.com/flexcoders@yahoogroups.com/msg86385.html">http://www.mail-archive.com/flexcoders@yahoogroups.com/msg86385.html</a></li>
<li><a href="http://www.mail-archive.com/flexcoders@yahoogroups.com/msg83781.html">http://www.mail-archive.com/flexcoders@yahoogroups.com/msg83781.html</a></li>
<li><a href="http://www.mail-archive.com/flexcoders@yahoogroups.com/msg95073.html">http://www.mail-archive.com/flexcoders@yahoogroups.com/msg95073.html</a></li>
<li><a href="http://www.mail-archive.com/flexcoders@yahoogroups.com/msg92116.html">http://www.mail-archive.com/flexcoders@yahoogroups.com/msg92116.html</a></li>
<li><a href="http://www.mail-archive.com/flexcoders@yahoogroups.com/msg86738.html">http://www.mail-archive.com/flexcoders@yahoogroups.com/msg86738.html</a></li>
</ul>
<p><strong>Adobe Bugbase (Please vote for these bugs!):</strong></p>
<ul>
<li><a href="http://bugs.adobe.com/jira/browse/SDK-15731">http://bugs.adobe.com/jira/browse/SDK-15731</a></li>
<li><a href="https://bugs.adobe.com/jira/browse/SDK-14820">https://bugs.adobe.com/jira/browse/SDK-14820</a></li>
<li><a href="https://bugs.adobe.com/jira/browse/FP-2009">https://bugs.adobe.com/jira/browse/FP-2009</a></li>
<li><a href="https://bugs.adobe.com/jira/browse/SDK-14781">https://bugs.adobe.com/jira/browse/SDK-14781</a></li>
</ul>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2009%2F10%2F08%2Fmax-presentation-tackling-memory-performance-in-flash-flex-and-air%2F&amp;title=MAX%20Presentation%20%26%238211%3B%20Tackling%20Memory%20%26amp%3B%20Performance%20in%20Flash%2C%20Flex%2C%20and%20AIR" id="wpa2a_18"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2009/10/08/max-presentation-tackling-memory-performance-in-flash-flex-and-air/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Flex Best Practices &#8211; Models, Views, and Controllers</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/08/18/flex-best-practices-models-views-and-controllers/</link>
		<comments>http://www.unitedmindset.com/jonbcampos/2009/08/18/flex-best-practices-models-views-and-controllers/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 13:34:00 +0000</pubDate>
		<dc:creator>jonbcampos</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[controllers]]></category>
		<category><![CDATA[data models]]></category>
		<category><![CDATA[event dispatcher]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[Special Events]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=677</guid>
		<description><![CDATA[If you read through this entire post and don&#8217;t see anything for you, congrats and ignore this next comment. No one seems to know how to actually implement MVC and I can&#8217;t stand it! Too many programs out there set up like a procedural php page (front top to bottom): imports, sql statements, data, methods, [...]]]></description>
			<content:encoded><![CDATA[<p>If you read through this entire post and don&#8217;t see anything for you, congrats and ignore this next comment.</p>
<p><strong>No one seems to know how to actually implement MVC and I can&#8217;t stand it!</strong></p>
<p>Too many programs out there set up like a procedural php page (front top to bottom): imports, sql statements, data, methods, and a ton of html. This is not how to set up a page, and even more so this isn&#8217;t how you set up an entire application! But people do it, don&#8217;t ask me how or why, but it&#8217;s a mess.</p>
<blockquote><p>
I want to let everyone know that the following &#8220;worst practice&#8221; example is actual code shown to me very recently. I simplified it a bit but ultimately the Flex application was one large mxml file.
</p></blockquote>
<p>You may try to argue that MVC takes more time to setup, more coding, &#8220;harder to read&#8221;, or whatever other arguments I have heard, but in the end it is easier to program, loosely coupled, simplistic, <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself" target="_blank">dry</a>, object oriented,  and finally <strong>best practice</strong>.<br />
<span id="more-677"></span><br />
If your code looks like this, you are doing it wrong! <strong>(Worst Practice)</strong></p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>s:Application xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><br />
&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><br />
&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span><br />
&nbsp; &nbsp; creationComplete=<span style="color: #ff0000;">&quot;application1_creationCompleteHandler(event)&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FaultEvent</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlexEvent</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> searchList:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> application1_creationCompleteHandler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; runSearch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> runSearch<span style="color: #66cc66;">&#40;</span>event:MouseEvent=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; httpService.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>searchTerm:searchInput.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> httpService_resultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; searchList = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span> event.<span style="color: #006600;">result</span> as <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> httpService_faultHandler<span style="color: #66cc66;">&#40;</span>event:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; searchList = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;fault&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>fx:Declarations<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:HTTPService id=<span style="color: #ff0000;">&quot;httpService&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result=<span style="color: #ff0000;">&quot;httpService_resultHandler(event)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fault=<span style="color: #ff0000;">&quot;httpService_faultHandler(event)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resultFormat=<span style="color: #ff0000;">&quot;e4x&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">&quot;http://www.someUrl.com/yourMethod&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>fx:Declarations<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:layout<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:VerticalLayout gap=<span style="color: #ff0000;">&quot;20&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;20&quot;</span> paddingLeft=<span style="color: #ff0000;">&quot;20&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;20&quot;</span> paddingTop=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:layout<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:HGroup <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Search Term&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:TextInput <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> id=<span style="color: #ff0000;">&quot;searchInput&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Do It!&quot;</span> click=<span style="color: #ff0000;">&quot;runSearch(event)&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:HGroup<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:<span style="color: #0066CC;">List</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>s:Application<span style="color: #66cc66;">&gt;</span></div></div>
<blockquote><p>This is an extremely simple example and honestly if this is all that your application needed to do then you are done. If your application is more complicated &#8211; or will get more complicated than this example &#8211; then this will fall apart real fast. <em>On top of that</em> good luck being able to unit test this code, reuse any of this code, using object oriented designs such as factories or even just interfaces, or even using the outliner view to find specific methods. Our final MVC application will be able to do all these things.</p></blockquote>
<p><strong>Quick Look At MVC</strong><br />
MVC is a simple concept that is immensely helpful at simplifying application development. The concept is just to split up your application by it&#8217;s model (the data), the view (what is seen), and the controller (the methods and functions that move the data from the view to the model and back).<br />
<a href="http://en.wikipedia.org/wiki/Model–view–controller" target="_blank">Wikipedia &#8211; MVC</a></p>
<p><strong>Understanding The Model</strong><br />
The models are your data centers for the application and extremely simple. In actionscript when you create models, this is the exact time you will want to use getters and setters for your properties. Why? Because the model just holds data and when the model has changed, it releases events to alert anything listening that the model has changed.</p>
<p><strong>Best Practices:</strong> All of the properties in your model should have setters and extend the EventDispatcher to be able to send out events when the model has changed. You can see what I mean in my model code below. You could always use custom events to send let your application know of property changes, but for my example I will just use the basic Event class. It is also <em>Best Practice</em> to check that the property has actually changed before sending out events and updating the value. Double check that the variable has actually changed first. Very easy with strings and numbers and such, a bit more effort for larger complex objects.</p>
<p><strong>Refactoring Your Code To The Model</strong><br />
For our example the model is EXTREMELY simple due to only one property, but you can see how simple the model is and how well it separates and simplifies the application layout. Finally you can now reuse this model in multiple controllers.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">models</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">EventDispatcher</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">IEventDispatcher</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Event<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;searchListChanged&quot;</span>,<span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;flash.events.Event&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SampleModel <span style="color: #0066CC;">extends</span> EventDispatcher<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const SEARCH_LIST_CHANGED:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;searchListChanged&quot;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SampleModel<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>:IEventDispatcher=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _searchList:<span style="color: #0066CC;">Array</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> searchList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _searchList;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> searchList<span style="color: #66cc66;">&#40;</span>v:<span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _searchList = v;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span>SEARCH_LIST_CHANGED<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p><strong>Understanding The Controller</strong><br />
Controllers are nothing more than a class that contains methods to move data back and forth from the data, update and handle responses from the view. I touched on this earlier but by separating this code into it&#8217;s own class you can have interfaces, subclasses, use unit testing on individual methods, and finally use the outline to jump to specific methods. Basically, everything that will help you grow as a developer as you make bullet proof applications.</p>
<p><strong>Best Practices:</strong> The controller includes whatever methods are necessary and a reference to the view. The methods/handlers that are required by the view will always be public, everything else is private or protected. All events handlers should be in the controller and then the controller modifies the model and/or changes the view. However the view NEVER directly accesses the model. Again, my events from the model are just straight Event classes, though you could always make custom events from your model, though it is probably a bit overkill. Notice especially that the model is set to private to protect it from the view and other components. If you wanted to allow accessors to specific data within the model you may want to add getters in the controller, though again this is highly discouraged.</p>
<p><strong>Refactoring Your Code To The Controller</strong><br />
Setting up your controller is simple, let&#8217;s start with a blank class.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">controllers</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SampleController<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SampleController<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Now we just have to move the methods and change the functions that need to be available to the view to be public. Notice that the controller includes a model reference and listens for changes to the model and then updates the view as necessary.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">controllers</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">unitedmindset</span>.<span style="color: #006600;">models</span>.<span style="color: #006600;">SampleModel</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlexEvent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FaultEvent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">http</span>.<span style="color: #006600;">HTTPService</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SampleController<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> view:UMBlogMVC;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _model:SampleModel;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SampleController<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _model = <span style="color: #000000; font-weight: bold;">new</span> SampleModel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _model.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SampleModel.<span style="color: #006600;">SEARCH_LIST_CHANGED</span>,_onSearchListChanged<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> application1_creationCompleteHandler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; runSearch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _onSearchListChanged<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.<span style="color: #006600;">searchList</span>.<span style="color: #006600;">dataProvider</span> = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span> _model.<span style="color: #006600;">searchList</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> runSearch<span style="color: #66cc66;">&#40;</span>event:MouseEvent=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> service:HTTPService = <span style="color: #000000; font-weight: bold;">new</span> HTTPService<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ResultEvent.<span style="color: #006600;">RESULT</span>,_httpService_resultHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FaultEvent.<span style="color: #006600;">FAULT</span>,_httpService_faultHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #006600;">resultFormat</span> = <span style="color: #ff0000;">&quot;e4x&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #0066CC;">url</span> = <span style="color: #ff0000;">&quot;http://www.someUrl.com/yourMethod&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>searchTerm:view.<span style="color: #006600;">searchInput</span>.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _httpService_resultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> service:HTTPService = event.<span style="color: #0066CC;">target</span> as HTTPService;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>ResultEvent.<span style="color: #006600;">RESULT</span>,_httpService_resultHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>FaultEvent.<span style="color: #006600;">FAULT</span>,_httpService_faultHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _model.<span style="color: #006600;">searchList</span> = event.<span style="color: #006600;">result</span> as <span style="color: #0066CC;">Array</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _httpService_faultHandler<span style="color: #66cc66;">&#40;</span>event:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> service:HTTPService = event.<span style="color: #0066CC;">target</span> as HTTPService;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>ResultEvent.<span style="color: #006600;">RESULT</span>,_httpService_resultHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>FaultEvent.<span style="color: #006600;">FAULT</span>,_httpService_faultHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _model.<span style="color: #006600;">searchList</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;fault&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<blockquote><p>Some people will argue that the httpservice should be in the model rather than in the controller. This is a point of contention among some developers. I believe it should be in the controller (or in a simple command) because it is a piece of logic that requests the data from the server, not the data itself.</p></blockquote>
<p><strong>Your Simplified View</strong><br />
Finally we will refactor our view to just the view elements and making a reference to the controller instance in your declarations section (for Fx4).</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>s:Application xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><br />
&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><br />
&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span><br />
&nbsp; &nbsp; xmlns:controllers=<span style="color: #ff0000;">&quot;com.unitedmindset.controllers.*&quot;</span><br />
&nbsp; &nbsp; creationComplete=<span style="color: #ff0000;">&quot;controller.application1_creationCompleteHandler(event)&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>fx:Declarations<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>controllers:SampleController id=<span style="color: #ff0000;">&quot;controller&quot;</span> view=<span style="color: #ff0000;">&quot;{this}&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>fx:Declarations<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:layout<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:VerticalLayout gap=<span style="color: #ff0000;">&quot;20&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;20&quot;</span> paddingLeft=<span style="color: #ff0000;">&quot;20&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;20&quot;</span> paddingTop=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:layout<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:HGroup <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Search Term&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:TextInput <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> id=<span style="color: #ff0000;">&quot;searchInput&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Do It!&quot;</span> click=<span style="color: #ff0000;">&quot;controller.runSearch(event)&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:HGroup<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:<span style="color: #0066CC;">List</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> id=<span style="color: #ff0000;">&quot;searchList&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>s:Application<span style="color: #66cc66;">&gt;</span></div></div>
<p>Looking over this code you will notice that there is absolutely no logic in your view, keeping you view to only doing one thing, <em>looking good</em>. It is the controller instance that receives events from the view and the controller that houses all of your application&#8217;s logic.</p>
<p><strong>Wrapping It All Up</strong><br />
Hopefully this is illuminating and pushes you to do some code refactoring. What is also great about this style of programming is that it works right in with any of your favorite frameworks. If you are making an application and are wondering &#8220;Where does this code go?&#8221;, you just have to ask yourself &#8220;is this part of what is seen, the data, or logic within the application?&#8221;. This separation will also make it easier for when you are working with junior developers and they don&#8217;t know where to put code. I am sure you can already see the benefits to not having services in your view and being able to reuse controllers over multiple views, and the ability to continue abstracting your code to new levels.</p>
<p>Good luck, and happy coding!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.unitedmindset.com%2Fjonbcampos%2F2009%2F08%2F18%2Fflex-best-practices-models-views-and-controllers%2F&amp;title=Flex%20Best%20Practices%20%26%238211%3B%20Models%2C%20Views%2C%20and%20Controllers" id="wpa2a_20"><img src="http://www.unitedmindset.com/jonbcampos/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.unitedmindset.com/jonbcampos/2009/08/18/flex-best-practices-models-views-and-controllers/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
	</channel>
</rss>

