<?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>Sönke Rohde &#187; ActionScript</title>
	<atom:link href="http://soenkerohde.com/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://soenkerohde.com</link>
	<description>Flash Platform (Flash, Flex, AIR) thoughts and examples</description>
	<lastBuildDate>Wed, 18 Apr 2012 22:45:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>AIR Mobile StageWebView UIComponent</title>
		<link>http://soenkerohde.com/2010/11/air-mobile-stagewebview-uicomponent/</link>
		<comments>http://soenkerohde.com/2010/11/air-mobile-stagewebview-uicomponent/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 16:28:53 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=995</guid>
		<description><![CDATA[<p>When you want to use webkit to display HTML in AIR 2.5 mobile projects you want to use StageWebView. Since StageWebView is a subclass of EventDispatcher you cannot add it to the display chain right away. The API works a bit differently and you need to define a Rectangle as the viewPort. However, I thought it [...]]]></description>
			<content:encoded><![CDATA[<p>When you want to use webkit to display HTML in AIR 2.5 mobile projects you want to use <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/media/StageWebView.html">StageWebView</a>. Since StageWebView is a subclass of EventDispatcher you cannot add it to the display chain right away. The API works a bit differently and you need to define a Rectangle as the viewPort. However, I thought it would be convenient to have a StageWebView UIComponent so that you can add it to the display chain. It is just a wrapper class which exposes the needed APIs like the <em>text</em> and <em>url</em> setter and the methods <em>show</em>, <em>hide</em> and <em>dispose</em>. Further you can listen for all event listeners which just get cloned and re-dispatched.</p>
<p>Example:<br />
<script src="https://gist.github.com/666366.js?file=StageWebViewUIComponentExampleView.mxml"></script></p>
<p>Source:<br />
<script src="https://gist.github.com/666342.js?file=StageWebViewUIComponent.as"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2010/11/air-mobile-stagewebview-uicomponent/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Swiz Yahoo Finance Metadata Processor</title>
		<link>http://soenkerohde.com/2010/03/swiz-yahoo-finance-metadata-processor/</link>
		<comments>http://soenkerohde.com/2010/03/swiz-yahoo-finance-metadata-processor/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 19:38:19 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Swiz]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=957</guid>
		<description><![CDATA[<p>Swiz 1.0 alpha introduced a very cool new feature which lets you extend Swiz be creating custom metadata processors.
This means that if you want to add a metadata like [MyCustomMetadata] you can now do so and Swiz offers you a very easy way to implement it.
For the Swiz 360 Flex demo app I have build a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://swizframework.org">Swiz</a> 1.0 alpha introduced a very cool new feature which lets you extend Swiz be creating custom metadata processors.<br />
This means that if you want to add a metadata like [MyCustomMetadata] you can now do so and Swiz offers you a very easy way to implement it.<br />
For the <a href="http://github.com/srohde/Swiz1Example">Swiz 360 Flex demo app</a> I have build a proof of concept YahooFinance metadata processor. The idea was to have something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>YahooFinance<span style="color: #66cc66;">&#40;</span>tickerSymbol=<span style="color: #ff0000;">&quot;ADBE&quot;</span>, days=<span style="color: #ff0000;">&quot;60&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> adobeStocks:IList;</pre></div></div>

<p>When you annotate the list variable with that metadata the YahooFinanceProcessor gets notified to process it and for the case above fetches the Adobe stock data for the last 60 days. The result is a list of objects which contain a date and a price. You can then bind this list to a chart é voilá, your chart shows live fetched data without writing any code (ok, except declaring the variable).</p>
<p>Here the full source of the view component:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>s:Group xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> 
		 xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> 
		 xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>fx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">IList</span>;
&nbsp;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
			<span style="color: #66cc66;">&#91;</span>YahooFinance<span style="color: #66cc66;">&#40;</span>tickerSymbol=<span style="color: #ff0000;">&quot;ADBE&quot;</span>, days=<span style="color: #ff0000;">&quot;60&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
			<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> adobeStocks:IList;
&nbsp;
			<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
			<span style="color: #66cc66;">&#91;</span>YahooFinance<span style="color: #66cc66;">&#40;</span>tickerSymbol=<span style="color: #ff0000;">&quot;MSFT&quot;</span>, days=<span style="color: #ff0000;">&quot;60&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
			<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> microsoftStocks:IList;
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>fx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>s:layout<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>s:VerticalLayout<span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>s:layout<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>s:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Stock Prices last 60 days&quot;</span> <span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:LineChart id=<span style="color: #ff0000;">&quot;chart&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> showDataTips=<span style="color: #ff0000;">&quot;true&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{adobeStocks}&quot;</span><span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:horizontalAxis<span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:CategoryAxis categoryField=<span style="color: #ff0000;">&quot;date&quot;</span> title=<span style="color: #ff0000;">&quot;Time&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:horizontalAxis<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:verticalAxis<span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:LinearAxis title=<span style="color: #ff0000;">&quot;Price&quot;</span> baseAtZero=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:verticalAxis<span style="color: #66cc66;">&gt;</span>
&nbsp;
		<span style="color: #66cc66;">&lt;</span>mx:series<span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:LineSeries dataProvider=<span style="color: #ff0000;">&quot;{microsoftStocks}&quot;</span> displayName=<span style="color: #ff0000;">&quot;Microsoft&quot;</span> xField=<span style="color: #ff0000;">&quot;date&quot;</span> yField=<span style="color: #ff0000;">&quot;price&quot;</span> <span style="color: #66cc66;">/&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:LineSeries dataProvider=<span style="color: #ff0000;">&quot;{adobeStocks}&quot;</span> displayName=<span style="color: #ff0000;">&quot;Adobe&quot;</span> xField=<span style="color: #ff0000;">&quot;date&quot;</span> yField=<span style="color: #ff0000;">&quot;price&quot;</span> <span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:series<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:LineChart<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Legend dataProvider=<span style="color: #ff0000;">&quot;{chart}&quot;</span> <span style="color: #66cc66;">/&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>s:Group<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>The result looks like this:<br />
<img src="/img/yahoochart.png" /></p>
<p>When you have a look at the <a href="http://github.com/srohde/Swiz1Example/blob/master/src/com/soenkerohde/example/processor/YahooFinanceProcessor.as">source of the YahooFinaceProcessor</a> you see how easy it is to build.</p>
<p>The example also shows how to use the <a href="http://code.google.com/p/foomonger-swizframework/">MediateSignalProcessor</a> build by <a href="http://blog.foomonger.com">Sam Ahn</a>.<br />
There are also a bunch of other custom metadata processors on the way like the <a href="http://blog.foomonger.com/2010/03/10/swiz-resourcemanager-and-resource/">ResourceProcessor</a> also by Sam.<br />
Note that I had to add -keep-as3-metadata+=YahooFinance which you have to do for any new metadata you introduce.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2010/03/swiz-yahoo-finance-metadata-processor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running Project Sprouts</title>
		<link>http://soenkerohde.com/2010/03/running-project-sprouts/</link>
		<comments>http://soenkerohde.com/2010/03/running-project-sprouts/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 02:12:16 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=907</guid>
		<description><![CDATA[<p>A few weeks ago I attended the SanFlashCisco usergroup meeting which was really great. After the meeting we moved to the Mars bar where I got to know Luke Bayes who founded Project Sprouts. Project Sprouts is a Ruby based open-source, cross-platform project generation and configuration tool for ActionScript 2, ActionScript 3, Adobe AIR and Flex [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I attended the <a href="http://sanflashcisco.com/">SanFlashCisco</a> usergroup meeting which was really great. After the meeting we moved to the Mars bar where I got to know <a href="http://www.lukebayes.com/">Luke Bayes</a> who founded <a href="http://projectsprouts.org/">Project Sprouts</a>. Project Sprouts is a Ruby based open-source, cross-platform project generation and configuration tool for ActionScript 2, ActionScript 3, Adobe AIR and Flex projects. Also be sure to check the the <a href="http://github.com/lukebayes/project-sprouts">GitHub repository</a>.</p>
<p>The following works on a Mac with <a href="http://www.ruby-lang.org/en/downloads/">Ruby</a> and <a href="http://rubyforge.org/frs/?group_id=126">RubyGems</a> installed but should be similar under Windows. Open the Terminal, switch to your working directory where you want to create your new project and:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># installs project sprouts</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> sprout
<span style="color: #666666; font-style: italic;"># creates a new Flex 4 project named SproutsExample</span>
sprout <span style="color: #660033;">-n</span> flex4 SproutsExample
<span style="color: #666666; font-style: italic;"># switch directory</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> SproutsExample
<span style="color: #666666; font-style: italic;"># build the project</span>
rake</pre></div></div>

<p>Now you see all dependencies like SDK and Flash Player being downloaded. So you can run this on a machine without Flex SDK and Flash Player installed because Sprouts handles all dependencies. However, I got this error:</p>
<pre>/Library/Ruby/Gems/1.8/gems/sprout-flashplayer-bundle-10.22.7/lib/clix_wrapper.rb:20:  (RuntimeError)
[ERROR] You must install the rb-appscript gem to use the desktop debug Flash Player, you do this by running: sudo gem install rb-appscript</pre>
<p>As being told I tried to run: <em>sudo gem install rb-appscript</em> which ended up in this error:</p>
<pre>ERROR:  Error installing rb-appscript:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h</pre>
<p>After a little web search I <a href="http://www.ruby-forum.com/topic/191688">found out</a> that I need to install the latest <a href="http://developer.apple.com/tools/xcode/">XCode</a> since I am on Snow Leopard.</p>
<p>Having XCode installed I tried again <em>sudo gem install rb-appscript</em> and it works!</p>
<p>So another try with <em>rake</em> and horray, the project gets compiled and the standalone flash player comes up showing the compiled default project!</p>
<p>So far so good. Now let&#8217;s try to create a class and a unit test for it.<br />
Due to a little bug in the flex 4 gem edit scripts/generate and replace</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> <span style="color:#9966CC; font-weight:bold;">begin</span>
      <span style="color:#6666ff; font-weight:bold;">Sprout::Sprout</span>.<span style="color:#9900CC;">generate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'flex4'</span>, ARGV.<span style="color:#9900CC;">shift</span>, ARGV, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">RubiGen::GeneratorError</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; e
      <span style="color:#6666ff; font-weight:bold;">Sprout::Sprout</span>.<span style="color:#9900CC;">generate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'as3'</span>, ARGV.<span style="color:#9900CC;">shift</span>, ARGV, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>with</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Sprout::Sprout</span>.<span style="color:#9900CC;">generate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'as3'</span>, ARGV.<span style="color:#9900CC;">shift</span>, ARGV, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>btw: when the fix for this is in place update with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem update sprout-flex4-bundle</pre></div></div>

<p>So, now you are ready to create a class including test classes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># creates the class com.soenkerohde.util.MathUtil and test classes</span>
script<span style="color: #000000; font-weight: bold;">/</span>generate com.soenkerohde.util.MathUtil</pre></div></div>

<p>You see the output</p>
<pre>create  src/com/soenkerohde/util
create  src/com/soenkerohde/util/MathUtil.as
create  test/com/soenkerohde/util
create  test/com/soenkerohde/util/MathUtilTest.as
force  test/AllTests.as
</pre>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Run the tests</span>
rake <span style="color: #7a0874; font-weight: bold;">test</span></pre></div></div>

<p>Now you see your tests compiling and they fail for now to remind you that you haven&#8217;t implemented the actual test code yet.</p>
<p>Pretty impressed by Sprouts so far but enough for now. In my next post I will try to go a little bit deeper and check what else Sprouts can do for me to not waste time on what can be automated.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2010/03/running-project-sprouts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powerful Cancelable Events</title>
		<link>http://soenkerohde.com/2010/01/powerful-cancelable-events/</link>
		<comments>http://soenkerohde.com/2010/01/powerful-cancelable-events/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 19:04:38 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=873</guid>
		<description><![CDATA[<p>When you dispatch events I bet that most Flash/Flex devs don&#8217;t take advantage of the fact that dispatchEvent returns a Boolean value indicating wether or not the event has been canceled. Normally your code looks similar to this:</p>

var event:MyEvent = new MyEvent&#40;MyEvent.FOO&#41;;
dispatchEvent&#40;event&#41;

<p>If you want to let something only happen if the event wasn&#8217;t canceled it should [...]]]></description>
			<content:encoded><![CDATA[<p>When you dispatch events I bet that most Flash/Flex devs don&#8217;t take advantage of the fact that dispatchEvent returns a Boolean value indicating wether or not the event has been canceled. Normally your code looks similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> event:MyEvent = <span style="color: #000000; font-weight: bold;">new</span> MyEvent<span style="color: #66cc66;">&#40;</span>MyEvent.<span style="color: #006600;">FOO</span><span style="color: #66cc66;">&#41;</span>;
dispatchEvent<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>If you want to let something only happen if the event wasn&#8217;t canceled it should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// The second &quot;true&quot; sets the event cancelable, first one sets bubbles</span>
<span style="color: #000000; font-weight: bold;">var</span> event:MyEvent = <span style="color: #000000; font-weight: bold;">new</span> MyEvent<span style="color: #66cc66;">&#40;</span>MyEvent.<span style="color: #006600;">FOO</span>, <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>dispatchEvent<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
   <span style="color: #808080; font-style: italic;">// do the actual task</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>With the code above the event listener can control if the actual task gets executed or not:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">dispatchingInstance.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MyEvent.<span style="color: #006600;">FOO</span>, fooHandler<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> fooHandler<span style="color: #66cc66;">&#40;</span>event:MyEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
   <span style="color: #808080; font-style: italic;">// depending on what you want to achieve you can cancel the event by calling preventDefault</span>
   event.<span style="color: #006600;">preventDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">// this will cause dispatchEvent to return false so the actual task doesn't get executed</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>A real life usecase for UI related events could be dispatching an event before closing a popup window:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> closeButtonHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
   <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MyWindowEvent<span style="color: #66cc66;">&#40;</span>MyWindowEvent.<span style="color: #0066CC;">CLOSE</span>, <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
      PopUpManager.<span style="color: #006600;">closePopup</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Cancelable events are also very interesting when you develop APIs because it offers powerful and easy to use hooks for the API user.<br />
I am making heavy use of cancelable events in my <a href="http://github.com/srohde/swizdesktop">swizdesktop lib</a>. Catching the different update phase events you get hooks to stop the update process by calling preventDefault on the listened event.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2010/01/powerful-cancelable-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chunk File Upload</title>
		<link>http://soenkerohde.com/2010/01/chunk-file-upload/</link>
		<comments>http://soenkerohde.com/2010/01/chunk-file-upload/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 12:16:40 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=840</guid>
		<description><![CDATA[<p>A while back I worked on an AIR client which had to be capable uploading very large files. In this scenario you have to upload files in little chunks. The research on how to solve this took me quite a while so I thought it would make sense to post my findings.</p>
<p>More or less I have [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I worked on an AIR client which had to be capable uploading very large files. In this scenario you have to upload files in little chunks. The research on how to solve this took me quite a while so I thought it would make sense to post my findings.</p>
<p>More or less I have taken the <a href="http://developer.nirvanix.com/forums/p/323/1783.aspx">NirvanixBinaryUploader</a> as a base and then extended (I should say forked) it to fit my needs.</p>
<p>The class <a href="http://gist.github.com/269720">UploadFile</a> takes a file and upload URL as constructor arguments. You can also define a separate resumeUrl if it differs from the upload URL. Further you can set the flag doCalcMD5 to true which is kind of experimental. It works using the <a href="http://code.google.com/p/as3corelib/">as3corelib</a> MD5Stream class but calculating the MD5 hash for large chunks like 1MB took about 20-30 secs on my machine.</p>
<p>I have also implement getters for bytesLoaded and bytesTotal so I can use an instance as a data source for the Flex ProgressBar in polled mode which comes in very handy.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:ProgressBar source=<span style="color: #ff0000;">&quot;{uploadFile}&quot;</span> mode=<span style="color: #ff0000;">&quot;polled&quot;</span> label=<span style="color: #ff0000;">&quot;Uploading&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

<p>If you want to use my code I guess you want to subclass my class because it contains example code and you probably want to override at least the createBody method. However, if you have a similar scenario like me, the code might be a good start.</p>
<p>Another interesting read on this topic was <a href="http://www.sephiroth.it/weblog/archives/2009/06/a_long_journey_through_chunked_transf.php">A long journey through chunked transfer and file uploading</a>.</p>
<p>Here now the code:</p>
<p><script src="http://gist.github.com/269720.js?file=UploadFile.as"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2010/01/chunk-file-upload/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Twitter AS3 OAuth Lib with Flex 4 example</title>
		<link>http://soenkerohde.com/2010/01/twitter-as3-oauth-lib-with-flex-4-example/</link>
		<comments>http://soenkerohde.com/2010/01/twitter-as3-oauth-lib-with-flex-4-example/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 12:30:30 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=813</guid>
		<description><![CDATA[<p>I have build a little Twitter AS3 library which handles Twitter OAuth authentication and let&#8217;s you update your Twitter status. The lib basically uses the OAuth AS3 lib and should be a good example how to use the actual OAuth lib.</p>
<p>This is still basic functionality but since it&#8217;s open source someone may fork and extend it. [...]]]></description>
			<content:encoded><![CDATA[<p>I have build a little <a href="http://github.com/srohde/Twitter">Twitter AS3 library</a> which handles <a href="http://apiwiki.twitter.com/OAuth-FAQ">Twitter OAuth authentication</a> and let&#8217;s you update your Twitter status. The lib basically uses the <a href="http://code.google.com/p/oauth-as3/">OAuth AS3 lib</a> and should be a good example how to use the actual OAuth lib.</p>
<p>This is still basic functionality but since it&#8217;s open source someone may fork and extend it. To get a simple idea of the current feature-set have a look at the <a href="http://github.com/srohde/Twitter/blob/master/src/com/soenkerohde/twitter/ITwitter.as">ITwitter interface</a>.</p>
<p>Further I have build a simple <a href="http://gist.github.com/266163">Flex 4 example AIR app</a> which shows things in action. The only thing you need to do upfront is <a href="http://twitter.com/apps">registering a Twitter app</a> to obtain an OAuth consumer key and secret which you have to add to the example:</p>
<p><script src="http://gist.github.com/266163.js?file=TwitterExample"></script></p>
<p>BTW: You maybe have already granted access to your Twitter account for some apps which you can <a href="http://twitter.com/account/connections">check here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2010/01/twitter-as3-oauth-lib-with-flex-4-example/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>FGATracker for Google Analytics tracking</title>
		<link>http://soenkerohde.com/2009/11/fgatracker-for-google-analytics-tracking/</link>
		<comments>http://soenkerohde.com/2009/11/fgatracker-for-google-analytics-tracking/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 13:10:46 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Swiz]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=780</guid>
		<description><![CDATA[<p>FGATracker is an AS3 library which wraps gaforflash for Google Analytics and can be easily used in combination with the Swiz framework.</p>
<p>Source and Download</p>

Source on GitHub
Download SWC
API docs

<p>Usage</p>
<p>Add FGATracker to your BeanLoader:</p>

&#60;ga:FGATracker id=&#34;fgaTracker&#34;
	   account=&#34;GOOGLE ANALYTICS ID&#34; xmlns:ga=&#34;com.soenkerohde.ga.*&#34; /&#62;

<p>Dispatch TrackPageEvent or TrackActionEvent:</p>
<p>From a view class (set bubbles=true):</p>

dispatchEvent&#40; new TrackPageEvent&#40; TrackPageEvent.PAGE, &#34;/pagename&#34;, true &#41; &#41;;
dispatchEvent&#40; new [...]]]></description>
			<content:encoded><![CDATA[<p>FGATracker is an AS3 library which wraps <a href="http://code.google.com/p/gaforflash/">gaforflash</a> for <a href="http://www.google.com/analytics/">Google Analytics</a> and can be easily used in combination with the <a href="http://swizframework.org">Swiz framework</a>.</p>
<p><b>Source and Download</b></p>
<ul>
<li><a href="http://github.com/srohde/FGATracker">Source on GitHub</a></li>
<li><a href="http://github.com/srohde/FGATracker/downloads">Download SWC</a></li>
<li><a href="http://srohde.github.com/fgatracker/">API docs</a></li>
</ul>
<p><b>Usage</b></p>
<p>Add FGATracker to your BeanLoader:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>ga:FGATracker id=<span style="color: #ff0000;">&quot;fgaTracker&quot;</span>
	   account=<span style="color: #ff0000;">&quot;GOOGLE ANALYTICS ID&quot;</span> xmlns:ga=<span style="color: #ff0000;">&quot;com.soenkerohde.ga.*&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

<p>Dispatch TrackPageEvent or TrackActionEvent:</p>
<p>From a view class (set bubbles=true):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> TrackPageEvent<span style="color: #66cc66;">&#40;</span> TrackPageEvent.<span style="color: #006600;">PAGE</span>, <span style="color: #ff0000;">&quot;/pagename&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> TrackActionEvent<span style="color: #66cc66;">&#40;</span> TrackActionEvent.<span style="color: #006600;">ACTION</span> <span style="color: #ff0000;">&quot;category&quot;</span>, <span style="color: #ff0000;">&quot;action&quot;</span>, <span style="color: #ff0000;">&quot;label&quot;</span>, <span style="color: #0066CC;">NaN</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>From a non-view class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">_dispatcher.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> TrackPageEvent<span style="color: #66cc66;">&#40;</span> TrackPageEvent.<span style="color: #006600;">PAGE</span>, <span style="color: #ff0000;">&quot;/pagename&quot;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>You can get a reference if your class implements the IDispatcherBean interface:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _dispatcher:IEventDispatcher;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> dispatcher<span style="color: #66cc66;">&#40;</span>dispatcher:IEventDispatcher<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	_dispatcher  = dispatcher;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2009/11/fgatracker-for-google-analytics-tracking/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FlairLoc Public Beta</title>
		<link>http://soenkerohde.com/2009/11/flairloc-public-beta/</link>
		<comments>http://soenkerohde.com/2009/11/flairloc-public-beta/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:58:24 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=722</guid>
		<description><![CDATA[<p>FlairLoc is an Adobe® AIR™ application to localize Adobe® Flex® applications.</p>
<p>Today I am happy to announce that the public beta of FlairLoc is available.</p>
<p>Features</p>

Change resources in a user interface with search capability
Extract resource keys from source code and synchronizes it with all locale sets
Automatic translation into 42 languages with the Google Translate API
Add new automatic translated [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flairloc.com">FlairLoc</a> is an Adobe® AIR™ application to localize Adobe® Flex® applications.</p>
<p>Today I am happy to announce that the public beta of FlairLoc is available.</p>
<p><strong>Features</strong></p>
<ul>
<li>Change resources in a user interface with search capability</li>
<li>Extract resource keys from source code and synchronizes it with all locale sets</li>
<li>Automatic translation into 42 languages with the Google Translate API</li>
<li>Add new automatic translated languages in only <strong>4 CLICKS</strong></li>
<li>Generation of locale compile statement and Ant parameters</li>
</ul>
<p>For more information, screenvideo and screenshots and to install the application please visit the <a href="http://flairloc.com">product page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2009/11/flairloc-public-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YouTube AS3 example</title>
		<link>http://soenkerohde.com/2009/10/youtube-as3-example/</link>
		<comments>http://soenkerohde.com/2009/10/youtube-as3-example/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 16:16:53 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Swiz]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=661</guid>
		<description><![CDATA[<p>Today YouTube finally released an ActionScript 3 API. Maybe this was accelerated by the move of Vimeo because they came up with an AS3 API last week.</p>
<p>I have build a little AIR client as an example application. Check my YouTubeAS3 project on github for the source code. The example of course uses the Swiz framework.</p>
<p>The meat [...]]]></description>
			<content:encoded><![CDATA[<p>Today <a href="http://youtube.com">YouTube</a> finally released an <a href="http://code.google.com/apis/youtube/flash_api_reference.html">ActionScript 3 API</a>. Maybe this was accelerated by the move of <a href="http://vimeo.com">Vimeo</a> because they came up with an <a href="http://vimeo.com/api/docs/advanced-api">AS3 API</a> last week.</p>
<p>I have build a little AIR client as an example application. Check my <a href="http://github.com/srohde/YouTubeAS3/">YouTubeAS3 project on github</a> for the source code. The example of course uses the <a href="http://swizframework.org/">Swiz framework</a>.</p>
<p>The meat is the <a href="http://github.com/srohde/YouTubeAS3/blob/master/src/com/soenkerohde/youtube/Player.as">Player class</a> and the <a href="http://github.com/srohde/YouTubeAS3/blob/master/src/com/soenkerohde/youtube/IPlayer.as">IPlayer interface</a> which wraps the YouTube proxy object. The Player extends UIComponent and implements IVisualElement so it works decent with <a href="opensource.adobe.com/wiki/display/flexsdk">Flex 4</a>. The original SWFProxy object extends Sprite which is fine for Flash but not for Flex.</p>
<p>If you are to lazy to study the API docs like me this screenshot might help:</p>
<div class="thumbnail"><a href="http://skitch.com/soenkerohde/ndejy/flash-debug-eclipse-users-soenkerohde-documents-workspace-gumbo"><img src="http://img.skitch.com/20091015-5cty54gbdn59eq7ergkrwsx2n.preview.jpg" alt="Flash Debug - Eclipse - /Users/soenkerohde/Documents/workspace_gumbo" /></a><br />
<span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>&#8216;s <a href="http://skitch.com">Skitch</a>!</span></div>
<p>The example is still pretty small but I&#8217;ll try to extend it when I find some time in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2009/10/youtube-as3-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Presentation Model Interface with Swiz</title>
		<link>http://soenkerohde.com/2009/08/presentation-model-interface-with-swiz/</link>
		<comments>http://soenkerohde.com/2009/08/presentation-model-interface-with-swiz/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 12:28:38 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Swiz]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=639</guid>
		<description><![CDATA[<p>Lately I have started to use the presentation model approach and I like it a lot. Swiz fellow Ben Clinkinbeard has a wonderful example posted on his blog.</p>
<p>However I disliked that I have to dispatch custom events to make getters bindable. This would normally look like this in an interface:</p>

&#91;Bindable&#40;event=&#34;customDataChanged&#34;&#41;&#93;
function get someData&#40;&#41;:Array;

<p>The problem with it is [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I have started to use the presentation model approach and I like it a lot. <a href="http://code.google.com/p/swizframework/">Swiz</a> fellow <a href="http://www.returnundefined.com/">Ben Clinkinbeard</a> has a wonderful example <a href="http://www.returnundefined.com/2009/05/swiz-example-application-with-presentation-model-pattern">posted on his blog</a>.</p>
<p>However I disliked that I have to dispatch custom events to make getters bindable. This would normally look like this in an interface:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#40;</span>event=<span style="color: #ff0000;">&quot;customDataChanged&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> someData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span>;</pre></div></div>

<p>The problem with it is that I have to dispatch an event typed &#8220;customDataChanged&#8221; from the presentation model implementation when I want the binding to be updated.<br />
So my implementation would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _someData:<span style="color: #0066CC;">Array</span>;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> someData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> _someData;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setSomeData<span style="color: #66cc66;">&#40;</span>a:<span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
    _someData = a;
    dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;customDataChanged&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>But what I wanted to use is the Swiz autowire-by-property style which would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#40;</span>bean=<span style="color: #ff0000;">&quot;appModel&quot;</span>, property=<span style="color: #ff0000;">&quot;someData&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> someData:<span style="color: #0066CC;">Array</span></pre></div></div>

<p>So for the examle above I have a bean with id appModel defined in my IoC Container (BeanLoader) which contains the someData variable. Swiz wires the property into the presentation model implementation but how do I get my interface getter bindable?<br />
The solution is quite easy. Just have a look at the generated actionscript with the compiler args -keep-generated-actionscript and you see that by default a PropertyChangeEvent is dispatched for bindable variables when they are changed. The type value of the event is &#8220;propertyChange&#8221; so the only thing I have to change in my interface is the event type:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#40;</span>event=<span style="color: #ff0000;">&quot;propertyChange&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> someData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span>;</pre></div></div>

<p>So my view gets the presentation model interface autowired-by-type:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> model:IMyPresentationModel;
<span style="color: #66cc66;">&lt;</span>s:<span style="color: #0066CC;">List</span> dataProvider=<span style="color: #ff0000;">&quot;{model.someData}&quot;</span><span style="color: #66cc66;">/&gt;</span></pre></div></div>

<p>Now when the application model someData property changes, Swiz updates the autowired property which fires a PropertyChangeEvent and forces the binding to be updated in the view.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2009/08/presentation-model-interface-with-swiz/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

