<?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>Almer/Blank Labs &#187; Omar Gonzalez</title>
	<atom:link href="http://labs.almerblank.com/author/omargonzalez/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.almerblank.com</link>
	<description>Blog of the Talent at Almer/Blank</description>
	<lastBuildDate>Mon, 19 Jul 2010 22:55:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Android Dev Kit from Adobe</title>
		<link>http://labs.almerblank.com/2010/07/android-dev-kit-from-adobe/</link>
		<comments>http://labs.almerblank.com/2010/07/android-dev-kit-from-adobe/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 21:41:06 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1523</guid>
		<description><![CDATA[Today I received an Android Dev Kit from Adobe! I posted a picture on my Twitter account: http://twitter.com/s9tpepper/status/18376097810
I&#039;ve already got a few ideas and things I want to try on the Nexus One, so guess I know what I&#039;ll be doing for the next week when I get home from work.
]]></description>
			<content:encoded><![CDATA[<p>Today I received an Android Dev Kit from Adobe! I posted a picture on my Twitter account: <a href="http://twitter.com/s9tpepper/status/18376097810" target="_blank">http://twitter.com/s9tpepper/status/18376097810</a></p>
<p>I&#039;ve already got a few ideas and things I want to try on the Nexus One, so guess I know what I&#039;ll be doing for the next week when I get home from work.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2010/07/android-dev-kit-from-adobe/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Illustrator CS5 to Flex4, so simple.</title>
		<link>http://labs.almerblank.com/2010/04/illustrator-cs5-to-flex4-so-simple/</link>
		<comments>http://labs.almerblank.com/2010/04/illustrator-cs5-to-flex4-so-simple/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 18:05:11 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[cs5]]></category>
		<category><![CDATA[illustrator]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[workflows]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1398</guid>
		<description><![CDATA[While I was doing some work this morning on a Flex4 application I found a pretty neat way of integrating Illustrator CS5 assets into Flex 4 with relative ease using FXG 2.0.  I haven&#039;t tested this method using other versions of FXG, but using 2.0 works great.
For my example, I used the tiger SVG [...]]]></description>
			<content:encoded><![CDATA[<p>While I was doing some work this morning on a Flex4 application I found a pretty neat way of integrating Illustrator CS5 assets into Flex 4 with relative ease using FXG 2.0.  I haven&#039;t tested this method using other versions of FXG, but using 2.0 works great.<span id="more-1398"></span></p>
<p>For my example, I used the tiger SVG file that I always see in SVG posts to create some vector art in Illustrator.  After opening the SVG I simply saved it as an FXG 2.0 file using the Save As menu.  In the FXG options I just used the default options.<br />
<img class="alignnone" title="FXG Options" src="http://laflash.org/wp-content/uploads/2010/04/Screen-shot-2010-04-14-at-10.33.55-AM.png" alt="" width="653" height="566" /></p>
<p>After saving the FXG file, I placed the file in my src folders in a Flex 4 project in Flash Builder 4.  I made a skins package to drop the file in.<br />
<img class="alignnone" title="FXG File Placement" src="http://laflash.org/wp-content/uploads/2010/04/Screen-shot-2010-04-14-at-10.51.18-AM.png" alt="" width="292" height="306" /></p>
<p>Once you drop your FXG file into your project, using the file is a breeze.  Just write the tag in!<br />
<img class="alignnone" title="Using FXG in Flex 4" src="http://laflash.org/wp-content/uploads/2010/04/Screen-shot-2010-04-14-at-11.05.41-AM.png" alt="" width="608" height="262" /></p>
<p>It really is as simple as that.  Using this method you can use these FXG files very easily in any of your Spark skins.  Here&#039;s the rendered FXG:<br />
<img class="alignnone" title="FXG rendered in Flex 4" src="http://laflash.org/wp-content/uploads/2010/04/Screen-shot-2010-04-14-at-10.38.57-AM.png" alt="" width="956" height="612" /></p>
<p>Once you have your fxg graphics rendering, you can manipulate the object using width, height, alpha, etc and the graphics will scale as you&#039;d expect from vector graphics.<br />
<img class="alignnone" title="Altered FXG at runtime" src="http://laflash.org/wp-content/uploads/2010/04/Screen-shot-2010-04-14-at-10.39.34-AM.png" alt="" width="1360" height="858" /></p>
<p>Download Flash Builder 4 project file here: <a href="http://laflash.org/wp-content/uploads/2010/04/FXGinFlex4.fxp">Example Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2010/04/illustrator-cs5-to-flex4-so-simple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZamfBrowser 1.2 and ZendAmfServiceBrowser Update</title>
		<link>http://labs.almerblank.com/2010/02/zamfbrowser-1-2-and-zendamfservicebrowser-update/</link>
		<comments>http://labs.almerblank.com/2010/02/zamfbrowser-1-2-and-zendamfservicebrowser-update/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 21:58:42 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Zamf]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[ZendAMF]]></category>
		<category><![CDATA[ZendAMF Service Browser]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1321</guid>
		<description><![CDATA[Over the weekend I updated both the ZamfBrowser application and the ZendAmfServiceBrowser class that gives the ZamfBrowser information about your ZendAMF services set up.  The ZendAmfServiceBrowser class now supports using the Zend_Amf_Server-&#62;addDirectory() method.  I also integrated some optimization suggestions submitted by Marijn Huizendveld.  Thanks for your contributions Marijn!  ZamfBrowser got updates to fix all the [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend I updated both the ZamfBrowser application and the ZendAmfServiceBrowser class that gives the ZamfBrowser information about your ZendAMF services set up.  <span id="more-1321"></span>The ZendAmfServiceBrowser class now supports using the Zend_Amf_Server-&gt;addDirectory() method.  I also integrated some optimization suggestions submitted by Marijn Huizendveld.  Thanks for your contributions Marijn!  ZamfBrowser got updates to fix all the currently reported bugs.  You can get more info about what exactly was updated, as well as download the source, at http://zamfbrowser.riaforge.com.  Info on the ZendAmfServiceBrowser class update can be found at http://www.zamfbrowser.org</p>
<p>If you have suggestions for enhancements or more bug fixes please do report them at http://zamfbrowser.riaforge.com  If you don&#039;t want to sign up for RIAForge just send me an email to omar@almerblank.com, I&#039;d really like to hear your suggestions and bug reports!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2010/02/zamfbrowser-1-2-and-zendamfservicebrowser-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Thoughts on PureMVC Mediators</title>
		<link>http://labs.almerblank.com/2010/02/thoughts-on-puremvc-mediators/</link>
		<comments>http://labs.almerblank.com/2010/02/thoughts-on-puremvc-mediators/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 05:01:52 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[code examples]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[PureMVC]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1302</guid>
		<description><![CDATA[A common practice amongst PureMVC developers when creating PureMVC Mediator implementations is the &#034;view getter&#034;, a getter method that returns the instance of the view object that the Mediator is coupled with.  As an example I will use an imaginary media player with a playlist. In a PlaylistMediator class the method would be something [...]]]></description>
			<content:encoded><![CDATA[<p>A common practice amongst PureMVC developers when creating PureMVC Mediator implementations is the &#034;view getter&#034;, a getter method that returns the instance of the view object that the Mediator is coupled with.  As an example I will use an imaginary media player with a playlist.<span id="more-1302"></span> In a PlaylistMediator class the method would be something like below.</p>
<p>ex. PlaylistMediator</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.project.view
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.patterns.mediator.Mediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PlaylistMediator extends Mediator
	<span style="color: #000000;">&#123;</span>
		static <span style="color: #0033ff; font-weight: bold;">public</span> const NAME<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;PlaylistMediator&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> PlaylistMediator<span style="color: #000000;">&#40;</span> viewComponent<span style="color: #000000; font-weight: bold;">:</span>PlaylistView <span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span> NAME, viewComponent <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> playlistView<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>PlaylistView
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> getViewComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> PlaylistView;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>As I&#039;ve worked on PureMVC projects with other developers I&#039;ve had the opportunity to see different approaches at writing application code in a PureMVC setting.  The view getter was a pretty common practice, but as I&#039;ve seen the way its used, and abused, I started wondering to myself, why?  Why is this method necessary?  Well obviously, it is necessary to retrieve the view component, without having to cast the type each time its needed.  The real question is, why is it public?</p>
<p>The purpose of the Mediator is to listen for events on the view and send notifications to the Controller, and to provide an API to manipulate the view.  And to a lesser extent, to listen to notifications that should update the view.  However, I am not a fan of this either, and I try to keep notification handling in Mediators to a minimum.  But that is beside the point I am trying to make about the view getter.  With an API to the view provided by the Mediator I feel like the view getter should actually be protected or private, instead of public.</p>
<p>ex. PlaylistMediator</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.project.view
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.patterns.mediator.Mediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PlaylistMediator extends Mediator
	<span style="color: #000000;">&#123;</span>
		static <span style="color: #0033ff; font-weight: bold;">public</span> const NAME<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;PlaylistMediator&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> PlaylistMediator<span style="color: #000000;">&#40;</span> viewComponent<span style="color: #000000; font-weight: bold;">:</span>PlaylistView <span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span> NAME, viewComponent <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> playlistView<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>PlaylistView
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> getViewComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> PlaylistView;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Using protected or private enforces that you should manipulate the view via the Mediator&#039;s API, and also stops promoting code like this:</p>
<p>ex. PlaylistLoadedCommand</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.project.controller.command
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.view.PlaylistMediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.interfaces.INotification;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.patterns.command.SimpleCommand;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PlaylistLoadedCommand extends SimpleCommand
	<span style="color: #000000;">&#123;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> execute<span style="color: #000000;">&#40;</span> notification<span style="color: #000000; font-weight: bold;">:</span>INotification <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> playlist<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = notification.getBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Array</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> playlistMediator<span style="color: #000000; font-weight: bold;">:</span>PlaylistMediator = facade.retrieveMediator<span style="color: #000000;">&#40;</span> PlaylistMediator.NAME <span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> PlaylistMediator;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> playlistItemView<span style="color: #000000; font-weight: bold;">:</span>PlaylistItemView;
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&amp;</span>lt; playlist.<span style="color: #004993;">length</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				playlistItemView		= <span style="color: #0033ff; font-weight: bold;">new</span> PlaylistItemView<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				playlistItemView.<span style="color: #004993;">data</span>		= playlist<span style="color: #000000;">&#91;</span> i <span style="color: #000000;">&#93;</span>;
				playlistItemView.<span style="color: #004993;">x</span>		= <span style="color: #000000; font-weight:bold;">0</span>;
				playlistItemView.<span style="color: #004993;">y</span>		= playlistItemView.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">*</span> i;
				playlistMediator.playlistView.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> playlistItemView <span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And instead, promotes code like this:</p>
<p>ex. PlaylistLoadedCommand &#8211; Registered to a notification sent when a Proxy is done loading playlist data</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.project.controller.command
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.view.PlaylistMediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.interfaces.INotification;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.patterns.command.SimpleCommand;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PlaylistLoadedCommand extends SimpleCommand
	<span style="color: #000000;">&#123;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> execute<span style="color: #000000;">&#40;</span> notification<span style="color: #000000; font-weight: bold;">:</span>INotification <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> playlist<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = notification.getBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Array</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> playlistMediator<span style="color: #000000; font-weight: bold;">:</span>PlaylistMediator = facade.retrieveMediator<span style="color: #000000;">&#40;</span> PlaylistMediator.NAME <span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> PlaylistMediator;
			playlistMediator.updatePlaylist<span style="color: #000000;">&#40;</span> playlist <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>In this example the Command simply calls the updatePlaylist() method on the PlaylistMediator, which encapsulates the logic required to actually update the playlist.  The PlaylistMediator can now also offer this functionality to another application system if it is required later in development due to another action.  Perhaps when the playlist is done and a refresh call is made, or if the user manually refreshes the playlist.</p>
<p>ex. In PlaylistMediator&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> updatePlaylist<span style="color: #000000;">&#40;</span> playlist<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> playlistItemView<span style="color: #000000; font-weight: bold;">:</span>PlaylistItemView;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&amp;</span>lt; playlist.<span style="color: #004993;">length</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		playlistItemView		= <span style="color: #0033ff; font-weight: bold;">new</span> PlaylistItemView<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		playlistItemView.<span style="color: #004993;">data</span>		= playlist<span style="color: #000000;">&#91;</span> i <span style="color: #000000;">&#93;</span>;
		playlistItemView.<span style="color: #004993;">x</span>		= <span style="color: #000000; font-weight:bold;">0</span>;
		playlistItemView.<span style="color: #004993;">y</span>		= playlistItemView.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">*</span> i;
&nbsp;
		playlistView.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> playlistItemView <span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This was just a small example, where I only showed accessing one mediator.  There are instances where a notification might need to update two or three views.  Instead of writing 10-20 lines in a Command per Mediator that needs to have a view updated, its much neater and easier to read to simply call a method on each Mediator.  This has other benefits other than short code.  If you are following some code that you are trying to debug it is easier to understand what happens if a notification is handled directly by a Command, since you will be able to see all affected actors, Mediators, Proxies, in a single centralized location.  Listening to the notifications within all the mediators makes it more difficult to find all of the places that a single notification effects, as the example illustrates below.  The alternative would be to listen to the notifications in each mediator, and have a command that triggers the proxy method.  I think its more maintainable and easier to debug if all notifications go directly to a command.  It makes more commands, and its more tedious, but in the end its far more maintainable and easier to debug.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.project.controller.command
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.view.PlaylistMediator;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.view.MenuMediator;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.model.proxy.ApplicationDataProxy;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.interfaces.INotification;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.patterns.command.SimpleCommand;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PlaylistLoadedCommand extends SimpleCommand
	<span style="color: #000000;">&#123;</span>
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> execute<span style="color: #000000;">&#40;</span> notification<span style="color: #000000; font-weight: bold;">:</span>INotification <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> playlist<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = notification.getBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Array</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> playlistMediator<span style="color: #000000; font-weight: bold;">:</span>PlaylistMediator = facade.retrieveMediator<span style="color: #000000;">&#40;</span> PlaylistMediator.NAME <span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> PlaylistMediator;
			playlistMediator.updatePlaylist<span style="color: #000000;">&#40;</span> playlist <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> menuMediator<span style="color: #000000; font-weight: bold;">:</span>MenuMediator = facade.retrieveMediator<span style="color: #000000;">&#40;</span> MenuMediator.NAME <span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> MenuMediator;
			menuMediator.resetMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> applicationDataProxy<span style="color: #000000; font-weight: bold;">:</span>ApplicationDataProxy = facade.retrieveMediator<span style="color: #000000;">&#40;</span> ApplicationDataProxy.NAME <span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> ApplicationDataProxy;
			applicationDataProxy.getPlaylistInfo<span style="color: #000000;">&#40;</span> playlist <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2010/02/thoughts-on-puremvc-mediators/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ZamfBrowser 1.1</title>
		<link>http://labs.almerblank.com/2009/11/zamfbrowser-1-1/</link>
		<comments>http://labs.almerblank.com/2009/11/zamfbrowser-1-1/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 22:50:21 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[code examples]]></category>
		<category><![CDATA[code generator]]></category>
		<category><![CDATA[flash builder]]></category>
		<category><![CDATA[stub]]></category>
		<category><![CDATA[stub code]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Zamf]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[ZendAMF]]></category>
		<category><![CDATA[ZendAMF Service Browser]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1275</guid>
		<description><![CDATA[Just posted an update to ZamfBrowser.  ZamfBrowser can now generate code for use in either Flash or Flex based projects.  Simply point ZamfBrowser to the source path folder where your code is, the &#034;com&#034; folder.  Then enter the package you would like the services in, for example &#034;com.project.services&#034;.  ZamfBrowser will create a methods package and [...]]]></description>
			<content:encoded><![CDATA[<p>Just posted an update to ZamfBrowser.  ZamfBrowser can now generate code for use in either Flash or Flex based projects.  <span id="more-1275"></span>Simply point ZamfBrowser to the source path folder where your code is, the &#034;com&#034; folder.  Then enter the package you would like the services in, for example &#034;com.project.services&#034;.  ZamfBrowser will create a methods package and a classes package within the services package you specify.  The classes in the &#034;classes&#034; package reflect the AMF services on the backend.  Service calls can also be made by starting a method object by itself from the classes in the &#034;methods&#034; package.  The Flex package uses the same class that ZamfBrowser uses to unit test methods.  The Flash package has been lightly tested.  As bugs come up please post them to the site http://zamfbrowser.riaforge.org   Usage examples will follow soon at http://labs.almerblank.com</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2009/11/zamfbrowser-1-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ZamfBrowser 1.0 &#8211; ZendAMF Service Browser</title>
		<link>http://labs.almerblank.com/2009/11/zamfbrowser-1-0-zendamf-service-browser/</link>
		<comments>http://labs.almerblank.com/2009/11/zamfbrowser-1-0-zendamf-service-browser/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 02:46:08 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Service Browser]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Zamf]]></category>
		<category><![CDATA[ZamfBrowser]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[ZendAMF]]></category>
		<category><![CDATA[ZendAMF Service Browser]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1265</guid>
		<description><![CDATA[ZamfBrowser is a ZendAMF Service Browser, like the AMFPHP Service Browser, which lets a developer unit test ZendAMF services.  I posted this project today for download on RIAForge at http://zamfbrowser.riaforge.com.  There is a demo of a ZendAMF implementation with ZamfBrowser implemented available at the site at http://www.zamfbrowser.org.  You can also download the demo source files [...]]]></description>
			<content:encoded><![CDATA[<p>ZamfBrowser is a ZendAMF Service Browser, like the AMFPHP Service Browser, which lets a developer unit test ZendAMF services.  I posted this project today for download on RIAForge at <a title="http://zamfbrowser.riaforge.com" href="http://zamfbrowser.riaforge.com" target="_blank">http://zamfbrowser.riaforge.com</a>.  <span id="more-1265"></span>There is a demo of a ZendAMF implementation with ZamfBrowser implemented available at the site at <a title="ZamfBrowser Home Page" href="http://www.zamfbrowser.org" target="_blank">http://www.zamfbrowser.org</a>.  You can also download the demo source files <a title="ZamfBrowser Demo Download" href="http://www.zamfbrowser.org/files/ZamfDemo.zip" target="_blank">here</a>.  I posted a walk-through on the documentation page.  Hopefully its written clear enough to understand, if not I&#039;ll be glad to answer any questions.</p>
<p><a href="http://labs.almerblank.com/wp-content/uploads/2009/11/nine.png"><img class="alignnone size-full wp-image-1266" title="nine" src="http://labs.almerblank.com/wp-content/uploads/2009/11/nine.png" alt="nine" width="1040" height="702" /></a></p>
<p>I plan on adding some AS3 service class export functionality next for Flash and Flex applications. The other big feature I want to add soon is strong type support, to test and see strongly typed objects.</p>
<p>On my server if you directly hit the http://www.zamfbrowser.org/zamf_demo/gateway.php file, the file downloads.  I believe it has something to do with the AMF response header and the server settings.  I&#039;m just not certain on that  yet.  The gateway does work with an AMF client though.  Also, if you have a gateway named something like this:  http://www.server.com/api/index.php, you can use http://www.server.com/api/, but if you leave out the trailing slash the browser does not load the gateway properly.  I&#039;m trying to track that issue down.</p>
<p>Hopefully this is as helpful to some as it&#039;s been for me in the first couple of days! =)</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2009/11/zamfbrowser-1-0-zendamf-service-browser/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Organizing PureMVC Notifications</title>
		<link>http://labs.almerblank.com/2009/11/organizing-puremvc-notifications/</link>
		<comments>http://labs.almerblank.com/2009/11/organizing-puremvc-notifications/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:33:28 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[pmvc]]></category>
		<category><![CDATA[PureMVC]]></category>
		<category><![CDATA[standards]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1071</guid>
		<description><![CDATA[One of my favorite things about using PureMVC as my application framework are the standards established for organizing application code.  For notification names the common ways that I have seen these organized is by declaring constants on the concrete Facade, or by externalizing them to external classes.  I have tried both approaches, but my preferred [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite things about using PureMVC as my application framework are the standards established for organizing application code.  For notification names the common ways that I have seen these organized is by declaring constants on the concrete Facade, or by externalizing them to external classes.  I have tried both approaches, but my preferred method is to externalize the constants to notification classes.  Not only do I feel like its more organized because the notification names for a section of the application are centralized to different notification classes.  But, it is also a good way to clean up the amount of imports in the concrete Facade and centralize the Command registrations to these notification classes.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.project.controller.notifications
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.controller.commands.LoginCommand;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.controller.commands.LogoutCommand;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.interfaces.IFacade;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LoginNotifications
	<span style="color: #000000;">&#123;</span>
		static <span style="color: #0033ff; font-weight: bold;">public</span> const LOGIN<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;LOGIN_NOTIFICATION&quot;</span>;
&nbsp;
		static <span style="color: #0033ff; font-weight: bold;">public</span> const LOGOUT<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;LOGOUT_NOTIFICATION&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LoginNotifications<span style="color: #000000;">&#40;</span> facade<span style="color: #000000; font-weight: bold;">:</span>IFacade <span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			facade.registerCommand<span style="color: #000000;">&#40;</span> LOGIN, LoginCommand <span style="color: #000000;">&#41;</span>;
			facade.registerCommand<span style="color: #000000;">&#40;</span> LOGOUT, LogoutCommand <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Above is an example of a notification class.  The constructor requires an IFacade object that it uses in the constructor to map notifications to commands using the IFacade object that is passed into the constructor.  You can see how a bigger group of commands can be nicely organized into this class.  Below is an example concrete Facade.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.project
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.project.controller.notifications.LoginNotifications;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.puremvc.as3.patterns.facade.Facade;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ProjectFacade extends Facade
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ProjectFacade<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		static <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>ProjectFacade
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>instance<span style="color: #000000;">&#41;</span> instance = <span style="color: #0033ff; font-weight: bold;">new</span> ProjectFacade<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">return</span> instance;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> initializeController<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span>.initializeController<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">new</span> LoginNotifications<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">this</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>In the example above we can see the usage example for the notifications class for the login group.  In the override for the initializeController() method, after initializing the controller, a LoginNotifications object is started with a reference to the IFacade instance that is the concrete facade, or simply &#034;this&#034;.  The amount of imports is reduced in the concrete facade, and there are less lines required in the initializeController() method, creating a neater, shorter concrete facade class.</p>
<p>This kind of organization is almost always based on personal preference, this just happens to be mine. =)</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2009/11/organizing-puremvc-notifications/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Moving rotated objects, the getBounds() bug, and how to fix it : Part One</title>
		<link>http://labs.almerblank.com/2009/11/moving-rotated-objects-the-getbounds-bug-and-how-to-fix-it-part-one/</link>
		<comments>http://labs.almerblank.com/2009/11/moving-rotated-objects-the-getbounds-bug-and-how-to-fix-it-part-one/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 03:07:08 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[code examples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[getBounds]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=997</guid>
		<description><![CDATA[Recently I was working on some bug fixes for a client project when I came across a bug with getBounds().  The issue that needed to be fixed had to do with an application that has an alignment feature.  Originally I had coded the alignment command to examine the x/y coordinates and the dimensions of the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on some bug fixes for a client project when I came across a bug with getBounds().  The issue that needed to be fixed had to do with an application that has an alignment feature.  Originally I had coded the alignment command to examine the x/y coordinates and the dimensions of the objects in order to figure out which coordinates to move the items.  This approach works correctly as long as the objects being aligned do not have any rotation set.</p>
<p>Throwing rotation into the mix no longer guarantees that the registration point is the top left coordinate of the item being aligned, which renders the first approach incorrect.  The first part of this blog post will go into the getBounds() method, what the bug is, and how to get the accurate bounds.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://labs.almerblank.com/wp-content/uploads/2009/11/getBoundsBug.swf" /><embed type="application/x-shockwave-flash" width="550" height="400" src="http://labs.almerblank.com/wp-content/uploads/2009/11/getBoundsBug.swf"></embed></object></p>
<p>This SWF above demonstrates the issues with the getBounds() method.  On the stage is a MovieClip instance with a triangle shape in it, the MovieClip&#039;s rotation is set to 0 at start up.  Pressing the &#034;Toggle MC Border&#034; button draws a 1 pixel red line around the border of the MovieClip that has the triangle.  Pressing the &#034;Toggle Unrotated getBounds()&#034; displays the rectangle returned by the getBounds() method before the MovieClip has been rotated.  Before explaining the last two buttons, lets shift focus to the Rotation input at the top.  The first two buttons show the border and the unrotated bounds border.  The Rotation input lets us modify the rotation of the MovieClip.  If the object is rotated to 45 degrees by typing in 45 and clicking the &#034;Set Rotation&#034; button the first two buttons still perform the same function.  Except that now that the MovieClip is rotated the unrotated bounds rectangle now longer contains the shape inside of it.  If you turn off both the MC Border and the Unrotated getBounds(), and click on &#034;Toggle Rotated getBounds()&#034;, you will see that the red border does not accurately draw to the expected size.  The top and right borders are further away from the right edge, which should meet at the top right of the shape.  If you click on &#034;Toggle MC Border&#034;, you can visually see why.  The getBounds() method calculates the bounds Rectangle object by using the actual borders of the MovieClip, instead of actual graphical space that the MovieClip occupies.  If you now click on the fourth button, &#034;Toggle getAccurateBounds()&#034;, you will see the blue rectangle drawn to the expected shape.  If the MovieClip&#039;s border is still on, the blue rectangle will be the same size as the red rectangle as seen in the screenshot below.</p>
<p><img class="alignnone size-full wp-image-1050" title="Screen shot 2009-11-02 at 6.32.32 PM" src="http://labs.almerblank.com/wp-content/uploads/2009/11/Screen-shot-2009-11-02-at-6.32.32-PM.png" alt="Screen shot 2009-11-02 at 6.32.32 PM" width="547" height="397" /></p>
<p>This is because the red 1 pixel border showing the MovieClip&#039;s border is taken into account, accurately, by the getAccurateBounds() method that I wrote.  That results in the bounds rectangle to do the same thing that getBounds() does.  If you press &#034;Toggle MC Border&#034; and turn off the MovieClip&#039;s border, and then turn the accurate border off and back on, you will see the difference in how the new actual bounds is actually wrapping the rotated triangle accurately.</p>
<p><img class="alignnone size-full wp-image-1050" title="Screen shot 2009-11-02 at 6.32.16 PM" src="http://labs.almerblank.com/wp-content/uploads/2009/11/Screen-shot-2009-11-02-at-6.32.16-PM.png" alt="Screen shot 2009-11-02 at 6.32.16 PM" width="547" height="397" /></p>
<p>Below is the _getAccurateBounds() method that is calculating the blue rectangle we see above.  This method demonstrates the technique to find the accurate bounds, but would likely need to be slightly altered to fit within real implementations depending on the actual architecture of the application its going to be used in because of the fact that it currently requires me to remove it from the stage to draw it independently of any other display objects.  It can probably also be accomplished by looping through the children of the clip&#039;s parent to turn off any visible items and turn them back on after the drawing process, but for the sake of simplicity in this example I will simply attach it to my placeholder bounds clip and then put it back.</p>
<p>Anyhow, the way that I accomplished this was by isolating the MovieClip that I want an accurate bounds Rectangle object from.  In my example I place it in a Sprite called boundsClip.  Next I set up a ColorTransform object with a color of blue (0&#215;0000FF).  This ColorTransform object is used in the next step, where I create a BitmapData object sized to the clip&#039;s parent&#039;s dimensions, in this case the SWF&#039;s stage.  I then draw the boundsClip into the BitmapData object.  That is why I place the clip into a placeholder Sprite, so it can be drawn into the BitmapData in the correct position using its x,y coordinates.  In the draw() method, I use the colorTransform object to tint the bitmap blue.  This is crucial to the last step.  Before returning the accurate bounds, I place the clip back onto the stage.  And finally, I get the accurate bounds of the clip by using the getColorBoundsRect() method on the BitmapData object.  In the example application above I use this Rectangle object to accurately draw the blue rectangle, which shows the accurate bounds.</p>
<p>In my next post I will go into how to use the bounds rectangle to actually move the objects to a desired position.</p>
<p>You can download the FLA for the example application here: <a href="http://labs.almerblank.com/wp-content/uploads/2009/11/getBoundsBug.fla.zip">getBoundsBug.fla</a></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> _getAccurateBounds<span style="color: #000000;">&#40;</span> clip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// Make a placeholder clip to draw the clip isolated from anything else</span>
        <span style="color: #009900;">// that is on stage.</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> boundsClip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            boundsClip.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> clip <span style="color: #000000;">&#41;</span>;
&nbsp;
        <span style="color: #009900;">// Make a ColorTransform object to tint the bitmap that is going to be</span>
        <span style="color: #009900;">// drawn based on the clip passed into _getAccurateBounds()</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> boundsColorTint<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = 0x0000FF;
	<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">colorTransform</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ColorTransform</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ColorTransform</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">colorTransform</span>.<span style="color: #004993;">color</span> = boundsColorTint;
&nbsp;
	<span style="color: #009900;">// Draw a BitmapData object with the clip passed into _getAccurateBounds()</span>
        <span style="color: #009900;">// and tint the BitmapData to a color, I use blue.</span>
        <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">bitmapData</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>,
                                                    <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>,
                                                    <span style="color: #0033ff; font-weight: bold;">true</span>,
                                                    0xFF000000 <span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">bitmapData</span>.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span> boundsClip, <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #004993;">colorTransform</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
        <span style="color: #009900;">// Place the mc back onto the stage after drawing it.</span>
        <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> clip <span style="color: #000000;">&#41;</span>;
&nbsp;
        <span style="color: #009900;">// Return the Rectangle object from the getColorBoundsRect() method on</span>
        <span style="color: #009900;">// the BitmapData object.  This Rectangle object will contain the</span>
        <span style="color: #009900;">// correct bounds of the item you want the bounds of rotated or not.</span>
        <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">bitmapData</span>.<span style="color: #004993;">getColorBoundsRect</span><span style="color: #000000;">&#40;</span> 0xFFFFFF, boundsColorTint, <span style="color: #0033ff; font-weight: bold;">false</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2009/11/moving-rotated-objects-the-getbounds-bug-and-how-to-fix-it-part-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
