<?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>lejnieks &#187; Flex</title>
	<atom:link href="http://www.lejnieks.com/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lejnieks.com</link>
	<description></description>
	<lastBuildDate>Fri, 29 Jan 2010 19:22:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using Resource Bundles in MXML for simple strings</title>
		<link>http://www.lejnieks.com/2009/04/06/using-resource-bundles-in-mxml-for-simple-strings/</link>
		<comments>http://www.lejnieks.com/2009/04/06/using-resource-bundles-in-mxml-for-simple-strings/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 18:08:17 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=63</guid>
		<description><![CDATA[There are a few ways developers can use resource bundles in a flex application. When using a resource bundle, in particular a simple string, inside of an mxml file you can gain access to the resource using the resourceManager or by using the @Resource directive. For simple strings, meaning strings you are not going to [...]]]></description>
			<content:encoded><![CDATA[<p>There are a few ways developers can use resource bundles in a flex application. When using a resource bundle, in particular a simple string, inside of an mxml file you can gain access to the resource using the resourceManager or by using the @Resource directive. For simple strings, meaning strings you are not going to tokenize you should be using the @Resource directive instead of the resourceManager.<br />
<span id="more-63"></span><br />
Lets examine a simple test app. Below you will see a simple app with two labels, both look for the same string in the same bundle and display them the same way. For all intents and purposes these two labels are exactly the same, except they are actually rather different.</p>
<p><strong>sample app</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;@Resource(key='testString', bundle='labels')&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	&lt;mx:Label text=&quot;{resourceManager.getString('labels', 'testString')}&quot; /&gt;</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>If you add the generate as output argument to your compiler we can see what is happening under the covers here</p>
<p><strong>compiler args</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">-locale en_US -source-path+<span style="color: #000066; font-weight:bold;">=</span>../locale/<span style="">&#123;</span>locale<span style="">&#125;</span> -keep-generated-actionscript</pre></div></div>

<p>once Flex is done building you can easily see how the compiler has handled the resource bundle @directive</p>
<p><strong>labels_properties.as</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">resources</span>.<span style="color: #006600;">ResourceBundle</span>;
&nbsp;
<span style="color: #66cc66;">&#91;</span>ExcludeClass<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> en_US$labels_properties <span style="color: #0066CC;">extends</span> ResourceBundle
<span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> en_US$labels_properties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
		 <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;en_US&quot;</span>, <span style="color: #ff0000;">&quot;labels&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    override protected <span style="color: #000000; font-weight: bold;">function</span> getContent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> content:<span style="color: #0066CC;">Object</span> =
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #ff0000;">&quot;testString&quot;</span>: <span style="color: #ff0000;">&quot;This is a test&quot;</span>
        <span style="color: #66cc66;">&#125;</span>;
        <span style="color: #b1b100;">return</span> content;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>main-generated.as (truncated&#8230;)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
...
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> main
	<span style="color: #0066CC;">extends</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">Application</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">//	Container document descriptor</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _documentDescriptor_ : mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponentDescriptor</span> =
<span style="color: #000000; font-weight: bold;">new</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponentDescriptor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">type</span>: mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">Application</span>
  ,
  propertiesFactory: <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#123;</span>
    childDescriptors: <span style="color: #66cc66;">&#91;</span>
      <span style="color: #000000; font-weight: bold;">new</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponentDescriptor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">type</span>: mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Label</span>
        ,
        propertiesFactory: <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#123;</span>
          <span style="color: #0066CC;">text</span>: ResourceManager.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getString</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;labels&quot;</span>, <span style="color: #ff0000;">&quot;testString&quot;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//	constructor (Flex display object)</span>
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		mx_internal::_document = <span style="color: #0066CC;">this</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	our style settings</span>
&nbsp;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	ambient styles</span>
		mx_internal::_main_StylesInit<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	properties</span>
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">layout</span> = <span style="color: #ff0000;">&quot;vertical&quot;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	events</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
	override <span style="color: #0066CC;">public</span> <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>
	<span style="color: #66cc66;">&#123;</span>
 		mx_internal::setDocumentDescriptor<span style="color: #66cc66;">&#40;</span>_documentDescriptor_<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">super</span>.<span style="color: #006600;">initialize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	mx_internal <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> _main_StylesInit_done:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
	mx_internal <span style="color: #000000; font-weight: bold;">function</span> _main_StylesInit<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">//	only add our style defs to the StyleManager once</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mx_internal::_main_StylesInit_done<span style="color: #66cc66;">&#41;</span>
			<span style="color: #b1b100;">return</span>;
		<span style="color: #b1b100;">else</span>
			mx_internal::_main_StylesInit_done = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> style:CSSStyleDeclaration;
		<span style="color: #000000; font-weight: bold;">var</span> effects:<span style="color: #0066CC;">Array</span>;
&nbsp;
		StyleManager.<span style="color: #006600;">mx_internal</span>::initProtoChainRoots<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>now reverse the commented section so Flex builds using the resourceManager() inside the label instead of using the @Resource directive.</p>
<p><strong>labels_properties.as</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">resources</span>.<span style="color: #006600;">ResourceBundle</span>;
&nbsp;
<span style="color: #66cc66;">&#91;</span>ExcludeClass<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> en_US$labels_properties <span style="color: #0066CC;">extends</span> ResourceBundle
<span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> en_US$labels_properties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
		 <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;en_US&quot;</span>, <span style="color: #ff0000;">&quot;labels&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    override protected <span style="color: #000000; font-weight: bold;">function</span> getContent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> content:<span style="color: #0066CC;">Object</span> =
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #ff0000;">&quot;testString&quot;</span>: <span style="color: #ff0000;">&quot;This is a test&quot;</span>
        <span style="color: #66cc66;">&#125;</span>;
        <span style="color: #b1b100;">return</span> content;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>main-generated.as (truncated&#8230;)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
...
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> main
	<span style="color: #0066CC;">extends</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">Application</span>
	<span style="color: #0066CC;">implements</span> mx.<span style="color: #006600;">binding</span>.<span style="color: #006600;">IBindingClient</span>
<span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//	instance variables</span>
<span style="color: #808080; font-style: italic;">/**
 * @private
 **/</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> _main_Label1 : mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Label</span>;
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">//	type-import dummies</span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">//	Container document descriptor</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _documentDescriptor_ : mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponentDescriptor</span> =
<span style="color: #000000; font-weight: bold;">new</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponentDescriptor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">type</span>: mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">Application</span>
  ,
  propertiesFactory: <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#123;</span>
    childDescriptors: <span style="color: #66cc66;">&#91;</span>
      <span style="color: #000000; font-weight: bold;">new</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponentDescriptor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">type</span>: mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Label</span>
        ,
        id: <span style="color: #ff0000;">&quot;_main_Label1&quot;</span>
      <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//	constructor (Flex display object)</span>
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		mx_internal::_document = <span style="color: #0066CC;">this</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	our style settings</span>
&nbsp;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	ambient styles</span>
		mx_internal::_main_StylesInit<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	properties</span>
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">layout</span> = <span style="color: #ff0000;">&quot;vertical&quot;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">//	events</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//	initialize()</span>
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
	override <span style="color: #0066CC;">public</span> <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>
	<span style="color: #66cc66;">&#123;</span>
 		mx_internal::setDocumentDescriptor<span style="color: #66cc66;">&#40;</span>_documentDescriptor_<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> bindings:<span style="color: #0066CC;">Array</span> = _main_bindingsSetup<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> watchers:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">target</span>:main = <span style="color: #0066CC;">this</span>;
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_watcherSetupUtil == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> watcherSetupUtilClass:<span style="color: #0066CC;">Object</span> = getDefinitionByName<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;_mainWatcherSetupUtil&quot;</span><span style="color: #66cc66;">&#41;</span>;
			watcherSetupUtilClass<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;init&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		_watcherSetupUtil.<span style="color: #006600;">setup</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>,
					<span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>propertyName:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#91;</span>propertyName<span style="color: #66cc66;">&#93;</span>; <span style="color: #66cc66;">&#125;</span>,
					bindings,
					watchers<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> bindings.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			Binding<span style="color: #66cc66;">&#40;</span>bindings<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		mx_internal::_bindings = mx_internal::_bindings.<span style="color: #0066CC;">concat</span><span style="color: #66cc66;">&#40;</span>bindings<span style="color: #66cc66;">&#41;</span>;
		mx_internal::_watchers = mx_internal::_watchers.<span style="color: #0066CC;">concat</span><span style="color: #66cc66;">&#40;</span>watchers<span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
		<span style="color: #0066CC;">super</span>.<span style="color: #006600;">initialize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//	scripts</span>
	<span style="color: #808080; font-style: italic;">//	end scripts</span>
&nbsp;
&nbsp;
    <span style="color: #808080; font-style: italic;">//	supporting function definitions for properties, events, styles, effects</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//	binding mgmt</span>
    <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _main_bindingsSetup<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> result:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
        <span style="color: #000000; font-weight: bold;">var</span> binding:Binding;
&nbsp;
        binding = <span style="color: #000000; font-weight: bold;">new</span> mx.<span style="color: #006600;">binding</span>.<span style="color: #006600;">Binding</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>,
            <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">var</span> result:<span style="color: #66cc66;">*</span> = <span style="color: #66cc66;">&#40;</span>resourceManager.<span style="color: #006600;">getString</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'labels'</span>, <span style="color: #ff0000;">'testString'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #000000; font-weight: bold;">var</span> stringResult:<span style="color: #0066CC;">String</span> = <span style="color: #66cc66;">&#40;</span>result == <span style="color: #0066CC;">undefined</span> ? <span style="color: #000000; font-weight: bold;">null</span> : <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #b1b100;">return</span> stringResult;
            <span style="color: #66cc66;">&#125;</span>,
            <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>_sourceFunctionReturnValue:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
&nbsp;
                _main_Label1.<span style="color: #0066CC;">text</span> = _sourceFunctionReturnValue;
            <span style="color: #66cc66;">&#125;</span>,
            <span style="color: #ff0000;">&quot;_main_Label1.text&quot;</span><span style="color: #66cc66;">&#41;</span>;
        result<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> = binding;
&nbsp;
        <span style="color: #b1b100;">return</span> result;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _main_bindingExprs<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> destination:<span style="color: #66cc66;">*</span>;
		<span style="color: #66cc66;">&#91;</span>Binding<span style="color: #66cc66;">&#40;</span>id=<span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		destination = <span style="color: #66cc66;">&#40;</span>resourceManager.<span style="color: #006600;">getString</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'labels'</span>, <span style="color: #ff0000;">'testString'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
    <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> watcherSetupUtil<span style="color: #66cc66;">&#40;</span>watcherSetupUtil:IWatcherSetupUtil<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #66cc66;">&#40;</span>main<span style="color: #66cc66;">&#41;</span>._watcherSetupUtil = watcherSetupUtil;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> _watcherSetupUtil:IWatcherSetupUtil;
&nbsp;
	<span style="color: #808080; font-style: italic;">//	initialize style defs for main</span>
&nbsp;
	mx_internal <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> _main_StylesInit_done:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
	mx_internal <span style="color: #000000; font-weight: bold;">function</span> _main_StylesInit<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">//	only add our style defs to the StyleManager once</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>mx_internal::_main_StylesInit_done<span style="color: #66cc66;">&#41;</span>
			<span style="color: #b1b100;">return</span>;
		<span style="color: #b1b100;">else</span>
			mx_internal::_main_StylesInit_done = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> style:CSSStyleDeclaration;
		<span style="color: #000000; font-weight: bold;">var</span> effects:<span style="color: #0066CC;">Array</span>;
&nbsp;
&nbsp;
		StyleManager.<span style="color: #006600;">mx_internal</span>::initProtoChainRoots<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">//	embed carrier vars</span>
	<span style="color: #808080; font-style: italic;">//	end embed carrier vars</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//	binding management vars</span>
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
    mx_internal <span style="color: #000000; font-weight: bold;">var</span> _bindings : <span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
    mx_internal <span style="color: #000000; font-weight: bold;">var</span> _watchers : <span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
    mx_internal <span style="color: #000000; font-weight: bold;">var</span> _bindingsByDestination : <span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
    <span style="color: #808080; font-style: italic;">/**
     * @private
     **/</span>
    mx_internal <span style="color: #000000; font-weight: bold;">var</span> _bindingsBeginWithWord : <span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Notice the addition of a change watcher to bind this string to the label. Now considering, again, this is a simple string, it will never change, we are not tokenizing it there for it will be everlasting throughout the application without the need to change therefore binding to this string is needless. You may also notice that the compiled swf using resourceManager is 256kb on disk. The compiled swf using @Resource is 248kb on disk, not a major difference but a difference none the less.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2009/04/06/using-resource-bundles-in-mxml-for-simple-strings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Skinning Checkbox with Error State</title>
		<link>http://www.lejnieks.com/2009/04/06/skinning-checkbox-with-error-state/</link>
		<comments>http://www.lejnieks.com/2009/04/06/skinning-checkbox-with-error-state/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 17:19:06 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Skinning]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=59</guid>
		<description><![CDATA[Similar to skinning a combobox with an error state, there may be times where you need to show the error state for a checkbox without showing its error string. main.css CheckBox &#123; icon : ClassReference&#40;&#34;com.lejnieks.poc.ui.skins.CheckboxBorderSkin&#34;&#41;; error-color : #FF0000; fillColors : #fdfdfd, #e2e3e3, #e6f5ff, #e6f5ff; borderColor : #374149; outerBorderColor : #77848D; themeColor : #77848d; icon-color : [...]]]></description>
			<content:encoded><![CDATA[<p>Similar to skinning a combobox with an error state, there may be times where you need to show the error state for a checkbox without showing its error string.</p>
<p><span id="more-66"></span></p>
<p><strong>main.css</strong></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">CheckBox
<span style="color: #00AA00;">&#123;</span>
	<span style="color: #993333;">icon</span>			<span style="color: #00AA00;">:</span>	ClassReference<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;com.lejnieks.poc.ui.skins.CheckboxBorderSkin&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	error-<span style="color: #000000; font-weight: bold;">color</span>		<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#FF0000</span><span style="color: #00AA00;">;</span>
	fillColors		<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#fdfdfd</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#e2e3e3</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#e6f5ff</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#e6f5ff</span><span style="color: #00AA00;">;</span>
	borderColor		<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#374149</span><span style="color: #00AA00;">;</span>
	outerBorderColor	<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#77848D</span><span style="color: #00AA00;">;</span>
	themeColor		<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#77848d</span><span style="color: #00AA00;">;</span>
	icon-<span style="color: #000000; font-weight: bold;">color</span>		<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#2A2A2A</span><span style="color: #00AA00;">;</span>
	disabled-icon-<span style="color: #000000; font-weight: bold;">color</span>	<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#7A7A7A</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span>			<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#DEEEF9</span><span style="color: #00AA00;">;</span>
	textSelectedColor	<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#DEEEF9</span><span style="color: #00AA00;">;</span>
	textRollOverColor	<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#DEEEF9</span><span style="color: #00AA00;">;</span>
	fontFamily		<span style="color: #00AA00;">:</span> 	Tahoma<span style="color: #00AA00;">;</span>
	fontSize		<span style="color: #00AA00;">:</span> 	<span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span>
	fontWeight		<span style="color: #00AA00;">:</span> 	<span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><strong>CheckboxBorderSkin.as</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">ui</span>.<span style="color: #006600;">skins</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">ui</span>.<span style="color: #006600;">controls</span>.<span style="color: #006600;">IValidatable</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">CheckBox</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">skins</span>.<span style="color: #006600;">halo</span>.<span style="color: #006600;">CheckBoxIcon</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CheckboxBorderSkin <span style="color: #0066CC;">extends</span> CheckBoxIcon <span style="color: #0066CC;">implements</span> IValidatable
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _showError:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> showError<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _showError;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> showError<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_showError = value;
			invalidateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> updateDisplayList<span style="color: #66cc66;">&#40;</span>w:<span style="color: #0066CC;">Number</span>, h:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">updateDisplayList</span><span style="color: #66cc66;">&#40;</span>w, h<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> bDrawCheck:<span style="color: #0066CC;">Boolean</span> 		= 	<span style="color: #000000; font-weight: bold;">false</span>;
			<span style="color: #000000; font-weight: bold;">var</span> fillAlphas:<span style="color: #0066CC;">Array</span>		= 	<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> highlightAlphas:<span style="color: #0066CC;">Array</span> 	= 	<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> checkColor:uint 		= 	<span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iconColor&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">borderColor</span>:uint		= 	<span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;borderColor&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> outerBorderColor:uint	=	<span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;outerBorderColor&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> fillColors:<span style="color: #0066CC;">Array</span> 		= 	<span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;fillColors&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> isErrorState:<span style="color: #0066CC;">Boolean</span>	=	<span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">!</span>_showError <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>parent is CheckBox <span style="color: #66cc66;">&amp;&amp;</span> CheckBox<span style="color: #66cc66;">&#40;</span>parent<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">errorString</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&amp;&amp;</span>  CheckBox<span style="color: #66cc66;">&#40;</span>parent<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">errorString</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">&amp;&amp;</span> CheckBox<span style="color: #66cc66;">&#40;</span>parent<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">errorString</span> <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span>  <span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					isErrorState = <span style="color: #000000; font-weight: bold;">true</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			graphics.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">name</span> <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;upIcon&quot;</span>:
					<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>isErrorState <span style="color: #66cc66;">||</span> _showError<span style="color: #66cc66;">&#41;</span>
					<span style="color: #66cc66;">&#123;</span>
						drawRoundRect<span style="color: #66cc66;">&#40;</span> -<span style="color: #cc66cc;">1</span>, -<span style="color: #cc66cc;">1</span>, w + <span style="color: #cc66cc;">2</span>, h + <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, outerBorderColor, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #66cc66;">&#125;</span>
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #cc66cc;">1</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;overIcon&quot;</span>:
					drawRoundRect<span style="color: #66cc66;">&#40;</span> -<span style="color: #cc66cc;">1</span>, -<span style="color: #cc66cc;">1</span>, w + <span style="color: #cc66cc;">2</span>, h + <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, outerBorderColor, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #cc66cc;">1</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;downIcon&quot;</span>:
					drawRoundRect<span style="color: #66cc66;">&#40;</span> -<span style="color: #cc66cc;">1</span>, -<span style="color: #cc66cc;">1</span>, w + <span style="color: #cc66cc;">2</span>, h + <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, outerBorderColor, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #cc66cc;">1</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;disabledIcon&quot;</span>:
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0.5</span>, <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#93;</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;selectedUpIcon&quot;</span>:
					bDrawCheck = <span style="color: #000000; font-weight: bold;">true</span>;
					<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>isErrorState <span style="color: #66cc66;">||</span> _showError<span style="color: #66cc66;">&#41;</span>
					<span style="color: #66cc66;">&#123;</span>
						drawRoundRect<span style="color: #66cc66;">&#40;</span> -<span style="color: #cc66cc;">1</span>, -<span style="color: #cc66cc;">1</span>, w + <span style="color: #cc66cc;">2</span>, h + <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, outerBorderColor, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #66cc66;">&#125;</span>
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #cc66cc;">1</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;selectedOverIcon&quot;</span>:
					bDrawCheck = <span style="color: #000000; font-weight: bold;">true</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> -<span style="color: #cc66cc;">1</span>, -<span style="color: #cc66cc;">1</span>, w + <span style="color: #cc66cc;">2</span>, h + <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, outerBorderColor, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #cc66cc;">1</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;selectedDownIcon&quot;</span>:
					bDrawCheck = <span style="color: #000000; font-weight: bold;">true</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> -<span style="color: #cc66cc;">1</span>, -<span style="color: #cc66cc;">1</span>, w + <span style="color: #cc66cc;">2</span>, h + <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, outerBorderColor, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #cc66cc;">1</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;selectedDisabledIcon&quot;</span>:
					bDrawCheck = <span style="color: #000000; font-weight: bold;">true</span>;
					checkColor = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;disabledIconColor&quot;</span><span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, w, h, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>, <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>;
					drawRoundRect<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #66cc66;">&#91;</span> fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, fillColors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0.5</span>, <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#93;</span>, verticalGradientMatrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, w - <span style="color: #cc66cc;">2</span>, h - <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bDrawCheck<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				graphics.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>checkColor<span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">moveTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">7</span>, <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">6.5</span>, <span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>IValidatable.as</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">ui</span>.<span style="color: #006600;">controls</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/**
	 *  The interface that components implement to
	 *  support validation of fields. This component
	 *  bypasses the need to use Validators.
	 *  Custom ui components implement this interface
	 *  therefore all custom ui component in the application can be
	 *  iterated through during a validation process
	 *  and set to show its error state or clear its error state.
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IValidatable
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/**
	     *  Every &lt;cod&gt;IValidatable&lt;/code&gt; component will have a proper error
	     *  skin. Setting &lt;code&gt;showError&lt;/code&gt; to true will invoke this setter
	     *  and flag the component to display the error skin on the next
	     *  &lt;cod&gt;commitPropeties&lt;/code&gt;.
	     *
	     *  &lt;p&gt;Calling &lt;code&gt;showError&lt;/code&gt; is similar to setting &lt;code&gt;errorString&lt;/code&gt;
	     *  except that some components may not need to display an error string but still show
	     *  its error skin.&lt;/p&gt;
	     * 	&lt;p&gt;IValidatable components in the application can display error skins regardless of setting an
	     *  errorString. This is important to note for child components whose parent containers
	     *  will set or show an error string or who wont show an error message at all but simply
	     *  display a skin or icon for its errored state&lt;/p&gt;
	     *
	 	*/</span>
		<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> showError<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>;
		<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> showError<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2009/04/06/skinning-checkbox-with-error-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Skinning ComboBox with Error State</title>
		<link>http://www.lejnieks.com/2009/04/06/skinning-combobox-with-error-state/</link>
		<comments>http://www.lejnieks.com/2009/04/06/skinning-combobox-with-error-state/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 16:18:55 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Skinning]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=60</guid>
		<description><![CDATA[Since the ComboBox doesn&#8217;t come with an out-of-the-box error state / skin without using an error string, you can grab the sample code below to give your comboBox an error skin. The example implements the interface IValidatable which for the most part is a stub interface that should be considered itterable by the application so [...]]]></description>
			<content:encoded><![CDATA[<p>Since the ComboBox doesn&#8217;t come with an out-of-the-box error state / skin without using an error string, you can grab the sample code below to give your comboBox an error skin. The example implements the interface IValidatable which for the most part is a stub interface that should be considered itterable by the application so you can easily request that any IValidatable component shows its error state ( <em>showError()</em> ). The point of doing this instead of using set errorString is that in certain instances you may not actually want to use an error string, or in the case of a comboBox you may want to have its parent container show the error string.</p>
<p>Another case to use this method of validation would be if you have a parent container with multiple controls inside of it, the parent container is responsible for messaging the error to the user but each control should display an errored state regardless of displaying an error string.</p>
<p><span id="more-65"></span></p>
<p><strong>main.css</strong></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">CustomComboBox
<span style="color: #00AA00;">&#123;</span>
	up-skin				<span style="color: #00AA00;">:</span>	Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/assets/images/combobox_skin_up.png&quot;</span><span style="color: #00AA00;">,</span> scaleGridTop<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridBottom<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #00AA00;">,</span> scaleGridLeft<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridRight<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	over-skin			<span style="color: #00AA00;">:</span>	Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/assets/images/combobox_skin_over.png&quot;</span><span style="color: #00AA00;">,</span> scaleGridTop<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridBottom<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #00AA00;">,</span> scaleGridLeft<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridRight<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	down-skin			<span style="color: #00AA00;">:</span>	Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/assets/images/combobox_skin_down.png&quot;</span><span style="color: #00AA00;">,</span> scaleGridTop<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridBottom<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #00AA00;">,</span> scaleGridLeft<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridRight<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	disabled-skin			<span style="color: #00AA00;">:</span>	Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/assets/images/combobox_skin_disabled.png&quot;</span><span style="color: #00AA00;">,</span> scaleGridTop<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridBottom<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #00AA00;">,</span> scaleGridLeft<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridRight<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	errorUpSkin			<span style="color: #00AA00;">:</span>	Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/assets/images/combobox_skin_errorUp.png&quot;</span><span style="color: #00AA00;">,</span> scaleGridTop<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridBottom<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #00AA00;">,</span> scaleGridLeft<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridRight<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	errorOverSkin			<span style="color: #00AA00;">:</span>	Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/assets/images/combobox_skin_errorOver.png&quot;</span><span style="color: #00AA00;">,</span> scaleGridTop<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridBottom<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #00AA00;">,</span> scaleGridLeft<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridRight<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	errorDownSkin			<span style="color: #00AA00;">:</span>	Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;/assets/images/combobox_skin_errorDown.png&quot;</span><span style="color: #00AA00;">,</span> scaleGridTop<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridBottom<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;17&quot;</span><span style="color: #00AA00;">,</span> scaleGridLeft<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #00AA00;">,</span> scaleGridRight<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span>				<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#0A3C6C</span><span style="color: #00AA00;">;</span>
	text-roll-over-<span style="color: #000000; font-weight: bold;">color</span>		<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#072A4C</span><span style="color: #00AA00;">;</span>
	text-selected-<span style="color: #000000; font-weight: bold;">color</span>		<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#072A4C</span><span style="color: #00AA00;">;</span>
	disabled-<span style="color: #000000; font-weight: bold;">color</span>			<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#404E58</span><span style="color: #00AA00;">;</span>
	dropDownStyleName		<span style="color: #00AA00;">:</span> 	comboBoxDropDowns<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.comboBoxDropDowns</span>
<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">color</span>				<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#0A3C6C</span><span style="color: #00AA00;">;</span>
	text-roll-over-<span style="color: #000000; font-weight: bold;">color</span>		<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#072A4C</span><span style="color: #00AA00;">;</span>
	text-selected-<span style="color: #000000; font-weight: bold;">color</span>		<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span>		<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#f6f6f6</span><span style="color: #00AA00;">;</span>
	border-thickness		<span style="color: #00AA00;">:</span> 	<span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-color</span>			<span style="color: #00AA00;">:</span> 	<span style="color: #cc00cc;">#f6f6f6</span><span style="color: #00AA00;">;</span>
	roll-over-<span style="color: #000000; font-weight: bold;">color</span>			<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#C3CED6</span><span style="color: #00AA00;">;</span>
	selection-<span style="color: #000000; font-weight: bold;">color</span>			<span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#0A3C6C</span><span style="color: #00AA00;">;</span>
	dropShadowEnabled		<span style="color: #00AA00;">:</span> 	false<span style="color: #00AA00;">;</span>
	corner-radius			<span style="color: #00AA00;">:</span>	<span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><strong>CustomCombBox</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">ui</span>.<span style="color: #006600;">controls</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">ComboBox</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">ValidationResultEvent</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomComboBox <span style="color: #0066CC;">extends</span> ComboBox <span style="color: #0066CC;">implements</span> IValidatable
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> originalUpSkin:<span style="color: #0066CC;">Object</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> originalOverSkin:<span style="color: #0066CC;">Object</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> originalDownSkin:<span style="color: #0066CC;">Object</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _showError:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> createChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">createChildren</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			originalUpSkin		=	<span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;upSkin&quot;</span><span style="color: #66cc66;">&#41;</span>;
			originalOverSkin	=	<span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;overSkin&quot;</span><span style="color: #66cc66;">&#41;</span>;
			originalDownSkin	=	<span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;downSkin&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			setBackgroundSkin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> showError<span style="color: #66cc66;">&#40;</span> value:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_showError = value;
			invalidateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> showError<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _showError;
		<span style="color: #66cc66;">&#125;</span>
&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>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">commitProperties</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_showError<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				setBackgroundErrorSkin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>errorString <span style="color: #66cc66;">&amp;&amp;</span> errorString.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
		    		<span style="color: #66cc66;">&#123;</span>
		    			errorString = <span style="color: #ff0000;">''</span>;
		    		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	        		setBackgroundSkin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setBackgroundSkin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;upSkin&quot;</span>, originalUpSkin<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;overSkin&quot;</span>, originalOverSkin<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;downSkin&quot;</span>, originalDownSkin<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setBackgroundErrorSkin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;upSkin&quot;</span>, <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;errorUpSkin&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;overSkin&quot;</span>, <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;errorOverSkin&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;downSkin&quot;</span>, <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;errorDownSkin&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>IValidatable</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">ui</span>.<span style="color: #006600;">controls</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/**
	 *  The interface that components implement to
	 *  support validation of fields. This component
	 *  bypasses the need to use Validators.
	 *  Custom ui components implement this interface
	 *  therefore all custom ui component in the application can be
	 *  iterated through during a validation process
	 *  and set to show its error state or clear its error state.
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IValidatable
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/**
	     *  Every &lt;cod&gt;IValidatable&lt;/code&gt; component will have a proper error
	     *  skin. Setting &lt;code&gt;showError&lt;/code&gt; to true will invoke this setter
	     *  and flag the component to display the error skin on the next
	     *  &lt;cod&gt;commitPropeties&lt;/code&gt;.
	     *
	     *  &lt;p&gt;Calling &lt;code&gt;showError&lt;/code&gt; is similar to setting &lt;code&gt;errorString&lt;/code&gt;
	     *  except that some components may not need to display an error string but still show
	     *  its error skin.&lt;/p&gt;
	     * 	&lt;p&gt;IValidatable components in the application can display error skins regardless of setting an
	     *  errorString. This is important to note for child components whose parent containers
	     *  will set or show an error string or who wont show an error message at all but simply
	     *  display a skin or icon for its errored state&lt;/p&gt;
	     *
	 	*/</span>
		<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> showError<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>;
		<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> showError<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2009/04/06/skinning-combobox-with-error-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile ASDocs with ANT</title>
		<link>http://www.lejnieks.com/2009/01/10/compile-asdocs-with-ant/</link>
		<comments>http://www.lejnieks.com/2009/01/10/compile-asdocs-with-ant/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 05:24:07 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ASDocs]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=62</guid>
		<description><![CDATA[Continuing on with ANT &#8211; Flex compilation, this sample script below will help you output ASDocs for your projects deliverable. Ant Script &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;project name=&#34;ASDocsTest&#34; default=&#34;compile&#34; basedir=&#34;.&#34;&#62; &#160; &#60;!-- import our build properties file --&#62; &#60;property file=&#34;./build.properties&#34; /&#62; &#160; &#160; &#60;!-- Flex Ant Tasks used to perform compc and mxml compiling more info [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing on with ANT &#8211; Flex compilation, this sample script below will help you output ASDocs for your projects deliverable.</p>
<p><span id="more-62"></span></p>
<p><strong>Ant Script</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ASDocsTest&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;compile&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	import our build properties file</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;./build.properties&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	Flex Ant Tasks used to perform compc and mxml compiling more info at http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;flexTasks.tasks&quot;</span> <span style="color: #000066;">classpath</span>=<span style="color: #ff0000;">&quot;${flexTasks.jar}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	Execute the ASDoc Compile</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;compile&quot;</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">&quot;generateASDocs&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;series of tasks to create docs&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	DELETE the existing output folder and files and then re-generate the output folder</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;cleanASDocsDir&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;DELETE the existing output folder and files and then re-generate the output folder&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${asdocOutput.dir}&quot;</span> <span style="color: #000066;">failOnError</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">includeEmptyDirs</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${asdocOutput.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>doc directory cleaned<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	Run the ASDoc executable and generate the ASDocs to the new output folder</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;generateASDocs&quot;</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">&quot;cleanASDocsDir, asDocsLog&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Run the ASDoc executable and generate the ASDocs to the new output folder&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;Generating ASDocs&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;${asdoc.dir}&quot;</span> <span style="color: #000066;">failonerror</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-doc-sources ${asdocClassPath}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-source-path '${srcpath.dir}'&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-external-library-path '${externalLib.dir}'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-window-title '${asdocsTitle}'&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-main-title '${asdocsTitle}'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-footer '${asdocsFooter}'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-output '${asdocOutput.dir}'&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;ASDocs created successfully&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	LOG writes asdoc output to log file: log.txt</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;asDocsLog&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;start the asdoc generation log&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;record</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;${asdocOutput.dir}/asdoc-log.txt&quot;</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;start&quot;</span> <span style="color: #000066;">append</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>Build.properties</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"># Home directory for flex sdk <span style="">3</span>, change this to build for Mac or PC using # as comment
<span style="color: #000099;">FLEX_HOME</span> 		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	sdks/flex-<span style="">3.2</span>-sdk</span>
flexTasks.jar		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	tools/FlexTasks/lib/flexTasks.jar</span>
srcpath.dir      	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	../src</span>
externalLib.dir  	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	../libs</span>
&nbsp;
# ASDoc
asdoc.dir		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	sdks/flex-<span style="">3.2</span>-sdk/bin/asdoc</span>
asdocOutput.dir  	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	../html_docs</span>
<span style="color: #000099;">asdocClassPath</span> 		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 	$<span style="">&#123;</span>srcpath.dir<span style="">&#125;</span>/com</span>
<span style="color: #000099;">asdocsTitle</span> 		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 	ASDocs Test Library</span>
<span style="color: #000099;">asdocsFooter</span> 		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 	CONFIDENTIAL. Copyright <span style="">2009</span> My Company</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2009/01/10/compile-asdocs-with-ant/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Overriding Menu to include stage height bounds</title>
		<link>http://www.lejnieks.com/2008/11/17/overriding-menu-to-include-stage-height-bounds/</link>
		<comments>http://www.lejnieks.com/2008/11/17/overriding-menu-to-include-stage-height-bounds/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 06:11:31 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=53</guid>
		<description><![CDATA[I was working on a custom menu component uses Menu. Turns out that Menu doesnt inherintly understand the stage height of the application. What I ended up doing was creating CustomMenu which extends Menu and adds in height bounds for the root and any sub menu. package com.lejnieks.poc.ui.components.menu &#123; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.geom.Point; [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a custom menu component uses Menu. Turns out that Menu doesnt inherintly understand the stage height of the application. What I ended up doing was creating CustomMenu which extends Menu and adds in height bounds for the root and any sub menu.</p>
<p><span id="more-53"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">ui</span>.<span style="color: #006600;">components</span>.<span style="color: #0066CC;">menu</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">DisplayObject</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">DisplayObjectContainer</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Point</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">Menu</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">listClasses</span>.<span style="color: #006600;">IListItemRenderer</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">menuClasses</span>.<span style="color: #006600;">IMenuItemRenderer</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">Application</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">ScrollPolicy</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">mx_internal</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">managers</span>.<span style="color: #006600;">PopUpManager</span>;
&nbsp;
	use namespace mx_internal;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomMenu <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">Menu</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> xpos:<span style="color: #0066CC;">Object</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ypos:<span style="color: #0066CC;">Object</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> const END_OF_SCREEN_MENU_PADDING:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">5</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CustomMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> createMenu<span style="color: #66cc66;">&#40;</span>parent:DisplayObjectContainer, mdp:<span style="color: #0066CC;">Object</span>, showRoot:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>:CustomMenu
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">menu</span>:CustomMenu = <span style="color: #000000; font-weight: bold;">new</span> CustomMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #0066CC;">tabEnabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">owner</span> = DisplayObjectContainer<span style="color: #66cc66;">&#40;</span>Application.<span style="color: #006600;">application</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">showRoot</span> = showRoot;
&nbsp;
			popUpMenu<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">menu</span>, parent, mdp<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">menu</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override mx_internal <span style="color: #000000; font-weight: bold;">function</span> openSubMenu<span style="color: #66cc66;">&#40;</span>row:IListItemRenderer<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			supposedToLoseFocus = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> r:<span style="color: #0066CC;">Menu</span> = getRootMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">menu</span>:<span style="color: #0066CC;">Menu</span>;
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>IMenuItemRenderer<span style="color: #66cc66;">&#40;</span>row<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">menu</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">menu</span> = <span style="color: #000000; font-weight: bold;">new</span> TIPSMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">parentMenu</span> = <span style="color: #0066CC;">this</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">owner</span> = <span style="color: #0066CC;">this</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">showRoot</span> = showRoot;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">dataDescriptor</span> = r.<span style="color: #006600;">dataDescriptor</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">styleName</span> = r;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">labelField</span> = r.<span style="color: #006600;">labelField</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">labelFunction</span> = r.<span style="color: #006600;">labelFunction</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">iconField</span> = r.<span style="color: #006600;">iconField</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">iconFunction</span> = r.<span style="color: #006600;">iconFunction</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">itemRenderer</span> = r.<span style="color: #006600;">itemRenderer</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">rowHeight</span> = r.<span style="color: #006600;">rowHeight</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">scaleY</span> = r.<span style="color: #006600;">scaleY</span>;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">scaleX</span> = r.<span style="color: #006600;">scaleX</span>;
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>row.<span style="color: #0066CC;">data</span> <span style="color: #66cc66;">&amp;&amp;</span>
					_dataDescriptor.<span style="color: #006600;">isBranch</span><span style="color: #66cc66;">&#40;</span>row.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span>
					_dataDescriptor.<span style="color: #006600;">hasChildren</span><span style="color: #66cc66;">&#40;</span>row.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">dataProvider</span> = _dataDescriptor.<span style="color: #006600;">getChildren</span><span style="color: #66cc66;">&#40;</span>row.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
&nbsp;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">sourceMenuBar</span> = sourceMenuBar;
				<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">sourceMenuBarItem</span> = sourceMenuBarItem;
&nbsp;
				IMenuItemRenderer<span style="color: #66cc66;">&#40;</span>row<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">menu</span> = <span style="color: #0066CC;">menu</span>;
				PopUpManager.<span style="color: #006600;">addPopUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">menu</span>, r, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">menu</span> = IMenuItemRenderer<span style="color: #66cc66;">&#40;</span>row<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">menu</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">openSubMenu</span><span style="color: #66cc66;">&#40;</span>row<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>x:<span style="color: #0066CC;">Object</span>=<span style="color: #000000; font-weight: bold;">null</span>, y:<span style="color: #0066CC;">Object</span>=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">xpos</span> = x;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">ypos</span> = y;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> absoluteHeightOfSubMenu:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">height</span> + <span style="color: #0066CC;">this</span>.<span style="color: #006600;">ypos</span>;
			<span style="color: #000000; font-weight: bold;">var</span> appHeight:<span style="color: #0066CC;">Number</span> = Application.<span style="color: #006600;">application</span>.<span style="color: #0066CC;">height</span>;
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> absoluteHeightOfSubMenu <span style="color: #66cc66;">&gt;</span> appHeight <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">ypos</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #006600;">ypos</span><span style="color: #66cc66;">&#41;</span> - <span style="color: #66cc66;">&#40;</span>absoluteHeightOfSubMenu - appHeight<span style="color: #66cc66;">&#41;</span> - END_OF_SCREEN_MENU_PADDING;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">super</span>.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>x, <span style="color: #0066CC;">this</span>.<span style="color: #006600;">ypos</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Im overriding show() so that when the menu displays, if the menus height + its absolute position is greater than the application height, then it will move the menus y position up by the difference of the menu height + menu y position, and then I add in just a bit of extra padding so the menu doesn&#8217;t butt up against the bottom of the application</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/11/17/overriding-menu-to-include-stage-height-bounds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Compile Flex applications using ANT</title>
		<link>http://www.lejnieks.com/2008/11/02/compile-flex-applications-using-ant/</link>
		<comments>http://www.lejnieks.com/2008/11/02/compile-flex-applications-using-ant/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 13:55:34 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=61</guid>
		<description><![CDATA[A quick setup and example of how to compile a Flex application using ANT. This example will show the basics of how to run the ANT script to compile your flex application, I will walk through more complex examples in later posts but to get started look through the script and properties files below or [...]]]></description>
			<content:encoded><![CDATA[<p>A quick setup and example of how to compile a Flex application using ANT. This example will show the basics of how to run the ANT script to compile your flex application, I will walk through more complex examples in later posts but to get started look through the script and properties files below or download the attached project files at the bottom of this post.</p>
<p><a href="http://ant.apache.org/">ANT</a> is a very powerful tool that, once you get into using it, will make your development, deployment and automation a lot simpler as well a lot less prone to error. If you are new to <a href="http://ant.apache.org/">ANT</a> there are a lot of resources out on the web that will help you get up to speed. This post and others to follow will focus specifically on the uses of ANT with Flex in a CI build process.</p>
<p><span id="more-61"></span></p>
<p><strong>Ant Script</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;FlexANTBuildSample&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;build&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	DEFINE import our build properties file and define our tasks</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;./build.properties&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;project.classpath&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${tools.dir}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;**/*.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;flexTasks.tasks&quot;</span> <span style="color: #000066;">classpath</span>=<span style="color: #ff0000;">&quot;${flexTasks.jar}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;com/adobe/ac/ant/tasks/tasks.properties&quot;</span> <span style="color: #000066;">classpath</span>=<span style="color: #ff0000;">&quot;${flexAntTasks.jar}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;net/sf/antcontrib/antcontrib.properties&quot;</span> <span style="color: #000066;">classpathref</span>=<span style="color: #ff0000;">&quot;project.classpath&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	TARGETS</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;build&quot;</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">&quot;init, clean, makeWrapper, compile&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	INITIALIZE</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;init&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Initializes the build&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;condition</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;environment.display&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;:1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;os</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Linux&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/condition<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tstamp</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;=============================================&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;${project.name}-${project.version} [${TODAY}]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;Copyright (c) ${project.year} ${project.owner}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;OS : ${os.name}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;Author: ${author}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;==============================================&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	CLEAN the existing output folder and files and then re-generate the output folder</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;clean&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;deletes and recreates the metadata destination directory&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">verbose</span>=<span style="color: #ff0000;">&quot;${verbose}&quot;</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${deploy.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${deploy.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">&quot;Deploy directory created&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	COMPILE</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;compile&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;compiles the Main app&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mxmlc</span> <span style="color: #000066;">context-root</span>=<span style="color: #ff0000;">&quot;main&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${mainApp.src}&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">output</span>=<span style="color: #ff0000;">&quot;${mainApp.swf}&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">actionscript-file-encoding</span>=<span style="color: #ff0000;">&quot;${encoding}&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">keep-generated-actionscript</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">incremental</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">			<span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;${locale}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;load-config</span> <span style="color: #000066;">filename</span>=<span style="color: #ff0000;">&quot;${FLEX_HOME}/frameworks/flex-config.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;compiler.source-path</span> <span style="color: #000066;">path-element</span>=<span style="color: #ff0000;">&quot;${FLEX_HOME}/frameworks&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;compiler.source-path</span> <span style="color: #000066;">path-element</span>=<span style="color: #ff0000;">&quot;${srcpath.dir}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;compiler.library-path</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${FLEX_HOME}/frameworks&quot;</span> <span style="color: #000066;">append</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;libs&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/compiler.library-path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;compiler.library-path</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${basedir}&quot;</span> <span style="color: #000066;">append</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;libs&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/compiler.library-path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mxmlc<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	MAKE WRAPPER</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;copyTemplates&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;${deploy.dir}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${htmltemplate.dir}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;**/index.template.html&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/copy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;makeWrapper&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;copies index.html wrapper and needed files from html-template directory&quot;</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">&quot;clean, copyTemplates&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pageTitle&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${mainApp.name}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copy</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${htmltemplate.dir}/index.template.html&quot;</span> <span style="color: #000066;">tofile</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${title}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${pageTitle}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${swf}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${mainApp.name}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${width}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${height}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${bgcolor}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${mainApp.bgColor}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${application}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${mainApp.name}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${version_major}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;9&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${version_minor}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replace</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${deploy.dir}/index.html&quot;</span> <span style="color: #000066;">token</span>=<span style="color: #ff0000;">&quot;$${version_revision}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;28&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>Build.properties</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">######################################
## Author information
######################################
<span style="color: #000099;">author</span>			<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	Kenneth Lejnieks</span>
project.owner		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	Lejnieks Consulting</span>
project.owner.url	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	http://www.lejnieks.com</span>
project.fullname		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	Build CI POC 1</span>
project.version		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	1.0.0 alpha  # major.minor<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>.revision<span style="">&#91;</span>.build<span style="">&#93;</span><span style="">&#93;</span></span></span>
project.name		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	POC Sample 1</span>
project.year		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	2009</span>
application.name	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	POC</span>
&nbsp;
&nbsp;
&nbsp;
######################################
## Path information
######################################
<span style="color: #000099;">FLEX_HOME</span>		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	sdks/flex-<span style="">3.2</span>-sdk</span>
&nbsp;
htmltemplate.dir	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	../html-template</span>
srcpath.dir		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	../src</span>
libs.dir  		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	../libs</span>
tools.dir		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	tools</span>
&nbsp;
deploy.dir		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	../deploy</span>
&nbsp;
&nbsp;
&nbsp;
######################################
## Build arguments
######################################
<span style="color: #000099;">verbose</span>			<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	true</span>
&nbsp;
&nbsp;
&nbsp;
######################################
## Application information
######################################
mainApp.name		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	FlexCISample1</span>
mainApp.src		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	$<span style="">&#123;</span>srcpath.dir<span style="">&#125;</span>/$<span style="">&#123;</span>mainApp.name<span style="">&#125;</span>.mxml</span>
mainApp.swf		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	$<span style="">&#123;</span>deploy.dir<span style="">&#125;</span>/$<span style="">&#123;</span>mainApp.name<span style="">&#125;</span>.swf</span>
mainApp.bgColor		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	#f6f6f6</span>
<span style="color: #000099;">locale</span>			<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	en_US</span>
<span style="color: #000099;">encoding</span>		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	UTF-8</span>
&nbsp;
&nbsp;
&nbsp;
######################################
## Build Tools
######################################
flexTasks.jar		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	$<span style="">&#123;</span>FLEX_HOME<span style="">&#125;</span>/ant/lib/flexTasks.jar</span>
flexAntTasks.jar	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	$<span style="">&#123;</span>tools.dir<span style="">&#125;</span>/FlexAntTasks.jar</span>
ant-contrib.jar		<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	$<span style="">&#123;</span>tools.dir<span style="">&#125;</span>/ant-contrib.jar</span></pre></div></div>

<p>Project source files including necessary jars can be found <a href="http://projects.lejnieks.com/Flex CI Sample.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/11/02/compile-flex-applications-using-ant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using tokens in resource bundles</title>
		<link>http://www.lejnieks.com/2008/10/20/using-tokens-in-resource-bundles/</link>
		<comments>http://www.lejnieks.com/2008/10/20/using-tokens-in-resource-bundles/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 20:29:01 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=64</guid>
		<description><![CDATA[A quick sample on how to pass in token values to a resource bundle string. When you need to replace a token value in your bundle, you will want to use the resourceManager or ResourceManager and pass in the value you want to replace in your bundle as an array, this is in the 3 [...]]]></description>
			<content:encoded><![CDATA[<p>A quick sample on how to pass in token values to a resource bundle string. When you need to replace a token value in your bundle, you will want to use the resourceManager or ResourceManager and pass in the value you want to replace in your bundle as an array, this is in the 3 parameter of the resourceManager&#8217;s getString() method.</p>
<p><span id="more-64"></span></p>
<p><strong>Application</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    [ResourceBundle(&quot;labels&quot;)]
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">			import mx.formatters.DateFormatter;</span>
<span style="color: #339933;">			import mx.resources.ResourceManager;</span>
&nbsp;
<span style="color: #339933;">			[Bindable] private var _username:String;</span>
<span style="color: #339933;">			[Bindable] private var _date:String;</span>
&nbsp;
<span style="color: #339933;">			private function setUsername( event:MouseEvent ):void</span>
<span style="color: #339933;">			{</span>
<span style="color: #339933;">				var tmpDate:Date	=	new Date();</span>
&nbsp;
<span style="color: #339933;">				_username	= 	usernameInput.text;</span>
<span style="color: #339933;">				_date		=	tmpDate.getMonth() + &quot;/&quot; + tmpDate.getDay() + &quot;/&quot; + tmpDate.getFullYear();</span>
<span style="color: #339933;">			}</span>
&nbsp;
<span style="color: #339933;">		]]&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:TextInput</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;usernameInput&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Set Username&quot;</span> <span style="color: #000066;">click</span>=<span style="color: #ff0000;">&quot;setUsername(event)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;{resourceManager.getString('labels', 'welcomeMessage', [_username, _date])}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>labels.properties</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">welcomeMessage</span>	<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">	Welcome <span style="">&#123;</span><span style="">0</span><span style="">&#125;</span> Today is <span style="">&#123;</span><span style="">1</span><span style="">&#125;</span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/10/20/using-tokens-in-resource-bundles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Keycodes</title>
		<link>http://www.lejnieks.com/2008/09/05/flex-keycodes/</link>
		<comments>http://www.lejnieks.com/2008/09/05/flex-keycodes/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 16:45:55 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=26</guid>
		<description><![CDATA[This is more a post-to-self regarding Key Code values in Flex. A = 65 B = 66 C = 67 D = 68 E = 69 F = 70 G = 71 H = 72 I = 73 J = 74 K = 75 L = 76 M = 77 N = 78 O = [...]]]></description>
			<content:encoded><![CDATA[<p>This is more a post-to-self regarding Key Code values in Flex.<br />
<span id="more-26"></span></p>
<p>A = 65<br />
B = 66<br />
C = 67<br />
D = 68<br />
E = 69<br />
F = 70<br />
G = 71<br />
H = 72<br />
I = 73<br />
J = 74<br />
K = 75<br />
L = 76<br />
M = 77<br />
N = 78<br />
O = 79<br />
P = 80<br />
Q = 81<br />
R = 82<br />
S = 83<br />
T = 84<br />
U = 85<br />
V = 86<br />
W = 87<br />
X = 88<br />
Y = 89<br />
Z = 90</p>
<p>CTRL + A = 1<br />
CTRL + B = 2<br />
CTRL + C = 3<br />
CTRL + D = 4<br />
CTRL + E = 5<br />
CTRL + F = 6<br />
CTRL + G = 7<br />
CTRL + H = 8<br />
CTRL + I = 9<br />
CTRL + J = 10<br />
CTRL + K = 11<br />
CTRL + L = 12<br />
CTRL + M = 13<br />
CTRL + N = 14<br />
CTRL + O = 15<br />
CTRL + P = 16<br />
CTRL + Q = 17<br />
CTRL + R = 18<br />
CTRL + S = 19<br />
CTRL + T = 20<br />
CTRL + U = 21<br />
CTRL + V = 22<br />
CTRL + W = 23<br />
CTRL + X = 24<br />
CTRL + Y = 25<br />
CTRL + Z = 26</p>
<p>ALT + A = 197<br />
ALT + B = 166<br />
ALT + C = 199<br />
ALT + D = 206<br />
ALT + E = 180<br />
ALT + F = 207<br />
ALT + G = 169<br />
ALT + H = 211<br />
ALT + I = 136<br />
ALT + J = 212<br />
ALT + K = 190<br />
ALT + L = 210<br />
ALT + M = 194<br />
ALT + N = 152<br />
ALT + O = 216<br />
ALT + P = 222<br />
ALT + Q = 140<br />
ALT + R = 174<br />
ALT + S = 205<br />
ALT + T = 134<br />
ALT + U = 168<br />
ALT + V = 175<br />
ALT + W = 221<br />
ALT + X = 188<br />
ALT + Y = 193<br />
ALT + Z = 253</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/09/05/flex-keycodes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Google Style Inline Auto Suggest Search Field</title>
		<link>http://www.lejnieks.com/2008/09/05/flex-google-style-inline-auto-suggest-search-field/</link>
		<comments>http://www.lejnieks.com/2008/09/05/flex-google-style-inline-auto-suggest-search-field/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 16:26:22 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=32</guid>
		<description><![CDATA[A quick little POC for building a drop down inline auto suggest, google style search field. The search is hitting a MySQL database populated with over 30,000 records, mind you some / a lot of them are duplicates and laziness forces me not to clean the data for this POC but it still proves the [...]]]></description>
			<content:encoded><![CDATA[<p>A quick little POC for building a drop down inline auto suggest, google style search field. The search is hitting a MySQL database populated with over 30,000 records, mind you some / a lot of them are duplicates and laziness forces me not to clean the data for this POC but it still proves the point. <span id="more-32"></span></p>
<p>Try it out below, you can see instant responses from the server back to flex creating a very responsive and realtime feel. The search is looking through over 30,000 records. View source is enabled as well. Click on the Search text field and try searching for general things like the letter &#8220;A&#8221; or more fine grained terms like &#8220;Led&#8221;. The search polls the database on a short interval using setTimeout().</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onKeyUp</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:KeyboardEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> TextInput<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		__interval = setTimeout<span style="color: #66cc66;">&#40;</span>query, <span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #66cc66;">&#123;</span>
		dgUserRequest.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><br/></p>
<p>You can modify the interval length, but from my testing I felt that 100 milliseconds was a good time for someone to type letter by letter and see instant responses, as well as not slow someone down who types rather fast and knows the search terms they are looking for.</p>
<p><object type="application/x-shockwave-flash" data="http://projects.lejnieks.com/flex_inline_search_poc/inline_search.swf" width="425" height="355" class="embedflash"><param name="movie" value="http://projects.lejnieks.com/flex_inline_search_poc/inline_search.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><small>(Please open the article to see the flash file or player.)</small></object></p>
<p>Source includes the MySQL database, Request.php which proctors the requests, and all the flex goodness. Source can be found here: <a href="http://projects.lejnieks.com/flex_inline_search_poc/inline_search.swf">http://projects.lejnieks.com/flex_inline_search_poc/inline_search.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/09/05/flex-google-style-inline-auto-suggest-search-field/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Passing arguments to javascript&#8217;s setTimeout() method using closures</title>
		<link>http://www.lejnieks.com/2008/08/21/passing-arguments-to-javascripts-settimeout-method-using-closures/</link>
		<comments>http://www.lejnieks.com/2008/08/21/passing-arguments-to-javascripts-settimeout-method-using-closures/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 18:07:34 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[fckEditor]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=30</guid>
		<description><![CDATA[Yesterday I ended up having to hack around FCKEditor a bit to &#8220;fine tune&#8221; it for a project im involved in. The problem was that the html text we needed from the editor was getting back to our app, I didnt touch the code at all except to add a console log (window.console.log()) and tada&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I ended up having to hack around FCKEditor a bit to &#8220;fine tune&#8221; it for a project im involved in. The problem was that the html text we needed from the editor was getting back to our app, I didnt touch the code at all except to add a console log (window.console.log()) and tada&#8230; it works now. Well it was aparent that the fckeditor was not getting to where i needed to get to fast enough.<br />
<span id="more-30"></span><br />
Javascript has a method setTimeout, which if you google this, youll find a bunch of related topics on setTimeout, setInterval, and clearTimeout etc&#8230; So I went with a setTimeout to simply call the next function i needed 1 millisecond later.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span> doAlert<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> doAlert<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Great! that works&#8230; but wait, I need to pass it a few variables. No problem i figured i could just add them inline right?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
<span style="color: #003366; font-weight: bold;">var</span> msg <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Hello World&quot;</span><span style="color: #339933;">;</span>
setTimeout<span style="color: #009900;">&#40;</span> doAlert<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> doAlert<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Wrong. this wont work in IE which sadly enough we have to support, and my argument that everyone should use firefox or safari just doesnt ever seem to hold water in a big corporation.</p>
<p>So I googled around and came across a post on <a href="http://lists.evolt.org/archive/Week-of-Mon-20040705/161085.html" target="_blank">evolt</a> showing how to add in parameters using closures. Now im not advocating the usage of closures, but I figure in this case it would have to do. So in the end my routine looked a little something like this</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
<span style="color: #003366; font-weight: bold;">var</span> msg <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Hello World&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> delay <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> doAlert<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
setTimeout<span style="color: #009900;">&#40;</span>delay<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> doAlert<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>this works like a champ on mac and windows in IE, FF, and safari.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/08/21/passing-arguments-to-javascripts-settimeout-method-using-closures/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Hello MXNA</title>
		<link>http://www.lejnieks.com/2008/07/31/hello-mxna/</link>
		<comments>http://www.lejnieks.com/2008/07/31/hello-mxna/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 03:43:17 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[MXNA]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=29</guid>
		<description><![CDATA[Long time listener, first time caller here, I’ve been aggregated by Adobe Feeds, and im looking forward to posting a lot more relevant information related to AIR, FLEX, RIA development through my experiences and research.]]></description>
			<content:encoded><![CDATA[<p>Long time listener, first time caller here, I’ve been aggregated by Adobe Feeds, and im looking forward to posting a lot more relevant information related to AIR, FLEX, RIA development through my experiences and research.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/07/31/hello-mxna/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling Keyboard Events</title>
		<link>http://www.lejnieks.com/2008/07/12/handling-keyboard-events/</link>
		<comments>http://www.lejnieks.com/2008/07/12/handling-keyboard-events/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 05:57:44 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=22</guid>
		<description><![CDATA[Im working on a project that required a Keyboard Manager to track shortcut keys within the Flex app, so i went ahead a wrote this quick little POC that I later incorporated into the project. I handle shortcut keys by adding and removing key listeners and mapping them to a dictionary of available keys. My [...]]]></description>
			<content:encoded><![CDATA[<p>Im working on a project that required a Keyboard Manager to track shortcut keys within the Flex app, so i went ahead a wrote this quick little POC that I later incorporated into the project. I handle shortcut keys by adding and removing key listeners and mapping them to a dictionary of available keys. My final implementation handled [cmd + shift + key] for windows and [alt + key] for mac switched based on Capabilities.os. <span id="more-22"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;vertical&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;onCreationComplete()&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">enum</span>.<span style="color: #006600;">KeyCodes</span>;
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _keyCodes:Dictionary;
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onCreationComplete<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				_keyCodes = <span style="color: #000000; font-weight: bold;">new</span> Dictionary<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
				addKeyCodes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
				addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, clickHandler<span style="color: #66cc66;">&#41;</span>;
				addEventListener<span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_DOWN</span>, <span style="color: #0066CC;">onKeyDown</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> clickHandler<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">focus</span> = <span style="color: #0066CC;">this</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> addKeyDownListeners<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> hasKeyUpListener:<span style="color: #0066CC;">Boolean</span> = hasEventListener<span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_UP</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #000000; font-weight: bold;">var</span> hasKeyDownListener:<span style="color: #0066CC;">Boolean</span> = hasEventListener<span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_DOWN</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>hasKeyUpListener<span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					addEventListener<span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_UP</span>,<span style="color: #0066CC;">onKeyUp</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>hasKeyDownListener<span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					removeEventListener<span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_DOWN</span>, <span style="color: #0066CC;">onKeyDown</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onKeyUp</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:KeyboardEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				addEventListener<span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_DOWN</span>,<span style="color: #0066CC;">onKeyDown</span><span style="color: #66cc66;">&#41;</span>;
				output_cmd.<span style="color: #0066CC;">text</span> = output_key.<span style="color: #0066CC;">text</span> = output_shift.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onKeyDown</span><span style="color: #66cc66;">&#40;</span>evt:KeyboardEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">os</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">os</span>;
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">os</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Windows&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">os</span> = <span style="color: #ff0000;">&quot;Windows&quot;</span>;
				<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">os</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Mac&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">os</span> = <span style="color: #ff0000;">&quot;Mac&quot;</span>;
&nbsp;
				<span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">os</span><span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;Windows&quot;</span>:
						handleWindowsKeyDown<span style="color: #66cc66;">&#40;</span> evt <span style="color: #66cc66;">&#41;</span>;
						<span style="color: #b1b100;">break</span>;
&nbsp;
					<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;Mac&quot;</span>:
						handleMacKeyDown<span style="color: #66cc66;">&#40;</span> evt <span style="color: #66cc66;">&#41;</span>;
						<span style="color: #b1b100;">break</span>;
&nbsp;
					<span style="color: #000000; font-weight: bold;">default</span>:
						<span style="color: #808080; font-style: italic;">//You are not on a supported OS</span>
						<span style="color: #b1b100;">break</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleMacKeyDown<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:KeyboardEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> keyTranslated:<span style="color: #0066CC;">String</span> = getKeyCodeTranslated<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">keyCode</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">altKey</span><span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					output_alt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;alt key is pressed&quot;</span>;
					<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> keyTranslated <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span>
					<span style="color: #66cc66;">&#123;</span>
						output_key.<span style="color: #0066CC;">text</span> = keyTranslated + <span style="color: #ff0000;">&quot; key is pressed&quot;</span>;
						addKeyDownListeners<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
					<span style="color: #66cc66;">&#125;</span>
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleWindowsKeyDown<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:KeyboardEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> keyTranslated:<span style="color: #0066CC;">String</span> = getKeyCodeTranslated<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">keyCode</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">ctrlKey</span><span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					output_cmd.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;cmd/ctrl key is pressed&quot;</span>;
&nbsp;
					<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">shiftKey</span><span style="color: #66cc66;">&#41;</span>
					<span style="color: #66cc66;">&#123;</span>
						output_shift.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;shift key is pressed&quot;</span>;
&nbsp;
						<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> keyTranslated <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span>
						<span style="color: #66cc66;">&#123;</span>
							output_key.<span style="color: #0066CC;">text</span> = keyTranslated + <span style="color: #ff0000;">&quot; key is pressed&quot;</span>;
							addKeyDownListeners<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
						<span style="color: #66cc66;">&#125;</span>
					<span style="color: #66cc66;">&#125;</span>
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> addKeyCodes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				_keyCodes = KeyCodes.<span style="color: #006600;">toDictionary</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getKeyCodeTranslated<span style="color: #66cc66;">&#40;</span> keyCode:uint <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">return</span> _keyCodes<span style="color: #66cc66;">&#91;</span>keyCode<span style="color: #66cc66;">&#93;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;output_cmd&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">&quot;#000000&quot;</span> borderStyle=<span style="color: #ff0000;">&quot;solid&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;output_shift&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">&quot;#000000&quot;</span> borderStyle=<span style="color: #ff0000;">&quot;solid&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Spacer <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;output_alt&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">&quot;#000000&quot;</span> borderStyle=<span style="color: #ff0000;">&quot;solid&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Spacer <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;output_key&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">&quot;#000000&quot;</span> borderStyle=<span style="color: #ff0000;">&quot;solid&quot;</span> <span style="color: #66cc66;">/&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>and the Enum to Dictionary Class</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">enum</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Dictionary</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">describeType</span>;
&nbsp;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> KeyCodes
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const A:uint = <span style="color: #cc66cc;">65</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const B:uint = <span style="color: #cc66cc;">66</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const C:uint = <span style="color: #cc66cc;">67</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const D:uint = <span style="color: #cc66cc;">68</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const <span style="color: #0066CC;">E</span>:uint = <span style="color: #cc66cc;">69</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const F:uint = <span style="color: #cc66cc;">70</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const G:uint = <span style="color: #cc66cc;">71</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const H:uint = <span style="color: #cc66cc;">72</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const I:uint = <span style="color: #cc66cc;">73</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const J:uint = <span style="color: #cc66cc;">74</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const K:uint = <span style="color: #cc66cc;">75</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const L:uint = <span style="color: #cc66cc;">76</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const M:uint = <span style="color: #cc66cc;">77</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const N:uint = <span style="color: #cc66cc;">78</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const O:uint = <span style="color: #cc66cc;">79</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const P:uint = <span style="color: #cc66cc;">80</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const Q:uint = <span style="color: #cc66cc;">81</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const R:uint = <span style="color: #cc66cc;">82</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const S:uint = <span style="color: #cc66cc;">83</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const T:uint = <span style="color: #cc66cc;">84</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const U:uint = <span style="color: #cc66cc;">85</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const V:uint = <span style="color: #cc66cc;">86</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const W:uint = <span style="color: #cc66cc;">87</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const X:uint = <span style="color: #cc66cc;">88</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const Y:uint = <span style="color: #cc66cc;">89</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const Z:uint = <span style="color: #cc66cc;">90</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const ALT_E:uint = <span style="color: #cc66cc;">180</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> KeyCodes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> toArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> keyCodes:<span style="color: #0066CC;">Array</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>;
			<span style="color: #000000; font-weight: bold;">var</span> classInfo:<span style="color: #0066CC;">XML</span> = describeType<span style="color: #66cc66;">&#40;</span>KeyCodes<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> v:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> classInfo..<span style="color: #006600;">constant</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>v.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
			    <span style="color: #000000; font-weight: bold;">var</span> value:<span style="color: #0066CC;">String</span> = KeyCodes<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span>;
			    keyCodes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			keyCodes.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> keyCodes;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> toDictionary<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Dictionary
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> keyCodesDict:Dictionary = <span style="color: #000000; font-weight: bold;">new</span> Dictionary<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> classInfo:<span style="color: #0066CC;">XML</span> = describeType<span style="color: #66cc66;">&#40;</span>KeyCodes<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> v:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> classInfo..<span style="color: #006600;">constant</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>v.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
			    <span style="color: #000000; font-weight: bold;">var</span> value:<span style="color: #0066CC;">String</span> = KeyCodes<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span>;
			    keyCodesDict<span style="color: #66cc66;">&#91;</span>value<span style="color: #66cc66;">&#93;</span> = <span style="color: #0066CC;">name</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">return</span> keyCodesDict;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><a href='http://www.lejnieks.com/wp-content/uploads/2008/07/flex_sample_keyboard_shortcuts.zip'>Download the source files here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/07/12/handling-keyboard-events/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex Debugger Crashes Safari</title>
		<link>http://www.lejnieks.com/2008/07/03/flex-debugger-crashes-safari/</link>
		<comments>http://www.lejnieks.com/2008/07/03/flex-debugger-crashes-safari/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 06:33:33 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=17</guid>
		<description><![CDATA[So I had one of those awful days at work yesterday, we have all been through it at one point or another, where basically for no reason at all, everything started breaking and nothing would work. All I wanted to do was walk through my application in the debugger, and what should have been a [...]]]></description>
			<content:encoded><![CDATA[<p>So I had one of those awful days at work yesterday, we have all been through it at one point or another, where basically for no reason at all, everything started breaking and nothing would work. All I wanted to do was walk through my application in the debugger, and what should have been a straight shot ended up turning into hours of troubleshooting my computer. The problem was when I would try to debug my flex app, safari would crash or hang or timeout.</p>
<p><span id="more-17"></span> I had no idea what was causing flex and safari to break down like this. Started looking through the typical places, opened the flex logs, opened my mac console, then opened the system monitor but nothing showed me anything really glaring. The application monitor did tell me my syslog was running wild which really just means, something is wrong&#8230; keep looking. I restarted my syslog and kept looking, but with no luck. I did a fresh install of Eclipse from 3.2 to 3.3, reinstalled Flex plugin, reinstalled the flash debug player, I even re-checked out the project from the repository, again, all to no avail.</p>
<p>I then turned to my good friend google&#8230; I found a ton of articles and jira tickets dealing with this problem but none of them really fixed the issue until&#8230; drum roll please&#8230; I came across <span><a href="http://www.fingersdancing.net/">Ross Phillips&#8217;s</a> blog. As I read through his post, he literally, word for word, had the exact same problem I had. </span></p>
<p>Basically, because I had been profiling the application two days ago, this ended up causing an issue with the debug player that resulted in the debug player crashing an hanging or not connecting at all. Ross found the solution <a href="http://www.fingersdancing.net/2008/06/flex-debugger-crashing-eclipse-safari.html">here</a> and while I don&#8217;t normally try to repost items like this (redundant blogging) i think this is a pretty common issue that might cause a lot of people a lot of angst and it definitely is worth a redundant post.</p>
<p>Ross&#8217;s solution, if your lazy and don&#8217;t want to click on the link above, is to open your mm.cfg file and remove the line in there relating to the profiler. Don&#8217;t worry, your still going to be able to profile your flex apps, this line will find its way back in here, so you&#8217;ll need to remove it again after you profile your app again but this way you can get back to debugging without interruption.</p>
<p>[Original Post]<br />
<a href="http://www.fingersdancing.net/2008/06/flex-debugger-crashing-eclipse-safari.html"> http://www.fingersdancing.net/2008/06/flex-debugger-crashing-eclipse-safari.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/07/03/flex-debugger-crashes-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 3 Profiler &amp; [tincan]</title>
		<link>http://www.lejnieks.com/2008/06/30/flex-3-profiler-tincan/</link>
		<comments>http://www.lejnieks.com/2008/06/30/flex-3-profiler-tincan/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 05:19:29 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=16</guid>
		<description><![CDATA[While profiling an application I&#8217;m working on I came across and interesting method in my performance snapshot. Method [tincan], for those of you wondering what this is, as I was, I Googled Flex 3 [tincan] and came across this post on flexcoders: http://www.mail-archive.com/flexcoders@yahoogroups.com/msg83781.html Basically [tincan] &#8220;&#8230;is the time processing RTMP messages&#8230;&#8221; A bit more investigating [...]]]></description>
			<content:encoded><![CDATA[<p>While profiling an application I&#8217;m working on I came across and interesting method in my performance snapshot. Method [tincan], for those of you wondering what this is, as I was, I Googled Flex 3 [tincan] and came across this post on <a href="http://tech.groups.yahoo.com/group/flexcoders">flexcoders</a>: <a href="http://www.mail-archive.com/flexcoders@yahoogroups.com/msg83781.html">http://www.mail-archive.com/flexcoders@yahoogroups.com/msg83781.html</a><br />
<span id="more-16"></span><br />
<strong>Basically [tincan] &#8220;&#8230;is the time processing RTMP messages&#8230;&#8221;</strong></p>
<p>A bit more investigating and reading up on the Profiler and i came across this:<a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Performance_and_Memory_Profiling#FAQ">http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Performance_and_Memory_Profiling#FAQ</a> explanation of bracketed functions found in the snapshots such as [verified]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/06/30/flex-3-profiler-tincan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Application Life Cycle</title>
		<link>http://www.lejnieks.com/2008/06/18/flex-application-life-cycle/</link>
		<comments>http://www.lejnieks.com/2008/06/18/flex-application-life-cycle/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 17:28:24 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=15</guid>
		<description><![CDATA[In the last project I was working on we were developing more so based on Flex&#8217;s Application and component life cycles. Binding data within the life cycle helps eliminate the need for weak references as well as direct mxml bindings which ill admit I have been know to over use. Recently a co-worker David Chang [...]]]></description>
			<content:encoded><![CDATA[<p>In the last project I was working on we were developing more so based on Flex&#8217;s Application and component life cycles. Binding data within the life cycle helps eliminate the need for weak references as well as direct mxml bindings which ill admit I have been know to over use.</p>
<p>Recently a co-worker <a href="http://nochump.com">David Chang</a> and I looked into the exact process Flex takes when initializing an application and its components and at what stages the data is available.<br />
<span id="more-15"></span><br />
A Flex application goes through 4 distinct events when initializing an application.</p>
<ol>
<li><strong>preinitialize</strong><br />
Dispatched at the beginning of the component initialization sequence, basically before anything else starts</li>
<li><strong>initialize</strong><br />
Dispatched when the component has finished its constructions and has all initialization properties set, this is done after all the other components have initialized themselves.</li>
<li><strong>creation complete</strong><br />
Dispatched when the component has finished its construction, property processing, measuring, layout, and drawing. This is done when all components have completed their creation.</li>
<li><strong>application complete</strong> (where applicable)
<p>Dispatched after the Application has been initialzed</li>
</ol>
<p>This is all fine and dandy except I wanted to get a more concrete illustration of what exactly is available and when, so I wrote up this quick little poc to show me in the debugger at what point data is available for the application and his components.<br />
<strong>Basic Application Life Cycle</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
<span style="color: #66cc66;">&lt;!</span>--<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
	<span style="color: #808080; font-style: italic;">/**
	 * Here we have no access to component / children level information,
	 * properties of any child in this application
	 * */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onPreinitialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;onPreinitialize() has no data will through an error in accessing component information&quot;</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/**
	 * Here we can access information about our children components,
	 * but not all information is accessible, notice width propety in text component
	 * is set to 0 and not the true width becuase this information has not been set yet
	 * */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onInitialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;onInitialize() text.text=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;, text.width=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">&quot;, text.x=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	override protected <span style="color: #000000; font-weight: bold;">function</span> createChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span>.<span style="color: #006600;">createChildren</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;override createChildren() text.text=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;, text.width=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">&quot;, text.x=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	override protected <span style="color: #000000; font-weight: bold;">function</span> childrenCreated<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span>.<span style="color: #006600;">childrenCreated</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;override childrenCreated() text.text=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;, text.width=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">&quot;, text.x=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&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>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span>.<span style="color: #006600;">commitProperties</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;override commitProperties() text.text=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;, text.width=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">&quot;, text.x=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&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>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span>.<span style="color: #006600;">measure</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;override measure() text.text=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;, text.width=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">&quot;, text.x=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/**
	 * At this point in the Application Life Cycle the children components
	 * have been created, they have run through thier own life cycles
	 * and all the information about them is available
	 * */</span>
	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>
	<span style="color: #66cc66;">&#123;</span>
		<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>;
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;override updateDisplayList() text.text=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;, text.width=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">&quot;, text.x=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onCreationComplete<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;onCreationComplete() text.text=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;, text.width=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">width</span> + <span style="color: #ff0000;">&quot;, text.x=&quot;</span> + <span style="color: #0066CC;">text</span>.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>--<span style="color: #66cc66;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/06/18/flex-application-life-cycle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Call Stack and callLater()</title>
		<link>http://www.lejnieks.com/2008/05/16/flex-call-stack-and-calllater/</link>
		<comments>http://www.lejnieks.com/2008/05/16/flex-call-stack-and-calllater/#comments</comments>
		<pubDate>Sat, 17 May 2008 04:47:10 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=25</guid>
		<description><![CDATA[Ive used callLater() quite a few times before, but about a week ago a co-worker asked me if I knew exactly when callLater() was called. Well I think its 1 millisecond after the method executes, to which he re-asked if its after the method or after the block of code executes? Great question, and I [...]]]></description>
			<content:encoded><![CDATA[<p>Ive used callLater() quite a few times before, but about a week ago a co-worker asked me if I knew exactly when callLater() was called. Well I think its 1 millisecond after the method executes, to which he re-asked if its after the method or after the block of code executes? Great question, and I honestly couldn&#8217;t with absolute certainty answer him so I went ahead and wrote this quick POC to prove the fact one way or another.<br />
<span id="more-25"></span><br />
Basically what I&#8217;m doing here is adding an initialize handler and a complete handler which will fire in that order except the initialize handler also has a callLater() call in it so what I expect to see is that the initialize function will fire the callLater function will fire then finally the complete handler will fire.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span>
	layout=<span style="color: #ff0000;">&quot;absolute&quot;</span>
	initialize=<span style="color: #ff0000;">&quot;onInitialize()&quot;</span>
	creationComplete=<span style="color: #ff0000;">&quot;onCreationComplete()&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// What we expect here is a trace output of</span>
			<span style="color: #808080; font-style: italic;">// Call 1 Call 3 Call 2, not Call 1 Call 2 Call 3</span>
			<span style="color: #808080; font-style: italic;">// this proves callLater dispatches a call directly</span>
			<span style="color: #808080; font-style: italic;">// 1 millisecond after the code black is done, that</span>
			<span style="color: #808080; font-style: italic;">// contains the callLater,</span>
			<span style="color: #808080; font-style: italic;">// not after all code blacks are done.</span>
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onInitialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;call 1&quot;</span><span style="color: #66cc66;">&#41;</span>;
				callLater<span style="color: #66cc66;">&#40;</span>trace3<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onCreationComplete<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;call 2&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> trace3<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;call 3&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>This proves to me with a concrete example that callLater gets fired 1 millisecond after the method its requested from fires.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/05/16/flex-call-stack-and-calllater/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Image Load I/O Error in Flex</title>
		<link>http://www.lejnieks.com/2008/05/09/image-load-io-error-in-flex/</link>
		<comments>http://www.lejnieks.com/2008/05/09/image-load-io-error-in-flex/#comments</comments>
		<pubDate>Sat, 10 May 2008 01:57:45 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=24</guid>
		<description><![CDATA[On a project im working on I ran into a very strange error when trying to load in a simple .jpg image. The image wouldn&#8217;t load. Now this sounds like a very familiar issue and easily solvable right? That what I thought too, but as it turns out, it turned into a couple hours of [...]]]></description>
			<content:encoded><![CDATA[<p>On a project im working on I ran into a very strange error when trying to load in a simple .jpg image. The image wouldn&#8217;t load. Now this sounds like a very familiar issue and easily solvable right? That what I thought too, but as it turns out, it turned into a couple hours of work and debugging. The issue wasn&#8217;t as simple as an incorrect url, network timeouts, dead links, etc&#8230; Debugging the complete() event shows the image was getting to where it had to get to and that flex felt that it did everything it had to do. So what was the problem with loading the image?<span id="more-24"></span></p>
<p>Flex can load .jpg, .png, .gif and so on&#8230; so why isnt the .jpg that was provided to me via the middle tier service loading in? Well it turns out that this wasn&#8217;t any ordinary jpeg, infact, it wasnt a jpeg at all. After a couple of hours of looking at everything under the sun, I finally looked into the image itself. I opened the image in <a href="http://hexedit.sourceforge.net/">HexEdit</a> and I noticed this .jpg file had a header of &#8220;BM&#8221;&#8230; thats a Bitmap not a jpeg. Try it out, open any jpeg you have in HexEdit or some kind of binary reader and notice the headers should read &#8220;JFIF&#8221; not &#8220;BM&#8230;&#8221;. Apparently the team responsible for submitting images to the content delivery system had saved a bitmap as a jpg by simply editing the file extension from .bmp to .jpg which im sure may have seemed harmless but in fact there is a so much more to it when you convert from one file format to another.</p>
<p>At the end of the day, it wasnt the worlds biggest issue but it did cause a delay and I figured maybe this could help anyone going through the same issue. Since then when I see image load I/O errors now I do the following to manage the issue</p>
<ul>
<ol>1. Check the URL of the image</ol>
<ol>2. Open the image in a Binary reader like HexEdit</ol>
<ol>3. Make sure the complete event fires</ol>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/05/09/image-load-io-error-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enum toArray()</title>
		<link>http://www.lejnieks.com/2008/03/29/enum-toarray/</link>
		<comments>http://www.lejnieks.com/2008/03/29/enum-toarray/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 06:50:31 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=13</guid>
		<description><![CDATA[There have been plenty of times that Ive needed to reuse the values of my enums as an array. A good example of this would be an enumeration of US states. There are many ways of doing this, however I find that writing an enumeration of static constants gives me the most flexibility and accuracy [...]]]></description>
			<content:encoded><![CDATA[<p>There have been plenty of times that Ive needed to reuse the values of my enums as an array. A good example of this would be an enumeration of US states. There are many ways of doing this, however I find that writing an enumeration of static constants gives me the most flexibility and accuracy in my code.</p>
<p><span id="more-13"></span></p>
<p>In a recent project I had a user registration form which has a drop down component for the state you live in. Because another area of my application required that I was able to test against a users state I created an enum of the US state. Now in this form I was trying to avoid retyping all of these states into the fields data provider, besides it being tremendously tedious, it breaks the DRY principle.</p>
<p>I remembered from a different conversation I had with <a href="http://eyefodder.com">paul</a> that there was a way to get actionscript to dump out the contents of a class into an xml list using <a href="http://livedocs.adobe.com/flex/201/langref/flash/utils/package.html#describeType()">describeType()</a></p>
<p>Using the describeType() method I was now able to get all of my constants in my class into a nice little array i could use as a data provider like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">lejnieks</span>.<span style="color: #006600;">poc</span>.<span style="color: #006600;">model</span>.<span style="color: #006600;">enums</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">describeType</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> USAStates
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const ALABAMA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Alabama&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const ALASKA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Alaska&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const ARIZONA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Arizona&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const ARKANSAS:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Arkansas&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const CALIFORNIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;California&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const COLORADO:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Colorado&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const CONNECTICUT:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Connecticut&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const DELAWARE:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Delaware&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const DISTRICT_OF_COLUMBIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;District Of Columbia&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const FLORIDA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Florida&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const GEORGIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Georgia&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const HAWAII:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Hawaii&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const IDAHO:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Idaho&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const ILLINOIS:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Illinois&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const INDIANA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Indiana&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const IOWA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Iowa&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const KANSAS:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Kansas&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const KENTUCKY:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Kentucky&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const LOUISIANA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Louisiana&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MAINE:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Maine&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MARYLAND:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Maryland&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MASSACHUSETTS:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Massachusetts&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MICHIGAN:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Michigan&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MINNESOTA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Minnesota&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MISSISSIPPI:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Mississippi&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MISSOURI:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Missouri&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MONTANA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Montana&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NEBRASKA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Nebraska&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NEVADA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Nevada&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NEW_HAMPSHIRE:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;New Hampshire&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NEW_JERSEY:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;New Jersey&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NEW_MEXICO:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;New Mexico&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NEW_YORK:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;New York&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NORTH_CAROLINA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;North Carolina&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const NORTH_DAKOTA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;North Dakota&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const OHIO:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Ohio&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const OKLAHOMA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Oklahoma&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const OREGON:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Oregon&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const PENNSYLVANIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Pennsylvania&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const RHODE_ISLAND:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Rhode Island&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const SOUTH_CAROLINA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;South Carolina&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const SOUTH_DAKOTA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;South Dakota&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const TENNESSEE:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Tennessee&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const TEXAS:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Texas&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const UTAH:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Utah&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const VERMONT:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Vermont&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const VIRGINIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Virginia&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const WASHINGTON:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Washington&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const WEST_VIRGINIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;West Virginia&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const WISCONSIN:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Wisconsin&quot;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const WYOMING:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Wyoming&quot;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> USAStates<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> toArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> states:<span style="color: #0066CC;">Array</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>;
			<span style="color: #000000; font-weight: bold;">var</span> classInfo:<span style="color: #0066CC;">XML</span> = describeType<span style="color: #66cc66;">&#40;</span>USAStates<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> v:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> classInfo..<span style="color: #006600;">constant</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>v.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
			    	<span style="color: #000000; font-weight: bold;">var</span> value:<span style="color: #0066CC;">String</span> = USAStates<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span>;
			    	states.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			states.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> states;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now I can use my standard enum as an array or dataprovider like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:ComboBox id=<span style="color: #ff0000;">&quot;state&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;250&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{USAStates.toArray()}&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/03/29/enum-toarray/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Externalizing CSS Text for Designer</title>
		<link>http://www.lejnieks.com/2008/03/29/externalizing-css-text-for-designer/</link>
		<comments>http://www.lejnieks.com/2008/03/29/externalizing-css-text-for-designer/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 17:18:18 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Skinning]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=10</guid>
		<description><![CDATA[Heres a quick and easy way to separate font styles from component styles which will allow ux teams to skin fonts independent of the development team or even independent of the encapsulating component itself. This all came up from a project im involved with right now requires a high regard to pixel perfect design, which [...]]]></description>
			<content:encoded><![CDATA[<p>Heres a quick and easy way to separate font styles from component styles which will allow ux teams to skin fonts independent of the development team or even independent of the encapsulating component itself. This all came up from a project im involved with right now requires a high regard to pixel perfect design, which meant a lot of back and forth between the ux team. Font rendering was clearly something that needed some direct tweaking from the ux guys. while I do think i have a pretty good eye for design, they are ultimately the ones who will sign off of subpixel  font grid type fitting and so on. So now my goal was to separate as much of the text formatting from the components and hopefully normalize it as best as possible as well.</p>
<p><span id="more-10"></span></p>
<p>The separation and normalization went pretty well and reduced my css doc by about 1200 lines, however there were still elements of font control that i could not external, mostly in components like buttons. I didnt want to have the redundancy and overhead of</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">CustomButton
<span style="color: #66cc66;">&#123;</span>
	font-family : 	<span style="color: #ff0000;">&quot;Myriad Pro Bold&quot;</span>;
	font-weight :	normal;
	font-style : 	normal;
	font-<span style="color: #0066CC;">size</span> :	<span style="color: #cc66cc;">11</span>;
	font-sharpness : 	<span style="color: #cc66cc;">0</span>;
	font-thickness : 	<span style="color: #cc66cc;">0</span>;
	letter-spacing :	.1;
	font-anti-alias-<span style="color: #0066CC;">type</span> :	advanced;
	font-grid-fit-<span style="color: #0066CC;">type</span> :	subpixel;
	text-<span style="color: #0066CC;">align</span> :	center;
	<span style="color: #0066CC;">color</span> :	<span style="color: #808080; font-style: italic;">#ff3300;</span>
	textRollOverColor :	<span style="color: #808080; font-style: italic;">#ffffff;</span>
	textSelectedColor :	<span style="color: #808080; font-style: italic;">#CC0000;</span>
	fillAlphas : <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>;
	fillColors : <span style="color: #808080; font-style: italic;">#ffffff, #ffffff, #0099cc, #0099cc;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>I was looking for a way to separate the design from the code in my styles similar to how the datagrid has references to text css</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:DataGrid headerStyleName=<span style="color: #ff0000;">&quot;customHeaderStyleName&quot;</span></pre></td></tr></table></div>

<p>so I looked around for a way to pull the text styles out of different components so the ux group can easily styles the different fonts in the application without having to worry about the actual component. After looking around I discovered most components can override the textStyle or similar such as</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomButton <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">Button</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CustomButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	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>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> textFieldStyleName:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;buttonLabelStyleName&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">textField</span>.<span style="color: #006600;">styleName</span> = textFieldStyleName;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>this works exactly as i had hoped, now the ux group can set fonts independent of the components and spend the needed time exacting their fonts.</p>
<p>You can see a sample below, side click for the source.<br />
<object type="application/x-shockwave-flash" data="http://projects.lejnieks.com/Sample_externalized_css_textStyle/SampleCSSTextStyle.swf" width="425" height="355" class="embedflash"><param name="movie" value="http://projects.lejnieks.com/Sample_externalized_css_textStyle/SampleCSSTextStyle.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><small>(Please open the article to see the flash file or player.)</small></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/03/29/externalizing-css-text-for-designer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Photoshop Express</title>
		<link>http://www.lejnieks.com/2008/03/27/adobe-photoshop-express/</link>
		<comments>http://www.lejnieks.com/2008/03/27/adobe-photoshop-express/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 23:43:02 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[cool stuff]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=3</guid>
		<description><![CDATA[Adobe Photoshop Express, a cool little flex app offering up some bare bones features picasa style. Nonetheless its a very clean interface, very well done, and just good fun to play with. Signing up is pretty painless, you get 2gb of storage, and a custom url for your account. Signup for the beta here]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-6" href="http://lejnieks.com/2008/03/adobe-photoshop-express/picture-14/"><img class="alignleft size-thumbnail wp-image-6" title="Photoshop Express " src="http://lejnieks.com/wp-content/picture-14-150x150.png" alt="" width="150" height="150" /></a>Adobe Photoshop Express, a cool little flex app offering up some bare bones features picasa style. Nonetheless its a very clean interface, very well done, and just good fun to play with.<br />
Signing up is pretty painless, you get 2gb of storage, and a custom url for your account. Signup for the beta  <a title="Photoshop Express" href="https://www.photoshop.com/express/i" target="_blank">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/03/27/adobe-photoshop-express/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex skinning links</title>
		<link>http://www.lejnieks.com/2008/01/29/flex-skinning-links/</link>
		<comments>http://www.lejnieks.com/2008/01/29/flex-skinning-links/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 17:35:52 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Skinning]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=12</guid>
		<description><![CDATA[Just a quick list of some links for skinning in flex, programmatic, graphic, or what have you. Ill be updating this list here and there as I consolidate more links. http://www.adobe.com/devnet/flex/articles/flex_skins_09.html http://examples.adobe.com/flex2/consulting/styleexp&#8230; http://scalenine.com/blog/2007/02/17/10-ways-to-skin-an-app/ http://scalenine.com/blog http://www.onflex.org/ted/2007/11/managing-ui-development-e&#8230; http://blog.flexexamples.com/2007/12/06/installing-the-flex-skin-design-&#8230; http://blog.flexexamples.com http://www.yswfblog.com/blog/2007/12/13/yahoo-and-flex-fee&#8230; http://www.tombray.com/2007/12/17/heres-a-tip-if-you-want-to-use-runti&#8230; http://www.nutrixinteractive.com/blog/?p=86 http://www.spacedust.be/?p=44 http://agileui.blogspot.com/2008/01/flex-3-programmatic-skinning-gotcha.html http://www.rictus.com/muchado/2007/10/10/stateful-skins-using-mxml/ http://www.rictus.com/muchado/2007/10/04/fillcolorscom-flex-skin-contest/ http://labs.flexcoders.nl/?p=103 http://www.websector.de/blog/2007/07/04/skinning-flex-containers-usin&#8230; http://www.colettas.org/?p=74 http://www.rictus.com/muchado/2006/07/31/loading-flex-skins-at-runtime/ http://www.onflex.org/ted/2007/01/flex-201-understand-runtime-css.php http://store1.adobe.com/devnet/flex/quickstart/skinning_components/ http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/htm&#8230; http://www.adobe.com/devnet/flex/design.html http://www.onflex.org/ted/2006/08/skinning-and-theme-support-by-glenn.php http://www.cynergysystems.com/blogs/page/andrewtrice?entry=my&#8230; http://www.adobe.com/devnet/flex/articles/flex_skins.html [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick list of some links for skinning in flex, programmatic, graphic, or what have you.<br />
Ill be updating this list here and there as I consolidate more links.</p>
<p><span id="more-12"></span></p>
<p><a href="http://www.adobe.com/devnet/flex/articles/flex_skins_09.html">http://www.adobe.com/devnet/flex/articles/flex_skins_09.html</a></p>
<p><a href="http://scalenine.com/blog/2007/02/17/10-ways-to-skin-an-app/">http://examples.adobe.com/flex2/consulting/styleexp&#8230;</a></p>
<p><a href="http://scalenine.com/blog">http://scalenine.com/blog/2007/02/17/10-ways-to-skin-an-app/</a></p>
<p><a href="http://www.onflex.org/ted/2007/11/managing-ui-development-expectations.php">http://scalenine.com/blog</a></p>
<p><a href="http://www.onflex.org/ted/2007/11/managing-ui-development-expectations.php">http://www.onflex.org/ted/2007/11/managing-ui-development-e&#8230;</a></p>
<p><a href="http://blog.flexexamples.com/2007/12/06/installing-the-flex-skin-design-extensions-for-cs3-from-adobe-labs/">http://blog.flexexamples.com/2007/12/06/installing-the-flex-skin-design-&#8230;</a></p>
<p><a href="http://blog.flexexamples.com">http://blog.flexexamples.com</a></p>
<p><a href="http://www.yswfblog.com/blog/2007/12/13/yahoo-and-flex-feel-good-in-your-own-skin/">http://www.yswfblog.com/blog/2007/12/13/yahoo-and-flex-fee&#8230;</a></p>
<p><a href="http://www.tombray.com/2007/12/17/heres-a-tip-if-you-want-to-use-runtime-styles-in-your-flex-apps/">http://www.tombray.com/2007/12/17/heres-a-tip-if-you-want-to-use-runti&#8230;</a></p>
<p><a href="http://www.nutrixinteractive.com/blog/?p=86">http://www.nutrixinteractive.com/blog/?p=86</a></p>
<p><a href="http://www.spacedust.be/?p=44">http://www.spacedust.be/?p=44</a></p>
<p><a href="http://agileui.blogspot.com/2008/01/flex-3-programmatic-skinning-gotcha.html">http://agileui.blogspot.com/2008/01/flex-3-programmatic-skinning-gotcha.html</a></p>
<p><a href="http://www.rictus.com/muchado/2007/10/10/stateful-skins-using-mxml/">http://www.rictus.com/muchado/2007/10/10/stateful-skins-using-mxml/</a></p>
<p><a href="http://www.rictus.com/muchado/2007/10/04/fillcolorscom-flex-skin-contest/">http://www.rictus.com/muchado/2007/10/04/fillcolorscom-flex-skin-contest/</a></p>
<p><a href="http://labs.flexcoders.nl/?p=103">http://labs.flexcoders.nl/?p=103</a></p>
<p><a href="http://www.websector.de/blog/2007/07/04/skinning-flex-containers-using-wsdoubleborderskin/">http://www.websector.de/blog/2007/07/04/skinning-flex-containers-usin&#8230;</a></p>
<p><a href="http://www.colettas.org/?p=74">http://www.colettas.org/?p=74</a></p>
<p><a href="http://www.rictus.com/muchado/2006/07/31/loading-flex-skins-at-runtime/">http://www.rictus.com/muchado/2006/07/31/loading-flex-skins-at-runtime/</a></p>
<p><a href="http://www.onflex.org/ted/2007/01/flex-201-understand-runtime-css.php">http://www.onflex.org/ted/2007/01/flex-201-understand-runtime-css.php</a></p>
<p><a href="http://store1.adobe.com/devnet/flex/quickstart/skinning_components/">http://store1.adobe.com/devnet/flex/quickstart/skinning_components/</a></p>
<p><a href="http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00000800.html">http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/htm&#8230;</a></p>
<p><a href="http://www.adobe.com/devnet/flex/design.html">http://www.adobe.com/devnet/flex/design.html</a></p>
<p><a href="http://www.onflex.org/ted/2006/08/skinning-and-theme-support-by-glenn.php">http://www.onflex.org/ted/2006/08/skinning-and-theme-support-by-glenn.php</a></p>
<p><a href="http://www.cynergysystems.com/blogs/page/andrewtrice?entry=my_presentation_on_skinning_amp">http://www.cynergysystems.com/blogs/page/andrewtrice?entry=my&#8230;</a></p>
<p><a href="http://www.adobe.com/devnet/flex/articles/flex_skins.html">http://www.adobe.com/devnet/flex/articles/flex_skins.html</a></p>
<p><a href="http://blog.kevinhoyt.org/2006/02/03/programmatic-skinning-with-flex-2">http://blog.kevinhoyt.org/2006/02/03/programmatic-skinning-with-flex-2</a></p>
<p><a href="http://www.fillcolors.com/">http://www.fillcolors.com/</a></p>
<p><a href="http://fleksray.org/Flex_skin.html">http://fleksray.org/Flex_skin.html</a></p>
<p><a href="http://flex.org/showcase/">http://flex.org/showcase/</a></p>
<p><a href="http://mannu.livejournal.com/305284.html">http://mannu.livejournal.com/305284.html</a></p>
<p><a href="http://www.flexdaddy.info/2006/02/06/how-to-skin-flex-20/">http://www.flexdaddy.info/2006/02/06/how-to-skin-flex-20/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/01/29/flex-skinning-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Talk to your view through your command</title>
		<link>http://www.lejnieks.com/2008/01/29/talk-to-your-view-through-your-command/</link>
		<comments>http://www.lejnieks.com/2008/01/29/talk-to-your-view-through-your-command/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 17:30:43 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=11</guid>
		<description><![CDATA[Admittedly, this is something I have grappled with for quite some time now, and apparently I&#8217;m not the only one. This is by no means a hot topic but for my own purposes, and as I venture deeper into the world of &#8220;Best Practices&#8221; and the pursuit of architectural sanity I felt that this was [...]]]></description>
			<content:encoded><![CDATA[<p>Admittedly, this is something I have grappled with for quite some time now, and apparently I&#8217;m not the only one.  This is by no means a hot topic but for my own purposes, and as I venture deeper into the world of &#8220;Best Practices&#8221; and the pursuit of architectural sanity I felt that this was worth a post.<span id="more-11"></span></p>
<p>I recently found the need for my command to effect a change in my view, specifically, I am loading a config file into my application, once that config has loaded I wanted to popup a login screen on the main application view. The way I have this working now I have my LoadConfigCommand request the xml config file through a delegate then respond back to the commands result handler. LoadConfigCommand&#8217;s result method needs to then popup a login window. This could easily be solved by using</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">     <span style="color: #000000; font-weight: bold;">var</span> appReference:DisplayObject = DisplayObject<span style="color: #66cc66;">&#40;</span> Application.<span style="color: #006600;">application</span> <span style="color: #66cc66;">&#41;</span>;
     <span style="color: #000000; font-weight: bold;">var</span> popup:IFlexDisplayObject = PopUpManager.<span style="color: #006600;">createPopUp</span><span style="color: #66cc66;">&#40;</span> appReference, Login, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>but I am not particularly partial to using Application.application references as it has gotten me into trouble a few times before. While this is a valid solution to this, it doesnt fit the needs or solve the problem of talking to my view through my command, at best this is only a bridge to my view, and as more complex problem arise in this realm this quickly becomes a brittle if not unmanageable solution.</p>
<p>So where does this leave me? Research. I looked around, for what others have been doing to solve this problem, and came across a few very interesting approaches. I came across <a href="http://jessewarden.com/2005/11/cairngorms-viewlocator-viewhelpers-explained-for-flash-developers.html" target="_blank">Jesse Warden&#8217;s</a> post on ViewHelpers in Cairngorm to see if I could access my views using the ViewHelpers ViewLocator. I went ahead and registered my views but when it came time to accessing the methods of my views it became apparent that I would need to cast my viewLocator with my View itself:  Projects( ViewLocator.getInstance().getViewHelper(&#8220;projectsHelper&#8221;) ).doLogin(); which to me seems contrary. To use this solution I will be going against to core principals of mvc and cairngorm by introducing a reference of my view into my command, and for that matter for this example I might as well just do: Projects.doLogin() as this is essentially the same solution to this problem. Next I read about <a href="http://weblogs.macromedia.com/auhlmann/archives/2007/02/creating_a_popu.cfm" target="_blank">Alex&#8217;s</a> post on creating a popup window in Cairngorm. Seems like this will work. I started reading more about it, and his usage of the Observer pattern to listent to changes in the model. Alex writes that he is setting a boolean value in his model from his command, and listening for this change through ObserveValue. Again this is a perfectly viable solution to this problem as well, however the more complex the problem becomes, and the more I need to  listen to changes in my model to effect changes in my view this will quickly become a cluttered and almost unidentifiable clutter of boolean values in my model. Besides my view may need to have multiple states which surpass the simple values of True and False.</p>
<p>So im still stumped at this point&#8230; I message <a href="http://eyefodder.com">Paul</a> over at AC to get his views on the matter and hopefully gain some knowledge on the best solution for this. My question to him was &#8220;how do I speak to a view from a command&#8221;.  His logic is, well&#8230; logical. He told me that in architectural decisions if it doesn&#8217;t feel right, it inst right. Think about what the popup represents, a view state change. State change being the optimal word here. Since this is a state change and state is maintained in the model its perfectly inline to have my view listen to my model for a change that is set by my command. This is similar to Alex&#8217;s recommendation however by not using boolean values and binding the view using mx:Binding instead of ObeserveValue I am able to listen to more profound change values such as var applicationState:String = &#8220;preloading&#8221; and then wrap this bound value to a switch case that my view will decide what to do with when a change has been made. The differences between the two paths, from my view, is that Alex&#8217;s solution forces the model to maintain distinct state values for each and every change so that in the event that your single view may have 5 or 6 or more changes then you would have 5 or 6 or more corresponding state values of type boolean in your model that your views would listen to individually whereas by having a single state variable I can write in as many state changes as I need and match them on the switch case in my view.</p>
<p>So lets think about this a bit more abstractly. lets remove the popup example as we have many ways of achieving a solution to this. Lets think about this example: I have an image viewer / editor application, my main application view has a collapsible toolbar that is defaulted to open. The user clicks on the preview button which goes through the Cairngorm daisy chain to get to my command. once at my command I want to hide a few things and show a few things, including hiding my toolbar which at this point is no longer needed the user is now previewing. From my command, using the solution above, I have set a variable in my model var viewMode:ViewModes = ViewModes.EDITOR;  which from my command I will set a from EDITOR to PLAYER so my model will now show viewMode:ViewModes = ViewModes.PLAYER. My main application view is bound to this variable using mx:Binding and is set to a setter in the same view. The setter goes through a quick switch case to determine what to do based on the value set and then reacts accordingly, in this instance it hides the toolbar.</p>
<p>My issue here was that I felt that there must be a way to communicate directly to the view on low levels requests, things that didnt seem logical to clutter the model with, maybe some variation of the ViewLocator might have worked in this instance to gain access to the view for such requests. Well Paul broke this down in a very logical way that to me seems like a good rule of thumb for this problem:</p>
<blockquote><p>If there is a material change in state<br />
If several views would need to respond<strong><br />
Then stick it in the model and bind currentState to the var</strong></p>
<p>If its just in 1 component (for example changing the text on a submit button while waiting for a response)<br />
If it seems just plain pernickity<strong><br />
Then have that logic in the view</strong></p></blockquote>
<blockquote><p>MOST OF ALL:<strong><br />
design and architect and develop in such a way that allows you to change your mind </strong></p></blockquote>
<p>So my take on this is that, when I need to talk to my view all the way from my command, I need to:</p>
<blockquote><p>First identify why I want to talk to my view in the first place</p>
<ul>
<li>Is this something the View can handle on its own</li>
<li>Does this demand to wait for something to happen from the command</li>
<li>Is this a state change</li>
<li>Will more then one view listen to this change</li>
</ul>
<p>Write my command&#8217;s result to set the change variable in the model<br />
Listen to this change through Binding in the various views that will be effected by the change</p></blockquote>
<p>And there you have it, through good clean code and a bit of organization my model will be filled with state as it well should be and my various and infinite views will listen to those states and react to the changes set by my commands.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/01/29/talk-to-your-view-through-your-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
