<?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>Tom Cornilliac &#187; Actionscript</title>
	<atom:link href="http://www.tomcornilliac.com/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tomcornilliac.com</link>
	<description>Flex, AIR and Rich Internet Goodness</description>
	<lastBuildDate>Wed, 17 Jun 2009 15:40:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Handling deferred view component creation within the PureMVC framework</title>
		<link>http://www.tomcornilliac.com/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/</link>
		<comments>http://www.tomcornilliac.com/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 19:24:15 +0000</pubDate>
		<dc:creator>Tom Cornilliac</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PureMVC]]></category>

		<guid isPermaLink="false">http://www.cornilliac.com/blog/?p=44</guid>
		<description><![CDATA[For my last AIR project and my current Flex project I&#8217;ve been using the PureMVC ActionScript framework. It&#8217;s a solid framework and on the whole I&#8217;m enjoying working with it. When using PureMVC for Flex and AIR development one of the questions I see consistently is how to create mediators for deferred components. In other [...]]]></description>
			<content:encoded><![CDATA[<p> For my last AIR project and my current Flex project I&#8217;ve been using the <a href="http://www.puremvc.org">PureMVC</a> ActionScript framework. It&#8217;s a solid framework and on the whole I&#8217;m enjoying working with it. When using PureMVC for Flex and AIR development one of the questions I see consistently is how to create mediators for deferred components. In other words, if the view of your app uses a view stack how do you handle creating mediators on the children of the viewstack that are not created yet?  <span id="more-44"></span></p>
<p>PureMVC uses mediators for all communication from the model and controller to the view. Out of the box PureMVC normally creates the view mediators after creationComplete has fired and the model has been initialized. The reason for this is that mediators require a reference to a view component to work. In order to construct a mediator you first need an object or view component to pass to the constructor.</p>
<p>There are basically three different ways to handle this, two of which I don&#8217;t recommend using.</p>
<p><strong>1. <u>Use dummy objects to initialize mediators</u></strong><br />
<strong> </strong>If you know that your view component is not on the stage yet you could still create it&#8217;s mediator by passing a POASO (plain old actionscript object) to it&#8217;s constructor. I have two problems with this solution; One you&#8217;re unnecessarily using memory and two you have not treated the whole problem, you still need some type of event schema to reinitialize the mediator once the component has been created. <strong>I don&#8217;t recommend using this solution.</strong></p>
<p><strong>2. <u>Use creationPolicy=&#8221;all&#8221; to avoid deferred views</u><br />
</strong>By default components like ViewStack and TabNavigator on create their top level children at runtime. The remainder are created as the user navigates to them. You can use the creationPolicy=&#8221;all&#8221; attribute to override this behavior. This causes the application to create all the view components at runtime. <strong>This is a terrible idea and I cannot recommend it. </strong>What you are in effect saying to your user is &#8220;I don&#8217;t care about your memory or performance because I&#8217;m to lazy to code a decent solution&#8221; I know this is a bit dramatic but I hate when people use this attribute.</p>
<p><strong>3. <u>Use a custom Event subclass</u><br />
</strong>The idea here is to create an event subclass that the application mediator or another mediator can listen for and use to create new mediators. This event class has an extra property which holds a reference to the newly created component, other mediators can use this reference to construct a mediator for the component. This approach not only keeps your memory footprint smaller but it allows you to easily create and destroy mediators. <strong>Here&#8217;s an example of an Event subclass:</strong></p>
<p>You create your own constant names based on the event type you want your mediator to listen for.</p>
<p>[as]<br />
package com.tomcornilliac.myproject.events<br />
{<br />
	import flash.events.Event;</p>
<p>   	public class ComponentCreationEvent extends Event<br />
   	{<br />
      	// Publically accessible properties<br />
      	public var component:Object;</p>
<p>		//Constants used for routing withing PureMVC mediators<br />
		public static const SOME_EVENT:String = &#8220;gatewayCreated&#8221;;<br />
		public static const SOME_OTHER_EVENT:String = &#8220;gatewayStackCreated&#8221;;</p>
<p>		public function ComponentCreationEvent(type:String, component:Object, bubbles:Boolean=false, cancelable:Boolean=false)<br />
		{<br />
			super(type, bubbles, cancelable);<br />
			//Probably should have a getter/setter for this property<br />
			this.component = component;<br />
		}</p>
<p>		//You must override the clone method<br />
		override public function clone():Event<br />
		{<br />
			return new ComponentCreationEvent(type, component, bubbles, cancelable);<br />
		}<br />
	}<br />
}<br />
[/as]</p>
<p>An instance of this event is dispatched from your view component with a reference to its self. <em>Note that &#8220;bubbles&#8221; is set to true, this is required for the event to make it up the chain to whatever mediator is listening.</em><br />
[xml]<br />
<?xml version="1.0" encoding="utf-8"?></p>
<p><mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"<br />
	width="100%" height="100%" creationComplete="init(event)"></p>
<p>	<mx:Metadata><br />
		[Event(name="gatewayCreated", type="org.deschutes.grizzly.events.ComponentCreationEvent")]<br />
	</mx:Metadata></p>
<p>	<mx:Script><br />
		<![CDATA[<br />
			import com.tomcornilliac.myproject.events.ComponentCreationEvent;</p>
<p>			private function init(e:Event):void<br />
			{<br />
				dispatchEvent(new ComponentCreationEvent(ComponentCreationEvent.GATEWAY_CREATED, this, true));<br />
			}<br />
		]]&gt;<br />
	</mx:Script></p>
<p></mx:Canvas><br />
[/xml]</p>
<p>The listening mediator (in this case the ApplictionMediator) will respond to the event and create and register a new mediator for the newly created view component. Now it&#8217;s important to note that while I&#8217;m using the ApplicationMediator in this example, you can use any mediator you want, so long as the event will bubble-up to it.</p>
<p>[as]<br />
package com.tomcornilliac.myproject.view<br />
{<br />
	import com.tomcornilliac.myproject.events.ComponentCreationEvent;<br />
	import com.tomcornilliac.myproject.view.components.SomeComponent;<br />
	import org.puremvc.interfaces.IMediator;<br />
	import org.puremvc.interfaces.INotification;<br />
	import org.puremvc.patterns.mediator.Mediator;</p>
<p>	public class ApplicationMediator extends Mediator implements IMediator<br />
	{<br />
		//Canonical name of the mediator<br />
		public static const NAME:String = &#8216;ApplicationMediator&#8217;;</p>
<p>		//Constructor<br />
		public function ApplicationMediator(viewComponent:Object)<br />
		{<br />
			super(viewComponent);</p>
<p>			/**<br />
			 * Setup event listeners for components created dynamically<br />
			 */<br />
			 app.addEventListener(ComponentCreationEvent.SOME_EVENT, createNewMediator);<br />
		}</p>
<p>		private function createNewMediator(e:ComponentCreationEvent):void<br />
		{<br />
			//Create the new Mediator and initialize it with the component from our event<br />
			var mediator:SomeComponentMediator = new SomeComponentMediator(e.component);<br />
			//Register the mediator with the Application Facade<br />
			facade.registerMediator(mediator)<br />
			//That&#8217;s it now your view component is hooked-up and ready to handle I/O<br />
		}</p>
<p>		&#8230;.other methods<br />
[/as]</p>
<p>This technique is not only good for component creation but you could just as easily create a custom ComponentDestructionEvent and use it to remove Mediators off the stack when no longer needed. </p>
<p>If you would like more information about the PureMVC framework I encourage you to <a href="http://www.puremvc.org">visit the PureMVC web site</a>. The documentation is excellent and there&#8217;s even a training course to help you on your way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomcornilliac.com/2008/01/handling-deferred-view-component-creation-within-the-puremvc-framework/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>eBay just announced an AS3 library</title>
		<link>http://www.tomcornilliac.com/2007/03/ebay-just-announced-an-as3-library/</link>
		<comments>http://www.tomcornilliac.com/2007/03/ebay-just-announced-an-as3-library/#comments</comments>
		<pubDate>Wed, 07 Mar 2007 17:06:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://tomcornilliac.netfirms.com/blog/?p=29</guid>
		<description><![CDATA[I just got out of the 360 Flex day 3 keynote, lots of great information (more on that later). At the end of the keynote Ebay announced the immediate availability of an AS3 library for its services.&#8220;The eBay ActionScript 3.0 library provides an interface between the eBay XML API and ActionScript 3.0. This open-source library [...]]]></description>
			<content:encoded><![CDATA[<p>I just got out of the 360 Flex day 3 keynote, lots of great information (more on that later). At the end of the keynote Ebay announced the immediate availability of an AS3 library for its services.<br /><span style="font-style: italic;"><br />&#8220;The eBay ActionScript 3.0 library provides an interface between the eBay XML API and ActionScript 3.0. This open-source library will allow developers to create novel and innovative applications leveraging both eBay&#8217;s marketplace services and Adobe&#8217;s Flash Player 9 runtime! It is written in ActionScript 3.0, so any environment using ActionScript 3.0 can use this library, including Adobe Flex 2 and Adobe Flash Pro 9.&#8221;</p>
<p></span>You can download beta 1 from <a href="http://adobe.com/go/ebaylibrary/">http://adobe.com/go/ebaylibrary/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomcornilliac.com/2007/03/ebay-just-announced-an-as3-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applying Flash Filters to Flex Components</title>
		<link>http://www.tomcornilliac.com/2007/01/applying-flash-filters-to-flex-components/</link>
		<comments>http://www.tomcornilliac.com/2007/01/applying-flash-filters-to-flex-components/#comments</comments>
		<pubDate>Wed, 24 Jan 2007 16:52:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://tomcornilliac.netfirms.com/blog/?p=35</guid>
		<description><![CDATA[Lately I have been spending a lot of time considering Flex application design. I work in a really small shop (two of us) and we don&#8217;t have the luxury of a Designer on staff. As a result when it comes time to make our Flex applications look muy bonito it&#8217;s yours truly who has to [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I have been spending a lot of time considering Flex application design. I work in a really small shop (two of us) and we don&#8217;t have the luxury of a Designer on staff. As a result when it comes time to make our Flex applications look muy bonito it&#8217;s yours truly who has to put on the designer hat. Since&nbsp; I&#8217;m &#8220;design challenged&#8221; my options to date have been limited to CSS. Skinning is beyond my abilities as I don&#8217;t get Flash (timeline&#8230;.huh?). So the <a title="Flex Style Explorer" href="http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html">Flex Style Explorer</a> has been my designer buddy for awhile.</p>
<p> Yesterday while researching the depths of Flex CSS I discovered you can apply <a title="Flash Filters" href="http://livedocs.macromedia.com/flex/2/langref/flash/filters/package-detail.html">Flash Filters</a> to Flex Components. That&#8217;s what I want to explore in this post. Flash filters can not only make your application look better but they can also improve the user experience. You could us the Glow filter to provide user feedback based on mouse movements or you might use Blur filter to direct the user&#8217;s attention to an object on screen (similar to a modal Title Window but with more options). The <a title="flash.filters package" href="http://livedocs.macromedia.com/flex/2/langref/flash/filters/package-detail.html">flash.filters package</a> contains 13 filters you can use and combine to create some amazing styles without having to resort to skinning.</p>
<p> There are two methods for implementing Flash Filters in your Flex application.</p>
<ol>
<li>     You can create a new namespace linked to the flash.filters.* package, just     like you would a Flex Component.   </li>
<li>     You can apply filters through ActionScript
</li>
</ol>
<p> Both of these approaches have their own benefits and it&#8217;s really up to the developer/designer as to which method to use. Let&#8217;s look at the basic syntax of each method.</p>
<div class="typocode">
<div class="codetitle">Using Flash Filters in MXML</div>
<pre><code class="typocode_default "><notextile>&lt;mx:Application&gt;
    xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    xmlns=&quot;*&quot;
    xmlns:flashFilter=&quot;flash.filters.*&quot;&amp;gt;

&lt;mx:TextArea&gt;
    width=&quot;150&quot; height=&quot;100&quot;
    cornerRadius=&quot;6&quot; text=&quot;Some text&quot;&amp;gt;
         &lt;mx:filters&gt;
             &lt;flashFilter:DropShadowFilter&gt;
                 inner=&quot;true&quot; distance=&quot;3&quot;
                 angle=&quot;120&quot; color=&quot;0x000000&quot;
                 alpha=&quot;0.4&quot; /&amp;gt;
            &lt;/flashFilter:DropShadowFilter&gt;
        &lt;/mx:filters&gt;
&lt;/mx:TextArea&gt;

&lt;/mx:Application&gt;</notextile></code></pre>
</div>
<div class="typocode">
<div class="codetitle">Using Flash Filters in ActionScript</div>
<pre><code class="typocode_default "><notextile>import flash.filters.*;

private function addGlow(event:MouseEvent):void
{
    var g:GlowFilter = new GlowFilter(0x006666, 0.65, 15, 15);
    var newFilters:Array = new Array();
    newFilters.push(g);
    event.currentTarget.filters = newFilters;
}</notextile></code></pre>
</div>
<p> As you can see Flash Filters are easy to implement and you don&#8217;t need any other software.</p>
<p><span style="font-weight: bold; text-decoration: underline;">Flash Filters Demonstrated<br />
</span><br/>I&#8217;ve created a very small <a href="/flex/flash_filters_demo/flashFilters.html" title="Flex app to demonstrate both of these techniques">Flex app to demonstrate both of these techniques</a> as well as give you something to look at. View Source is enabled so right + click and select view source to download the app and view the full source.</p>
<p><span style="font-weight: bold; text-decoration: underline;">Other Resources<br />
 </span>
<ul>
<li><a href="http://weblogs.macromedia.com/mc/" title="Adobe Consulting">Adobe Consulting</a> </li>
<li><a href="http://www.scalenine.com/" title="Flex Themes at scalenine.com">Flex Themes at scalenine.com</a></li>
<li><a href="http://livedocs.macromedia.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=styles_069_27.html" title="Using Filters in Flex">Using Filters in Flex</a> (livedocs)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tomcornilliac.com/2007/01/applying-flash-filters-to-flex-components/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
