<?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>Lab49 Blog &#187; ActionScript</title>
	<atom:link href="http://blog.lab49.com/archives/category/advanced-visualization/actionscript/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.lab49.com</link>
	<description>Technology and industry insights from Lab49.</description>
	<lastBuildDate>Wed, 08 Feb 2012 09:02:55 +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>EventDispatcher vs. Signals</title>
		<link>http://www.michelboudreau.com/2010/12/31/eventdispatcher-vs-signals/</link>
		<comments>http://www.michelboudreau.com/2010/12/31/eventdispatcher-vs-signals/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 15:49:35 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Advanced Visualization]]></category>
		<category><![CDATA[Lab49]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=628</guid>
		<description><![CDATA[At our last Flex Meetup, Adam Spektor did an overview of AS3Signals (by Robert Penner) which brought up some interesting questions about why developers would use Signals over regular Events.  I decided that I would test it out and benchmark both methods, meanwhile evaluating the pros and cons of each.  To be able to test [...]]]></description>
			<content:encoded><![CDATA[<p>At our last <a href="http://www.meetup.com/New-York-Flex-Meetup/" >Flex Meetup</a>, Adam Spektor did an overview of <a href="https://github.com/robertpenner/as3-signals" >AS3Signals</a> (by <a href="http://flashblog.robertpenner.com/" >Robert Penner</a>) which brought up some interesting questions about why developers would use Signals over regular Events.  I decided that I would test it out and benchmark both methods, meanwhile evaluating the pros and cons of each.  To be able to test the results, I created a FlexUnit project that would test the creation and dispatch of one event, and then the dispatch of a thousand events.  In one test case, I would test a single Signal and in the other test case I would just create a central EventDispatcher to try to mimic Signals.  You can find the project <a href="http://www.michelboudreau.com/wp-content/uploads/2010/12/EventBenchmark.zip">here</a>, but the real important part is the execution time of each one.</p>
<p><span id="more-628"></span></p>
<p><strong>Results</strong></p>
<table class="datatable" style="border-collapse: collapse; width: 400px;">
<tbody>
<tr style="text-align: center;">
<td style="border-right: 3px solid white;"></td>
<td style="border-right: 3px solid white;" colspan="2"><strong>Event Dispatcher</strong></td>
<td colspan="2"><strong>Signals</strong></td>
</tr>
<tr style="text-align: center;">
<td style="border-right: 3px solid white;"></td>
<td>1 event</td>
<td style="border-right: 3px solid white;">1000 events</td>
<td>1 event</td>
<td>1000 events</td>
</tr>
<tr style="text-align: center;">
<td style="text-align: left; border-right: 3px solid white;"><strong>Trial 1</strong></td>
<td>26ms</td>
<td style="border-right: 3px solid white;">15ms</td>
<td>9ms</td>
<td>25ms</td>
</tr>
<tr style="text-align: center;">
<td style="text-align: left; border-right: 3px solid white;"><strong>Trial 2</strong></td>
<td>15ms</td>
<td style="border-right: 3px solid white;">55ms</td>
<td>11ms</td>
<td>20ms</td>
</tr>
<tr style="text-align: center;">
<td style="text-align: left; border-right: 3px solid white;"><strong>Trial 3</strong></td>
<td>47ms</td>
<td style="border-right: 3px solid white;">18ms</td>
<td>19ms</td>
<td>16ms</td>
</tr>
<tr style="text-align: center;">
<td style="text-align: left; border-right: 3px solid white;"><strong>Trial 4</strong></td>
<td>51ms</td>
<td style="border-right: 3px solid white;">15ms</td>
<td>15ms</td>
<td>25ms</td>
</tr>
<tr style="text-align: center;">
<td style="text-align: left; border-right: 3px solid white;"><strong>Average<br />
</strong></td>
<td><strong>34.75ms</strong></td>
<td style="border-right: 3px solid white;"><strong>25.75ms</strong></td>
<td><strong>13.5ms</strong></td>
<td><strong>21.5ms</strong></td>
</tr>
<tr>
<td style="border-right: 3px solid white;"><strong>Total</strong></td>
<td style="text-align: center; border-right: 3px solid white;" colspan="2"><strong>60.5ms</strong></td>
<td style="text-align: center;" colspan="2"><strong>35ms<br />
</strong></td>
</tr>
</tbody>
</table>
<p>Now, a few things about this data.  The Signals library was very consistent in the times outputted, however the EventDispatcher was very erratic.  You can see it a little here within the results, but these results were fairly tame.  During testing, I&#8217;ve seen spikes going both high and low.  I&#8217;ve also seen it several times being faster than Signals.  I&#8217;ve tried to find an explanation about why and all I could think of is because the EventDispatcher is so intertwined with Flash Player and that could affect the test somehow but this is all speculation.</p>
<p>Because of this inconsistency, it&#8217;s hard to interpret the data for the EventDispatcher, so instead let&#8217;s concentrate more on the Signals side.  You&#8217;ll notice that the time taken is fairly consistent and would work as expected (one event is faster than a thousand).  When I first heard of Signals, my first thought was that this would be faster than normal events, and the data clearly shows this by 173%.</p>
<p>Signals is fast, there&#8217;s no doubt about it, but will incorporating it in your project actually increase overall speed?  Will it actually benefit development?</p>
<p>Personally, I don&#8217;t think I would personally use it in my project for a few different reasons:</p>
<ol>
<li>It&#8217;s not native to Flash/Flex.  Some may dismiss this point, but when you have a whole system based upon EventDispatcher and Events, it&#8217;s hard to ignore.</li>
<li>Lack of bubbling and capture.  Signals is working on bubbling, but I doubt they will get it working as well as the native implementation.</li>
<li>There is no meta-data possible for Signals.  This severely limits the possibility of using signals in MXML.</li>
<li>Need to recreate all event variables for Signals all over again.  Signals tries to reduce boiler-plate code by dismissing custom Event classes, but you still need to create new variables in the class for the event which essentially cancel each other out.</li>
<li>Keeping two separate standards for events in one system is a maintenance nightmare.</li>
<li>Little speed gain for the amount of extra work needed to get it working in a system.</li>
</ol>
<p>All and all, I think Signals is a very good idea for performance and extra utility, however it seems to me that the concept is Utopian.  If we could swap out the native event mechanism of Flash, then I&#8217;d be all for it, but in my current situation it isn&#8217;t very realistic to replace a current system that works (very well I might add) with another that&#8217;s slightly faster and more convenient.  The pros simply do not outweigh the cons.  If I were to use Signals, it would be in a very small Actionscript only project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/12/31/eventdispatcher-vs-signals/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextInput Prompt Component</title>
		<link>http://www.michelboudreau.com/2010/11/24/textinput-prompt-component/</link>
		<comments>http://www.michelboudreau.com/2010/11/24/textinput-prompt-component/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 01:36:48 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Advanced Visualization]]></category>
		<category><![CDATA[Lab49]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=603</guid>
		<description><![CDATA[Last week at the Lab49 sponsored Flex vs. Silverlight Bakeoff, my team (Flex) had an issue when we wanted to create a simple text input component with a prompt.&#160; This isn&#8217;t something that I use particularly often, but for some reason I had a memory of some kind of prompt property.&#160; To my surprise however, [...]]]></description>
			<content:encoded><![CDATA[<p>Last week at the <a href="http://www.lab49.com" >Lab49</a> sponsored <a href="http://www.ustream.tv/recorded/10919997" >Flex vs. Silverlight Bakeoff</a>, my team (Flex) had an issue when we wanted to create a simple text input component with a prompt.&nbsp; This isn&#8217;t something that I use particularly often, but for some reason I had a memory of some kind of prompt property.&nbsp; To my surprise however, Flex 4.1 did not have a prompt property on the TextInput component, even though it is a fairly sought after feature.</p>
<p><span id="more-603"></span>In the end, we opted for a quick implementation of it, but it wasn&#8217;t up to the standards of Spark.&nbsp; This is where this post comes in.&nbsp; Searching online quickly listed a lot of different variations on how to do it, but many of them resembled my first attempt and didn&#8217;t take advantage of Spark skinning.&nbsp; I chose to rectify this by creating my own PromptTextInput that is highly skinnable, stylable and to my knowledge, uses the best Spark practices.</p>
<p>One quick note before diving into the code; while I was trying to implement this, I was surprised to find that you could not extend TextInput via MXML.&nbsp; It has to be done in Actionscript.&nbsp; This is no doubt a bug in the compiler.&nbsp; The error? &#8220;<em>Multiple initializer values for default property, &#8216;text&#8217;, of type &#8216;String&#8217;</em>.&#8221;&nbsp; This because the &#8216;defaultProperty&#8217; of TextInput is &#8216;text&#8217;, which means anything that&#8217;s placed in between the TextInput tag is expected to be the text that&#8217;s going to be displayed.&nbsp; In this case though, when trying to just add a Script tag, it would give this error.&nbsp; Very annoying.&nbsp;&nbsp; Moving on however to the actual implementation.&nbsp; First the component itself.&nbsp; Or just <a href="http://www.michelboudreau.com/wp-content/uploads/2010/11/PromptTextInput.zip">download the project</a>.</p>
<pre class="brush: as3; title: ;">
package com.michelboudreau.view.components
{
	import com.michelboudreau.view.skins.PromptTextInputSkin;
	import flash.events.FocusEvent;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import spark.components.Label;
	import spark.components.TextInput;

	// Extra skin states that we need to show prompt
	[SkinState(&quot;normalWithPrompt&quot;)]
	[SkinState(&quot;disabledWithPrompt&quot;)]

	public class PromptTextInput extends TextInput
	{
		// Create a new skin part that will display our prompts
		[SkinPart(required=&quot;false&quot;)]
		public var promptDisplay:Label;

		private var _prompt:String; // Holds the value of the prompt text
		private var _promptChanged:Boolean; // Flag for the invalidation
		private var _inFocus:Boolean = false; // Flag used to know if in focus

		// New state constants
		static protected const NORMAL_WITH_PROMPT:String = 'normalWithPrompt';
		static protected const DISABLED_WITH_PROMPT:String = 'disabledWithPrompt';

		public function PromptTextInput()
		{
			super();
			this.addEventListener(FocusEvent.FOCUS_IN, onFocus);
			this.addEventListener(FocusEvent.FOCUS_OUT, onFocus);

			// sets the default skin
			setStyle(&quot;skinClass&quot;, PromptTextInputSkin);
		}

		[Bindable]
		public function get prompt():String
		{
			return _prompt;
		}

		public function set prompt(value:String):void
		{
			this._prompt = value;
			this._promptChanged = true;
			invalidateProperties();
		}

		/**
		 * Adding the prompt text to the label if it's available
		 */
		override protected function commitProperties():void
		{
			super.commitProperties();

			if (this._promptChanged)
			{
				if (promptDisplay)
				{
					promptDisplay.text = prompt;
				}
				this._promptChanged = false;
			}
		}

		/**
		 * Changing the logic to add our new skin states
		 *
		 * @return The state that the skin should change to
		 */
		override protected function getCurrentSkinState():String
		{
			if(!this._inFocus &amp;&amp; text.length == 0)
			{
				if(enabled)
				{
					return NORMAL_WITH_PROMPT;
				}else{
					return DISABLED_WITH_PROMPT;
				}
			}else{
				return super.getCurrentSkinState();
			}
		}

		/**
		 * Listen to see if the prompt label is being created and add
		 * prompt text to it.
		 *
		 * @param partName:String
		 * @param instance:Object
		 */
		override protected function partAdded(partName:String, instance:Object):void
		{
			super.partAdded(partName, instance);

			if (instance == promptDisplay)
			{
				promptDisplay.text = prompt;
			}
		}

		/**
		 * Handles the focus event and sets our focus flag then
		 * invalidates the skin to change states appropriately
		 * @param e:FocusEvent
		 */
		private function onFocus(e:FocusEvent):void
		{
			this._inFocus = e.type == FocusEvent.FOCUS_IN;
			invalidateSkinState();
		}
	}
}
</pre>
<p>You&#8217;ll notice that we&#8217;re add a few things to the components.  First, we&#8217;re adding two new skin states on top of the two that are with TextInput (normal and disabled).  We&#8217;re also adding a new skin part that isn&#8217;t required since we want to leave it open to the developers/designers if they want to have to add in the skin.  And finally, we override the getCurrentSkinState so to send out two new skin state strings to the skin itself.  If none of this makes sense, I definitely recommend you read up on <a href="http://danorlando.com/?p=374" >Spark Skinning</a>.  And of course, for all this to come together, we need our new skin.</p>
<pre class="brush: xml; title: ;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:SparkSkin xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot; xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
    xmlns:fb=&quot;http://ns.adobe.com/flashbuilder/2009&quot; alpha.disabled=&quot;0.5&quot; blendMode=&quot;normal&quot;&gt;

    &lt;fx:Metadata&gt;
		[HostComponent(&quot;com.michelboudreau.view.components.PromptTextInput&quot;)]
	&lt;/fx:Metadata&gt;

    &lt;fx:Script fb:purpose=&quot;styling&quot;&gt;
        private var paddingChanged:Boolean;

        /* Define the skin elements that should not be colorized. */
        static private const exclusions:Array = [&quot;background&quot;, &quot;textDisplay&quot;];

        /**
         * @private
         */
        override public function get colorizeExclusions():Array {return exclusions;}

        /* Define the content fill items that should be colored by the &quot;contentBackgroundColor&quot; style. */
        static private const contentFill:Array = [&quot;bgFill&quot;];

        /**
         *  @private
         */
        override public function get contentItems():Array {return contentFill};

        /**
         *  @private
         */
        override protected function commitProperties():void
        {
            super.commitProperties();

            if (paddingChanged)
            {
                updatePadding();
                paddingChanged = false;
            }
        }

        /**
         * @private
         */
        override protected function initializationComplete():void
        {
            useChromeColor = true;
            super.initializationComplete();
        }

        /**
         *  @private
         */
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            if (getStyle(&quot;borderVisible&quot;) == true)
            {
                border.visible = true;
                shadow.visible = true;
                background.left = background.top = background.right = background.bottom = 1;
                textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 1;
            }
            else
            {
                border.visible = false;
                shadow.visible = false;
                background.left = background.top = background.right = background.bottom = 0;
                textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 0;
            }

            borderStroke.color = getStyle(&quot;borderColor&quot;);
            borderStroke.alpha = getStyle(&quot;borderAlpha&quot;);

            super.updateDisplayList(unscaledWidth, unscaledHeight);
        }

        /**
         *  @private
         */
        private function updatePadding():void
        {
            if (!textDisplay)
                return;

            // Push padding styles into the textDisplay
            var padding:Number;

            padding = getStyle(&quot;paddingLeft&quot;);
            if (textDisplay.getStyle(&quot;paddingLeft&quot;) != padding)
                textDisplay.setStyle(&quot;paddingLeft&quot;, padding);

            padding = getStyle(&quot;paddingTop&quot;);
            if (textDisplay.getStyle(&quot;paddingTop&quot;) != padding)
                textDisplay.setStyle(&quot;paddingTop&quot;, padding);

            padding = getStyle(&quot;paddingRight&quot;);
            if (textDisplay.getStyle(&quot;paddingRight&quot;) != padding)
                textDisplay.setStyle(&quot;paddingRight&quot;, padding);

            padding = getStyle(&quot;paddingBottom&quot;);
            if (textDisplay.getStyle(&quot;paddingBottom&quot;) != padding)
                textDisplay.setStyle(&quot;paddingBottom&quot;, padding);
        }

        /**
         *  @private
         */
        override public function styleChanged(styleProp:String):void
        {
            var allStyles:Boolean = !styleProp || styleProp == &quot;styleName&quot;;

            super.styleChanged(styleProp);

            if (allStyles || styleProp.indexOf(&quot;padding&quot;) == 0)
            {
                paddingChanged = true;
                invalidateProperties();
            }
        }
    &lt;/fx:Script&gt;

    &lt;fx:Script&gt;
        &lt;![CDATA[
        /**
         * @private
         */
        private static const focusExclusions:Array = [&quot;textDisplay&quot;];

        /**
         *  @private
         */
        override public function get focusSkinExclusions():Array { return focusExclusions;};
        ]]&gt;
    &lt;/fx:Script&gt;

    &lt;s:states&gt;
        &lt;s:State name=&quot;normal&quot;/&gt;
        &lt;s:State name=&quot;disabled&quot;/&gt;

		&lt;!-- ADDED --&gt;
		&lt;s:State name=&quot;normalWithPrompt&quot; stateGroups=&quot;promptGroup&quot;/&gt;
		&lt;s:State name=&quot;disabledWithPrompt&quot; stateGroups=&quot;promptGroup&quot;/&gt;
    &lt;/s:states&gt;

    &lt;!-- border --&gt;
    &lt;!--- @private --&gt;
    &lt;s:Rect left=&quot;0&quot; right=&quot;0&quot; top=&quot;0&quot; bottom=&quot;0&quot; id=&quot;border&quot;&gt;
        &lt;s:stroke&gt;
            &lt;!--- @private --&gt;
            &lt;s:SolidColorStroke id=&quot;borderStroke&quot; weight=&quot;1&quot; /&gt;
        &lt;/s:stroke&gt;
    &lt;/s:Rect&gt;

    &lt;!-- fill --&gt;
    &lt;!--- Defines the appearance of the TextInput component's background. --&gt;
    &lt;s:Rect id=&quot;background&quot; left=&quot;1&quot; right=&quot;1&quot; top=&quot;1&quot; bottom=&quot;1&quot;&gt;
        &lt;s:fill&gt;
            &lt;!--- @private Defines the background fill color. --&gt;
            &lt;s:SolidColor id=&quot;bgFill&quot; color=&quot;0xFFFFFF&quot; /&gt;
        &lt;/s:fill&gt;
    &lt;/s:Rect&gt;

    &lt;!-- shadow --&gt;
    &lt;!--- @private --&gt;
    &lt;s:Rect left=&quot;1&quot; top=&quot;1&quot; right=&quot;1&quot; height=&quot;1&quot; id=&quot;shadow&quot;&gt;
        &lt;s:fill&gt;
            &lt;s:SolidColor color=&quot;0x000000&quot; alpha=&quot;0.12&quot; /&gt;
        &lt;/s:fill&gt;
    &lt;/s:Rect&gt;

    &lt;!-- text --&gt;
    &lt;!--- @copy spark.components.supportClasses.SkinnableTextBase#textDisplay --&gt;
    &lt;s:RichEditableText id=&quot;textDisplay&quot;
              verticalAlign=&quot;middle&quot;
              widthInChars=&quot;10&quot;
              left=&quot;1&quot; right=&quot;1&quot; top=&quot;1&quot; bottom=&quot;1&quot; /&gt;

	&lt;!-- ADDED --&gt;
	&lt;!-- prompt --&gt;
	&lt;s:Label id=&quot;promptDisplay&quot; verticalAlign=&quot;middle&quot; includeIn=&quot;promptGroup&quot;
			 alpha=&quot;0.5&quot; mouseEnabled=&quot;false&quot; left=&quot;1&quot; right=&quot;1&quot; top=&quot;1&quot; bottom=&quot;1&quot; /&gt;
&lt;/s:SparkSkin&gt;
</pre>
<p>This is a default TextInput skin, but with an added Label at the end of the file, and you&#8217;ll also find the two new states added to the mix.  That&#8217;s all it takes.</p>
<p><strong>UPDATE:</strong> After <a href="https://bugs.adobe.com/jira/browse/SDK-28118" >looking around</a>, it seems that a prompt property will be added to Flex 4.5.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/11/24/textinput-prompt-component/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex/Actionscript UML Tool: UML4AS</title>
		<link>http://www.michelboudreau.com/2010/08/18/flexactionscript-uml-tool-uml4as/</link>
		<comments>http://www.michelboudreau.com/2010/08/18/flexactionscript-uml-tool-uml4as/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 19:08:39 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Advanced Visualization]]></category>
		<category><![CDATA[Lab49]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=389</guid>
		<description><![CDATA[Anyone remember Saffron?  I was never certain if this project was ever going to come to fruition, so lately I was thinking excessively about making my own.  I started searching for inspiration in other UML tools so I could design a better user interface.  Low and behold, I stumble across UML4AS, a brand spanking new [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone remember <a href="http://www.michelboudreau.com/2010/04/30/saffron-is-still-alive/" >Saffron</a>?  I was never certain if this project was ever going to come to fruition, so lately I was thinking excessively about making my own.  I started searching for inspiration in other UML tools so I could design a better user interface.  Low and behold, I stumble across <a href="http://www.uml4as.com" >UML4AS</a>, a brand spanking new project that does just what I was planning of doing.</p>
<p>It integrates completely with Eclipse (and Flash Builder) and has this neat feature called CodeSync that makes sure your model and code is always persisted between each other.  In other words, everything works together in an integrated workflow to save you time.</p>
<p>I&#8217;ll have to dig deeper, try this out on projects and do a complete review.  In the meantime, please support this initiative by registering and posting on the forum.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/08/18/flexactionscript-uml-tool-uml4as/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FirebugLoggerTarget Class</title>
		<link>http://www.michelboudreau.com/2010/07/13/firebugloggertarget-class/</link>
		<comments>http://www.michelboudreau.com/2010/07/13/firebugloggertarget-class/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 04:29:07 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Advanced Visualization]]></category>
		<category><![CDATA[Lab49]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=358</guid>
		<description><![CDATA[Some of you might of seen my past post about the FirebugLogger class.  It was an easy way to have text show up in the Firebug console in Firefox and has proven itself quite useful.  However, since I&#8217;ve been using Parsley a lot lately I needed something new to show the output of Parsley in [...]]]></description>
			<content:encoded><![CDATA[<p>Some of you might of seen my past post about the <a href="http://www.michelboudreau.com/2009/04/29/firebuglogger-class/">FirebugLogger class</a>.  It was an easy way to have text show up in the Firebug console in Firefox and has proven itself quite useful.  However, since I&#8217;ve been using Parsley a lot lately I needed something new to show the output of Parsley in Firebug.  Parlsey uses the native Flex logging framework (like TraceTarget) when you specify it in the config.</p>
<p><span id="more-358"></span>What I&#8217;ve done is extend TraceTarget and include some code so that any output goes to Firebug.  Simple enough, but very useful when you don&#8217;t have to have your debugger always running to see the output.</p>
<pre class="brush: as3;">
package com.codemonkeycreative.utils
{
	import flash.external.ExternalInterface;

	import mx.formatters.DateFormatter;
	import mx.logging.ILogger;
	import mx.logging.LogEvent;
	import mx.logging.LogEventLevel;
	import mx.logging.targets.TraceTarget;

	public class FirebugLoggerTarget extends TraceTarget
	{
		private var _dateFormatter:DateFormatter = new DateFormatter();

		public function FirebugLoggerTarget()
		{
			super();
		}

		/**
		 * Overrides the main function of TraceTarget that gets triggered
		 * every time someone tries to log anything using a Logger
		 **/
		override public function logEvent(event:LogEvent):void
		{
			// send the event to be traced normally
			super.logEvent(event);
			// Find the level
			var levelType:String = getLevelString(event.level);
			var level:String = includeLevel?levelType.toUpperCase():'';

			// Date variables
			var date:String = &quot;&quot;;
			var d:Date = new Date();

			// Format date
			if(includeDate)
			{
				this._dateFormatter.formatString = &quot;MM/DD/YYYY&quot;;
				date = this._dateFormatter.format(d) + fieldSeparator;
			}

			// Format time
			if(includeTime)
			{
				this._dateFormatter.formatString = &quot;J:N:SS.QQQ&quot;;
				date += '[' + this._dateFormatter.format(d) + ']' + fieldSeparator;
			}

			// Find the category
			var category:String = includeCategory ? ILogger(event.target).category + fieldSeparator : &quot;&quot;;

            // Then output it in firebug
            if(ExternalInterface.available)
            {
				ExternalInterface.call(&quot;console.&quot;+levelType, date + level + category + event.message);
            }
		}

		/**
		 * Returns the string equivalend of the level enum.
		 * This is needed for firebug to understand the console output.
		 **/
		private function getLevelString(level:int):String
		{
     		switch(level)
			{
				case LogEventLevel.DEBUG:
					return 'debug';
					break;
				case LogEventLevel.INFO:
					return 'info';
					break;
				case LogEventLevel.WARN:
					return 'warn';
					break;
				case LogEventLevel.FATAL:
				case LogEventLevel.ERROR:
					return 'error';
					break;
				case LogEventLevel.ALL:
				default:
					return 'log';
					break;
			}
		}
	}
}
</pre>
<p>Simply create this class and include it in your project.  Then in your config file, just add the following line.</p>
<pre class="brush: xml;">
&lt;utils:FirebugLoggerTarget level=&quot;{LogEventLevel.ALL}&quot; includeTime=&quot;true&quot; includeDate=&quot;true&quot; /&gt;
</pre>
<p>You just need to change the properties like you normally on TraceTarget and the class does the rest.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/07/13/firebugloggertarget-class/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New York Flex Meetup Group</title>
		<link>http://www.michelboudreau.com/2010/05/21/new-york-flex-meetup-group/</link>
		<comments>http://www.michelboudreau.com/2010/05/21/new-york-flex-meetup-group/#comments</comments>
		<pubDate>Fri, 21 May 2010 20:48:28 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Advanced Visualization]]></category>
		<category><![CDATA[Lab49]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=321</guid>
		<description><![CDATA[That&#8217;s right, it&#8217;s here, everyone rejoice. When I moved here from Ottawa I thought to myself that NYC would be full of Flex gurus. Sadly, that is not the case. I&#8217;ve met many developers, but very few experts in the field. This is my way to try and change that. I&#8217;m hoping that this will [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s right, <a href="http://www.meetup.com/New-York-Flex-Meetup/">it&#8217;s here</a>, everyone rejoice.</p>
<p>When I moved here from Ottawa I thought to myself that NYC would be full of Flex gurus.  Sadly, that is not the case. I&#8217;ve met many developers, but very few experts in the field.</p>
<p>This is my way to try and change that.  I&#8217;m hoping that this will become the place where Flex developers of all skill levels meet, discuss, share and learn from each other.</p>
<p>If that interests you, join the group and come out to our inaugural meet June 7th. Pizza will be provided.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/05/21/new-york-flex-meetup-group/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlexUnit4 &amp; Parsley</title>
		<link>http://blog.lab49.com/archives/4450</link>
		<comments>http://blog.lab49.com/archives/4450#comments</comments>
		<pubDate>Mon, 10 May 2010 22:01:47 +0000</pubDate>
		<dc:creator>Anthony McCormick</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[DI]]></category>
		<category><![CDATA[FlashBuilder]]></category>
		<category><![CDATA[FlexUnit4]]></category>
		<category><![CDATA[Inversion Of Control]]></category>
		<category><![CDATA[IOC]]></category>
		<category><![CDATA[Parsley]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Test Driven Development]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=4450</guid>
		<description><![CDATA[For the last six months I have been working on a rather large enterprise application that uses parsley as it&#8217;s main Dependency Injection Framework. This has led to many complex class&#8217; that contain multiple injected models, VO and other elements. Recreating these items inside test harness can become very cumbersome if you have to create [...]]]></description>
			<content:encoded><![CDATA[<p>For the last six months I have been working on a rather large enterprise application that uses parsley as it&#8217;s main Dependency Injection Framework. This has led to many complex class&#8217; that contain multiple injected models, VO and other elements. Recreating these items inside test harness can become very cumbersome if you have to create a large injection heirarchy. Consider the following example.</p>
<p><a title="FlexUnit4 &amp; Parsley" href="http://www.betadesigns.co.uk/Blog/2010/04/29/flexunit4-parsley/" target="_blank">More</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/4450/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom FlashBuilder Component Views</title>
		<link>http://blog.lab49.com/archives/4449</link>
		<comments>http://blog.lab49.com/archives/4449#comments</comments>
		<pubDate>Mon, 10 May 2010 21:51:50 +0000</pubDate>
		<dc:creator>Anthony McCormick</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Advanced Component Development]]></category>
		<category><![CDATA[Custom components]]></category>
		<category><![CDATA[design.xml]]></category>
		<category><![CDATA[FlashBuilder]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[manifest.xml]]></category>
		<category><![CDATA[swc]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=4449</guid>
		<description><![CDATA[I recently discovered that you can create custom components that can appear under your own company/personal folder inside Flash/Flexbuilder design view. Normally any custom component you create will appear under the Custom folder in the Components View and well thats not very good for branding now is it. In addition you also get an actual [...]]]></description>
			<content:encoded><![CDATA[<p>I recently discovered that you can create custom components that can appear under your own company/personal folder inside Flash/Flexbuilder design view. Normally any custom component you create will appear under the Custom folder in the Components View and well thats not very good for branding now is it. In addition you also get an actual size representation of your component in Design view rather than just an empty box outline. For example the first image is the default and the second the custom.</p>
<p><a title="Custom FlashBuilder Component Views" href="http://www.betadesigns.co.uk/Blog/2010/05/06/custom-flashbuilder-component-views/" target="_blank">more</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/4449/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prepping Flash for War</title>
		<link>http://www.michelboudreau.com/2010/03/22/prepping-flash-for-war/</link>
		<comments>http://www.michelboudreau.com/2010/03/22/prepping-flash-for-war/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 15:44:41 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Advanced Visualization]]></category>
		<category><![CDATA[Lab49]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=258</guid>
		<description><![CDATA[Flash vs Silverlight vs HTML5; a no-holds barred grudge match is brewing in this industry.  It will divide developers and companies where there was little contention in the past.  I doubt that this will end in a fatality, but the injuries will most likely fall to Adobe because of its current dominance in the field.  [...]]]></description>
			<content:encoded><![CDATA[<p>Flash vs Silverlight vs HTML5; a no-holds barred grudge match is brewing in this industry.  It will divide developers and companies where there was little contention in the past.  I doubt that this will end in a fatality, but the injuries will most likely fall to Adobe because of its current dominance in the field.  Each technology has its pros and cons, and multiple providers can co-exist, but companies need a reason to choose one over another. I predict most of the debate will be based around the development process; ease of development, quick prototyping, effectiveness of tools offered, development environments, unit testing, system integration, as well as application design and planning. If a company can make great applications in less time, it means that they can make more money.</p>
<p><span id="more-258"></span>I’m a fan of Flash, but like most things in life, it isn’t perfect.  Flex and Actionscript have been an integral part of my career and I would like them to continue to be so.  I would like to touch on certain concepts that I think would add more value to the current software offerings and in turn give Adobe an edge over the competition.</p>
<p>Time is an important asset for a company, which is why increasing development efficiency will be a key factor in winning this war. I&#8217;m talking about reducing the compiler time, making it smarter and bug free, and adding 64bit support to utilise workstation performance. This improvement can save valuable minutes or even hours depending on the developer.</p>
<p>Speaking of development efficiency, I also suggest that Flash Builder starts supporting Linux.  Adobe doesn&#8217;t even have to officially support it, just make sure the eclipse plug-in can work in a Linux environment with or without design view (I personally never use it).  The <a href="http://bugs.adobe.com/jira/browse/FB-19053" >feature request</a> for having Flash Builder on Linux is one of the most popular requests on the Adobe bug tracker.</p>
<p>Irritations while using Flash products also need to be eliminated. I personally enjoy development work (geek alert!), but when something doesn&#8217;t work like expected, it frustrates me to no end. The Flex framework is fairly good at doing exactly that; it’s supposed to save time, and it does, but there are some components that have been buggy ever since its inception and they aren&#8217;t being fixed.</p>
<p>The next point is cause for debate between developers, in the end it comes down to preference, but it needs to be addressed. Of course, I&#8217;m talking about Cairngorm &#8211; or more specifically your decision to support it. I personally don&#8217;t think MVC is the pattern to use when handling a Flex application, and other developers in the community agree; hence the creation of several new open<del datetime="2010-03-29T13:45" cite="mailto:Michel%20Boudreau">-</del><ins datetime="2010-03-29T13:45" cite="mailto:Michel%20Boudreau"> </ins>source frameworks. It seems to me that Adobe is playing favorites with Cairngorm and could instead use that development effort in a more productive way.  Adobe should work on enhancing the Flash API and opening up doors to allow third party frameworks to improve their usability.</p>
<p>With complex applications come crucial new ways to design the flow and interaction within the system.  For that, a developer needs tools to show this visually.  Tools like wireframe UI timeline or UML round-trip engineering can combine both design and functionality in a uniform way that all developers can understand.  A lot could be learned from Java and their tools: e.g. offering code hot-swapping to greatly reduce debugging time.</p>
<p>If Adobe is serious about creating a developer language, then a more complex language needs to be their goal.  Multiple-inheritance, polymorphism, overloading, enumerators, abstract classes, destructors, private constructors, decimal data type, threading support &#8211; these are only a few of the things that Actionscript is lacking. Some would argue that there are a lot more. I&#8217;m not saying it&#8217;s a bad language, after all, it does do what it&#8217;s supposed to do, but with bigger systems come more architectural complexities that the current language cannot support.</p>
<p>A common topic when debating Silverlight vs Flex is the lack of multi-threading.  I really do hope that this will be implemented in the next iteration of the language because the possibilities it would open would be mind-blowing.  Imagine a system that can execute complex algorithms and computations without disrupting the user experience; that would be a major improvement! Heck, even if the language doesn&#8217;t give developers access to threads, just allowing the player to run different threads for visual components and for computations would be a great improvement.</p>
<p>Let me leave you with this: I&#8217;ve been a fan of Adobe since I was a kid, and I still am. If any business is capable of surmounting the upcoming challenge, it will be Adobe. I believe that the community surrounding this product will be a key factor in this war; if Adobe listens and responds to our suggestions, only great things can happen. <del datetime="2010-03-29T13:45" cite="mailto:Michel%20Boudreau"></del></p>
<p>Speaking of community, I invite all developers and designers to debate and comment on this topic. I think it is one that will be talked about for quite some time to come.  I&#8217;d also like to thank <a href="http://joemorrison.org/blog/" >Joe Morrison</a>, a Director at Lab49, for letting me bounce ideas off of him.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/03/22/prepping-flash-for-war/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RichTextArea Component</title>
		<link>http://www.michelboudreau.com/2010/03/18/richtextarea-component/</link>
		<comments>http://www.michelboudreau.com/2010/03/18/richtextarea-component/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:35:40 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A few months ago, I was working on a project that needed a CMS backend to create content that will be displayed in Flex.  We used a RichTextEditor component to create appropriate HTML so that it would display like we wanted to on the frontend.
The problem with this approach is that we needed our [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I was working on a project that needed a CMS backend to create content that will be displayed in Flex.  We used a RichTextEditor component to create appropriate HTML so that it would display like we wanted to on the frontend.<br />
The problem with this approach is that we needed our [...]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/03/18/richtextarea-component/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RichTextArea Component</title>
		<link>http://www.michelboudreau.com/2010/03/18/richtextarea-component/</link>
		<comments>http://www.michelboudreau.com/2010/03/18/richtextarea-component/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 21:31:09 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Advanced Visualization]]></category>
		<category><![CDATA[Lab49]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=232</guid>
		<description><![CDATA[A few months ago, I was working on a project that needed a CMS backend to create content that will be displayed in Flex.  We used a RichTextEditor component to create appropriate HTML so that it would display like we wanted to on the frontend.
The problem with this approach is that we needed our [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I was working on a project that needed a CMS backend to create content that will be displayed in Flex.  We used a RichTextEditor component to create appropriate HTML so that it would display like we wanted to on the frontend.</p>
<p>The problem with this approach is that we needed our application to be re-themeable between different clients that would be using this product, which meant that we also needed a way to style the html content without having to redo the html itself.</p>
<p><span id="more-232"></span></p>
<p>As much as I looked for it, I couldn&#8217;t find anyone else doing something similar to this, so I created my own.  Essentially, I just extended TextArea which already handles htmlText and added my own html tag styling to it.  I was surprised to see that you can actually set styles to the html within the TextArea, but you can only do it with Actionscript.</p>
<p>I looked at all the possible <a href="http://livedocs.adobe.com/flex/3/html/textcontrols_04.html#437502" >html tags</a> that TextArea supports, and created CSS styles for it.  I wanted to stick with the proper CSS convention of separating the words using a dash and used my own kind of standard &#8216;html-&lt;tag&gt;-&lt;property&gt;&#8217;, property being one of &#8216;color&#8217;, &#8216;weight&#8217;, &#8216;decoration&#8217; or &#8217;style&#8217;.  One exception to this rule is for the anchor tag, which can also do pseudo-classes (a:link, a:hover and a:active).  If you need to reference those tags, you just need to use &#8216;alink&#8217;, &#8216;ahover&#8217; and &#8216;aactive&#8217;.  If someone has a better suggestion, I&#8217;m all ears.</p>
<pre class="brush: as3;">
package com.lab49.components
{
	import flash.text.StyleSheet;

	import mx.collections.ArrayCollection;
	import mx.controls.TextArea;
	import mx.styles.CSSStyleDeclaration;
	import mx.styles.StyleManager;

	// Set the style metadata - If adding another style/tag, add it here
	// Style names are in the of 'html-&lt;tag&gt;-&lt;property&gt;' exception is for pseudo-classes
	// which is attached directly to the tag name.
	[Style(name=&quot;html-a-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-a-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-a-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-a-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-ahover-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-ahover-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-ahover-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-ahover-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-aactive-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-aactive-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-aactive-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-aactive-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-alink-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-alink-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-alink-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-alink-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-b-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-b-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-b-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-b-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-font-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-font-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-font-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-font-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-i-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-i-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-i-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-i-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-li-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-li-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-li-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-li-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-p-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-p-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-p-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-p-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-span-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-span-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-span-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-span-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-textformat-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-textformat-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-textformat-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-textformat-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-u-style&quot;, type=&quot;String&quot;, enumeration=&quot;italic, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-u-weight&quot;, type=&quot;String&quot;, enumeration=&quot;bold, normal&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-u-decoration&quot;, type=&quot;String&quot;, enumeration=&quot;none, underline&quot;, inherit=&quot;no&quot;)]
	[Style(name=&quot;html-u-color&quot;, type=&quot;uint&quot;, format=&quot;Color&quot;, inherit=&quot;no&quot;)]

	/**
	 * RichTextArea Class, extends TextArea.  Displays html text, but styles them uniformily for
	 * easy theming.
	 **/
	public class RichTextArea extends TextArea
	{
		private var _stypePropChanged:Boolean = false; // Style property change flag.  Set to true when one of the html styles is set
        private static var _classConstructed:Boolean = classConstruct(); // Calls a static initializer function before anything else

        // All possible styles.  If adding a new one, must be added in this ArrayCollection with the proper metadata above.
        private const _styles:ArrayCollection = new ArrayCollection([	&quot;html-a-style&quot;,
														            	&quot;html-a-weight&quot;,
														            	&quot;html-a-decoration&quot;,
														            	&quot;html-a-color&quot;,
														            	&quot;html-ahover-style&quot;,
														            	&quot;html-ahover-weight&quot;,
														            	&quot;html-ahover-decoration&quot;,
														            	&quot;html-ahover-color&quot;,
														            	&quot;html-alink-style&quot;,
														            	&quot;html-alink-weight&quot;,
														            	&quot;html-alink-decoration&quot;,
														            	&quot;html-alink-color&quot;,
														            	&quot;html-aactive-style&quot;,
														            	&quot;html-aactive-weight&quot;,
														            	&quot;html-aactive-decoration&quot;,
														            	&quot;html-aactive-color&quot;,
														            	&quot;html-b-style&quot;,
														            	&quot;html-b-weight&quot;,
														            	&quot;html-b-decoration&quot;,
														            	&quot;html-b-color&quot;,
														            	&quot;html-font-style&quot;,
														            	&quot;html-font-weight&quot;,
														            	&quot;html-font-decoration&quot;,
														            	&quot;html-font-color&quot;,
														            	&quot;html-i-style&quot;,
														            	&quot;html-i-weight&quot;,
														            	&quot;html-i-decoration&quot;,
														            	&quot;html-i-color&quot;,
														            	&quot;html-li-style&quot;,
														            	&quot;html-li-weight&quot;,
														            	&quot;html-li-decoration&quot;,
														            	&quot;html-li-color&quot;,
														            	&quot;html-p-style&quot;,
														            	&quot;html-p-weight&quot;,
														            	&quot;html-p-decoration&quot;,
														            	&quot;html-p-color&quot;,
														            	&quot;html-span-style&quot;,
														            	&quot;html-span-weight&quot;,
														            	&quot;html-span-decoration&quot;,
														            	&quot;html-span-color&quot;,
														            	&quot;html-textformat-style&quot;,
														            	&quot;html-textformat-weight&quot;,
														            	&quot;html-textformat-decoration&quot;,
														            	&quot;html-textformat-color&quot;,
														            	&quot;html-u-style&quot;,
														            	&quot;html-u-weight&quot;,
														            	&quot;html-u-decoration&quot;,
														            	&quot;html-u-color&quot; ]);

		// Sets default properties of RichTextArea
		[Inspectable(category=&quot;General&quot;, defaultValue=&quot;false&quot;)]
		override public function set editable(value:Boolean):void
		{
			super.editable = value;
		}

		[Inspectable(category=&quot;General&quot;, defaultValue=&quot;true&quot;)]
		override public function set selectable(value:Boolean):void
		{
			super.selectable = value;
		}

		[Inspectable(category=&quot;General&quot;, defaultValue=&quot;true&quot;)]
		override public function set condenseWhite(value:Boolean):void
		{
			super.condenseWhite = value;
		}

		// Constructor
		public function RichTextArea()
		{
			super();

			// Removes background, border and focus highlight of the TextArea
			this.setStyle('backgroundAlpha', 0);
			this.setStyle('borderStyle', 'none');
			this.setStyle('focusAlpha', 0);
		}

		/**
		 * This method is called a static initializer since it is called before the
		 * constructor since it's being referenced by a static variable.
		 * If anything needs to be set before the constructor runs, this is the place to do it.
		 *
		 * @return true
		 **/
        private static function classConstruct():Boolean
        {
        	// Check to see if style exists
            if (!StyleManager.getStyleDeclaration(&quot;RichTextArea&quot;))
            {
            	// Set default empty style declaration
                var style:CSSStyleDeclaration = new CSSStyleDeclaration();
                style.defaultFactory = function():void {};
                StyleManager.setStyleDeclaration(&quot;RichTextArea&quot;, style, true);
            }
            return true;
        }

    	/**
    	 * Overrides the htmlText property to set the '_stylePropertyChanged' flag
    	 * since any new text being set will not be styled unless updateDisplayList()
    	 * is called.
    	 *
    	 * @param value:String The html text to be set
    	 **/
    	override public function set htmlText(value:String):void
		{
			super.htmlText = value;
			this._stypePropChanged = true; // Set the flag to style the text
			invalidateDisplayList(); // Call updateDisplayList() on next render
		}

		/**
		 * Override the styleChanged() method to detect changes in your new style.
		 * only set the _stylePropChanged tag to true if one of our custom styles has
		 * been changed.  If a new style is added, it must be added here as well.
		 *
		 * @param styleProp:String The new property name that has been set
		 **/
        override public function styleChanged(styleProp:String):void
        {
            super.styleChanged(styleProp);

            // Check to see if it's one of our custom styles
            if(this._styles.contains(styleProp))
            {
            	// Redo text styling
            	this._stypePropChanged = true;
	            invalidateDisplayList();
            }
        }

		// Override updateDisplayList() to update the component
        // based on the style setting.
        /**
         * Override the drawing function and resets the style on the html text if the _stylePropChanged flag is set to true.
         *
         * @param unscaledWidth:Number the width of the current component
         * @param unscaledHeight:Number the height of the current component
         **/
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            // Check to see if style changed.
            if (this._stypePropChanged)
            {
            	this._stypePropChanged = false; // set the flag back to false

                /*
				 * Adds new styles to the CSS for specific html content.
				 * More can be added, just add the tag name in the 'tags' array and
				 * add the css property 'html-&lt;tag name&gt;-&lt;text property name&gt;' in your stylesheet
				 * For instance, I can could do 'html-p-weight:bold'.
				 * Possible text property names are 'style', 'weight', 'decoration' and 'color'
				 *
				 * Only exception to the tag name is for the 'a' tag.  You can specify just 'a' or
				 * you can do the pseudo class 'hover', 'link' and 'active', but you need to specify the tag
				 * before, like so 'html-ahover-weight: bold;'.
				 */
				var style:Object, value:Object, tag:String, tagSplit:Array, ss:StyleSheet = new StyleSheet();

				for(var i:int = 0, len:int = this._styles.length; i &lt; len; i++)
				{
					style = {};
					tag = this._styles.getItemAt(i) as String;

					// Convert into AS3 stylename format (camelCase)
					tagSplit = tag.split('-');
					tag = tagSplit[0] + String(tagSplit[1]).charAt(0).toUpperCase() + String(tagSplit[1]).slice(1) +
							String(tagSplit[2]).charAt(0).toUpperCase() + String(tagSplit[2]).slice(1);

					// Get style if there
					value = getStyle(tag);
					if(value)
					{
						style = ss.getStyle(tagSplit[1]); // Get style if one already exists so you don't override the previous one
						// Find the proper style name and save it
						switch(tagSplit[2])
						{
							case 'style':
								style.fontStyle = value;
								break;
							case 'weight':
								style.fontWeight = value;
								break;
							case 'decoration':
								style.textDecoration = value;
								break;
							case 'color':
								style.color = '#'+('00000'+Number(value).toString(16).toUpperCase()).substr(-6);
								break;
						}

						// Do the cases for the pseudo 'a' classes and set the style object
						switch(tagSplit[1])
						{
							case 'ahover':
								ss.setStyle('a:hover', style);
								break;
							case 'alink':
								ss.setStyle('a:link', style);
								break;
							case 'aactive':
								ss.setStyle('a:active', style);
								break;
							default:
								ss.setStyle(tagSplit[1], style);
								break;
						}
					}
				}

				styleSheet = ss; // Save stylesheet
            }
        }
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2010/03/18/richtextarea-component/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Take on ActionScript 3 shortcomings</title>
		<link>http://mycenes.wordpress.com/2010/02/22/my-take-on-actionscript-3-shortcomings/</link>
		<comments>http://mycenes.wordpress.com/2010/02/22/my-take-on-actionscript-3-shortcomings/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 15:06:24 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[RIA]]></category>

		<guid isPermaLink="false">http://mycenes.wordpress.com/?p=37</guid>
		<description><![CDATA[ActionScript 3 has been touted as an object oriented language with optional compile-type checking and so I had certain expectations when I took the language for a spin, with a eye towards developing large (as in a few thousand classes) application. Here are my thoughts on what is missing.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycenes.wordpress.com&#38;blog=8923193&#38;post=37&#38;subd=mycenes&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been playing with ActionScript 3 lately and I will say upfront that I like it, it does what it&#8217;s supposed to do pretty well: Provide a thoughtfully designed language targeted specifically at the Flash platform.<br />
But it has also been touted as an object oriented language with optional compile-type checking and so I had certain expectations when I took the language for a spin, with a eye towards developing large (as in a few thousand classes) application.</p>
<p>Here are my thoughts on what is missing and why I think those features should get implemented as the language matures and tries to appeal to a wider range of developers (think non-&#8221;traditional&#8221; one who have been working mostly on non rich web application application). By the way, I don&#8217;t consider myself a language expert and my opinion may evolve as I write more ActionScript code.</p>
<p>- No support for multi-threading. I feel that this is the most glaring shortcoming. I understand that it can get tricky for any language belonging to the JavaScript family (I guess it&#8217;s more appropriate to use ECMA family of languages here, or ECMA-compliant, but ECMA is a weird acronym that just doesn&#8217;t round right) to support threads when it&#8217;s meant to run within many browsers and on many different operating systems but this could be one of the main reasons why some enterprise projects may shy away from ActionScript 3. But then again AIR is a desktop solution, and still no threading. Maybe Adobe and the community should seriously reconsider this missing feature. haXe could be considered as a model <a href="http://haxe.org/doc/neko/threads?lang=en">(http://haxe.org/doc/neko/threads?lang=en</a>)</p>
<p>- Limited native types. You just get 5 of them: String, Boolean, Number, int and uint. It may be an indication of the language purely dynamic origins where such considerations were not important. And what&#8217;s with the inconsistent use of cases: String and int (upper and lower)? I guess it&#8217;s for legacy reasons. You could argue that if you really need to make a distinction between double and float then maybe AS3 is not the right tool just as you could argue that for people who want to use AS3 for the visualization of complex analytics such a distinction does matter. There is a lot of room for debate here.</p>
<p>- No overloading allowed for constructors, methods, or even between a variable and a method. This is a limiting factor in larger OO applications. Overloading constructors, for example, greatly contributes to the usability of your class. On the other hand I do like the mandatory inclusion of the &#8216;override&#8217; keyword in subclasses, in line with the trend of other languages (or Java&#8217;s @Override annotation; for Java it&#8217;s too late to enforce it as a keyword)</p>
<p>- No abstract classes, but there are interfaces. Again, that&#8217;s a missing piece in the arsenal of an OO language as interfaces are not exactly the same thing.</p>
<p>- Interfaces can only declare methods, not variables or constants. This restriction can be lived with, but why?</p>
<p>- An .as file must have only one externally visible (public or internal) class or function; this a compiler (mxmlc) restriction, not an AS3 restriction per se. This can become annoying for a file defining global utility functions.<br />
It&#8217;s worth noting at this point that there are a few ActrionScript compilers out there, a tribute to the vitality of the community, but that&#8217;s a little bit off topic in a post titled &#8220;AS3 shortcomings&#8221;, isn&#8217;t it? So I&#8217;ll just add that MTASC is great, but specifically geared towards AS2 with no plans for AS3 as they announced that they are focusing on haXe (by the way they are the creators of haXe). I never tried swftools, though I should. Maybe this bullet point will prove invalid.</p>
<p>- No Generics, which gives the language a very pre-Java 5 feel. This is felt even more acutely given the many resemblances to the Java language. They could have been inspired by GJ, the work on STL, etc&#8230; For some reasons it has been left out. This may not be necessarily hurtful for people used to work with the AS3 Array class (it&#8217;s a heterogeneous collection of objects) but you do feel their absence when you are trying to write a method where arguments can be of a certain type and all of its descendants but no more, i.e. you don&#8217;t want to necessarily resort to the * notation.</p>
<p>- Speaking of Array, what&#8217;s with the delete operator? It does not really delete (for that you are better off using splice()). Maybe that&#8217;s what happens when you try too hard to come up with a unique syntax for your language. At this point I am tempted to say that we should just stick to the C++ syntax, but to each his own and this type of debate can easily degenerate into futility, so let&#8217;s leave it that: The &#8216;delete&#8217; operator does not delete an array element (when used in the context of arrays), it merely sets the element value to undefined, and that&#8217;s misleading.</p>
<p>That&#8217;s it for now, I will probably post a follow up where I explain why I really like the event dispatching model and some of the language functional features.</p>
<p>Filed under: <a href='http://mycenes.wordpress.com/category/ria/actionscript-3/'>ActionScript 3</a>, <a href='http://mycenes.wordpress.com/category/adobe/'>Adobe</a>, <a href='http://mycenes.wordpress.com/category/ria/'>RIA</a> Tagged: <a href='http://mycenes.wordpress.com/tag/actionscript/'>ActionScript</a>, <a href='http://mycenes.wordpress.com/tag/as-3/'>AS 3</a>, <a href='http://mycenes.wordpress.com/tag/java/'>Java</a>, <a href='http://mycenes.wordpress.com/tag/object-oriented/'>Object Oriented</a>, <a href='http://mycenes.wordpress.com/tag/oo/'>OO</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycenes.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycenes.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycenes.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycenes.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycenes.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycenes.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycenes.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycenes.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycenes.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycenes.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycenes.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycenes.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycenes.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycenes.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycenes.wordpress.com&amp;blog=8923193&amp;post=37&amp;subd=mycenes&amp;ref=&amp;feed=1" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://mycenes.wordpress.com/2010/02/22/my-take-on-actionscript-3-shortcomings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

