<?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>Flex Stuff by Gilles Guillemin &#187; Flex</title>
	<atom:link href="http://www.flexstuff.co.uk/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flexstuff.co.uk</link>
	<description>Stuff about Flex. And Air. Oh and Flash. And probably about other stuff as well. Who knows?</description>
	<lastBuildDate>Wed, 07 Apr 2010 05:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Flex 4: CoverFlow Layout</title>
		<link>http://www.flexstuff.co.uk/2009/12/23/flex-4-coverflow-layout/</link>
		<comments>http://www.flexstuff.co.uk/2009/12/23/flex-4-coverflow-layout/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 11:41:47 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[coverflow]]></category>
		<category><![CDATA[Flash Builder 4]]></category>
		<category><![CDATA[flex component]]></category>
		<category><![CDATA[gumbo]]></category>
		<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=907</guid>
		<description><![CDATA[An example of coverflow-like layout using the new flex 4 layout paradigm.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F12%252F23%252Fflex-4-coverflow-layout%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2F9ZXny8%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Flex%204%3A%20CoverFlow%20Layout%22%20%7D);"></div>
<blockquote><p><strong>UPDATED (07/04/2010):<br />
</strong>I&#8217;ve updated the example (and the source code) to reflect some things added in the comments and also added a new <em>stepFade</em> property (see the example).</p>
<p>Finally, I&#8217;ve also updated the example &#8220;content&#8221; so it&#8217;s more <em>in phase</em> with the season&#8230;</p></blockquote>
<p>Last month I already showed you how cool Flex 4&#8242;s new layout system is with <a href="http://www.flexstuff.co.uk/2009/11/06/flex-4-animated-timemachine-layout/">my TimeMachine Layout</a>. Pretty much at the same time I knocked together another example, the good ol&#8217; CoverFlow but with my new gig in Paris for Keytree/SAP/Publicis I didn&#8217;t get the chance to publish it until now.</p>
<p>Here it is! As usual, just click on the picture to launch it and right-click to see the source.</p>
<div class="wp-caption aligncenter" style="width: 360px"><a class="lightview" title="Flex 4: CoverFlow Layout :: Right-click to view the source. :: width: 918, height: 624" href="http://flexstuff.co.uk/wp-content/uploads/examples/coverflowlayout/Coverflow_Flex4.swf"><img src="http://flexstuff.co.uk/wp-content/uploads/2009/12/coverflow.png" alt="CoverFlow Layout" width="350" height="250" /></a><p class="wp-caption-text">Flex 4: CoverFlow Layout (click to Launch)</p></div>
<p>Same disclaimer as for the TimeMachine layout: it&#8217;s not optimized, some things can certainly be done a different/better way, but at least it works reasonably well and gives another idea of how easy it is to implement complex layouts with Flex 4.</p>
<p>Enjoy and Merry Christmas/Happy New Year!</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F12%2F23%2Fflex-4-coverflow-layout%2F';
  addthis_title  = 'Flex+4%3A+CoverFlow+Layout';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/12/23/flex-4-coverflow-layout/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>Flex 4: Animated TimeMachine Layout</title>
		<link>http://www.flexstuff.co.uk/2009/11/06/flex-4-animated-timemachine-layout/</link>
		<comments>http://www.flexstuff.co.uk/2009/11/06/flex-4-animated-timemachine-layout/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 13:50:37 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[Flash Builder 4]]></category>
		<category><![CDATA[flex component]]></category>
		<category><![CDATA[gumbo]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[timemachine]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=898</guid>
		<description><![CDATA[An example of timemachine-like layout using the new flex 4 layout paradigm.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F11%252F06%252Fflex-4-animated-timemachine-layout%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Flex%204%3A%20Animated%20TimeMachine%20Layout%22%20%7D);"></div>
<p>The new layout architecture in Flex 4 is pretty cool. It&#8217;s much much simpler to implement complex layouts than what was possible with Flex 3. So the other day I was asked to develop a TimeMachine-like layout. It eventually ended up being done with Flex 3 but before that I had a chance to give a try with the new layout system.</p>
<p>So I picked a bit of <a href="http://evtimmy.com/2009/06/wheellayout-source-and-quick-mashup/" target="_blank">Evtim&#8217;s Wheel layout</a>, added a bit of <a href="http://www.ryancampbell.com/2009/06/16/heres-5-3d-layouts-for-flex-4/" target="_blank">Ryan Campbell&#8217;s 5 3D Layouts</a> (who got himself inspired by Evtim&#8217;s example), blended the whole thing in my own recipe and ended up with something I thought I should share (source is available by right-clicking on the demo after launching it):</p>
<div class="wp-caption aligncenter" style="width: 360px"><a class="lightview" title="Flex 4: Animated TimeMachine Layout :: Right-click to view the source. :: width: 918, height: 624" href="http://flexstuff.co.uk/wp-content/uploads/examples/timemachinelayout/TimeMachine_Flex4.swf"><img src="http://flexstuff.co.uk/wp-content/uploads/2009/11/TimeMachine.gif" alt="TimeMachine Layout" width="350" height="250" /></a><p class="wp-caption-text">Flex 4: Animated TimeMachine Layout (click to Launch)</p></div>
<p>It&#8217;s not optimized, some things can certainly be done a different/better way, but at least it works reasonably well and gives another idea of how easy it is to implement complex layouts with Flex 4.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F11%2F06%2Fflex-4-animated-timemachine-layout%2F';
  addthis_title  = 'Flex+4%3A+Animated+TimeMachine+Layout';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/11/06/flex-4-animated-timemachine-layout/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Refresh Automatically in Flash Catalyst Beta 2: a quick fix</title>
		<link>http://www.flexstuff.co.uk/2009/10/21/refresh-automatically-in-flash-catalyst-beta-2-a-quick-fix/</link>
		<comments>http://www.flexstuff.co.uk/2009/10/21/refresh-automatically-in-flash-catalyst-beta-2-a-quick-fix/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 10:02:44 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[CatalystBuilderSync]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Catalyst]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[FlexStuff]]></category>
		<category><![CDATA[FlexStuff.co.uk]]></category>
		<category><![CDATA[gumbo]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=887</guid>
		<description><![CDATA[A quick fix to activate Adobe Catalyst Beta 2 Refresh Automatically setting without access to Catalyst's preferences
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F10%252F21%252Frefresh-automatically-in-flash-catalyst-beta-2-a-quick-fix%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Refresh%20Automatically%20in%20Flash%20Catalyst%20Beta%202%3A%20a%20quick%20fix%22%20%7D);"></div>
<p>As explained the other day in <a href="http://www.flexstuff.co.uk/2009/10/08/flash-builder-4-beta2-flash-catalyst-beta2-and-catalystbuildersync-good-to-go-but/" target="_blank">this previous post</a>, the new version version of Adobe Flash Catalyst Beta 2 doesn&#8217;t allow access anymore to it&#8217;s preferences so you cannot set it to refresh automatically. It&#8217;s kind of a pain when you use my synchronization tool, <a href="http://www.flexstuff.co.uk/applications/catalystbuildersync/" target="_blank">CatalystBuilderSync</a>, as the synchronizations with Flash Builder do not reflect anymore in Catalyst.<br />
So I&#8217;ve been digging a bit into Catalyst architecture and found an easy fix for that. You just need to edit the following file, depending on your platform (attention,<em> .metadata </em>is usually <em>hidden</em> by default):</p>
<ul>
<li> On Mac:<br />
<strong>/Users/[your username]/Library/Application Support/Adobe/Flash Catalyst/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs</strong></li>
<li>On Windows 7 (and probably on Vista but unverified):<br />
<strong>C:\Users\[your username]\AppData\Roaming\Adobe\Flash Catalyst\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.core.resources.prefs</strong></li>
<li>On Windows XP:<br />
<strong>C:\Documents and Settings\</strong><strong>[your username]</strong><strong>\Application Data\Adobe\Flash Catalyst\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.core.resources.prefs</strong></li>
</ul>
<p>Open one of those and add the following line:</p>
<blockquote><p><strong>refresh.enabled=true</strong></p></blockquote>
<p>Save, restart Catalyst and that would do the trick. I&#8217;ll simplify the whole process in <a href="../applications/catalystbuildersync/" target="_blank">CatalystBuilderSync</a> next update, hopefully in a couple of days.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F10%2F21%2Frefresh-automatically-in-flash-catalyst-beta-2-a-quick-fix%2F';
  addthis_title  = 'Refresh+Automatically+in+Flash+Catalyst+Beta+2%3A+a+quick+fix';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/10/21/refresh-automatically-in-flash-catalyst-beta-2-a-quick-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mate examples: #11 Mediator (or Passive View)</title>
		<link>http://www.flexstuff.co.uk/2009/10/13/mate-examples-11-mediator-or-passive-view/</link>
		<comments>http://www.flexstuff.co.uk/2009/10/13/mate-examples-11-mediator-or-passive-view/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 07:00:26 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mate Framework]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[London Flash Platform User Group]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=559</guid>
		<description><![CDATA[This is the eleventh of a series of gradually more complex examples on how to use Mate. Here we see how to use the Mediator (or Passive View) pattern with Mate.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F10%252F13%252Fmate-examples-11-mediator-or-passive-view%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Mate%20examples%3A%20%2311%20Mediator%20%28or%20Passive%20View%29%22%20%7D);"></div>
<p>This blog post is related to <a href="http://www.flexstuff.co.uk/2009/08/05/my-lfpug-presentation-about-mate/" target="_blank">My LFPUG Presentation about Mate</a> blog post (I know, it was 3 months ago, it&#8217;s a shame but I also must work for a living).</p>
<p>If you haven&#8217;t done it yet you should have a look first at our previous examples: <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-1-a-very-basic-injectors-example/" target="_blank">#1,</a> <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-2-databinding-and-eventhandlers/" target="_blank">#2</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-3-multiple-counters/" target="_blank">#3</a>, <a href="http://www.flexstuff.co.uk/?p=521" target="_blank">#4</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-5-localeventmap/" target="_blank">#5</a>, <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-6-reset-countdown-pt-1/" target="_blank">#6</a>, <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-7-reset-countdown-pt-2/" target="_blank">#7</a>, <a href="http://www.flexstuff.co.uk/2009/08/18/mate-examples-8-modules-example-pt-1/" target="_blank">#8</a>, <a href="http://www.flexstuff.co.uk/2009/08/23/mate-examples-9-modules-example-pt-2/" target="_blank">#9</a> and <a href="http://www.flexstuff.co.uk/2009/08/25/mate-examples-10-presentation-model/" target="_blank">#10</a>.</p>
<p>In our previous example we&#8217;ve studied a simple implementation of the Presentation Pattern. In this configuration, the View has a reference to its presentation model (or at least to its interface). But what if you want it to be the other way around? The view exists for itself and the model is the one who has a reference to the view. This approach definitely is a prime candidate if you want to use views generated in Flash Catalyst then synchronised with Flash Builder with <a href="http://www.flexstuff.co.uk/applications/catalystbuildersync/" target="_blank">CatalystBuilderSync</a>. You can easily modify your views without affecting the logic whatsoever. The view is dumb or passive as explained in <a href="http://blogs.adobe.com/paulw/archives/2007/11/presentation_pa_6.html#more" target="_blank">this other article by Paul Williams</a>. It&#8217;s also one of the patterns used in <a href="http://puremvc.org" target="_blank">PureMVC</a>, called Mediator and we will keep the name here. So, how is it possible with Mate?</p>
<p>Let&#8217;s have a look (source is available by right-clicking on the demo after launching it):</p>
<div class="wp-caption aligncenter" style="width: 360px"><a class="lightview" title="#11 Mediator (a la PureMVC) :: Right-click to view the source. :: width: 1024, height: 768" href="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo11%20-%20Mediator/Demo.swf"><img src="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo11%20-%20Mediator/Mate_example10.png" alt="Mate example" width="350" height="250" /></a><p class="wp-caption-text">#11 Mediator (a la PureMVC) (click to Launch)</p></div>
<p><span id="more-559"></span><br />
As you can see, the 2 views FirstPanel.mxml and SecondPanel.mxml are completely autonomous, without any reference to anything else nor any logic:</p>
<p><cite><br />
<h3>Demo #11: src/views/FirstPanel.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;298&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;164&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;First Panel&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Button One&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;30&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;verticalCenter=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Button Two&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;30&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;verticalCenter=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p><cite><br />
<h3>Demo #11: src/views/SecondPanel.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;246&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;232&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;Deuxieme Panel&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderStyle=<span style="color: #990000;">&quot;inset&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#A5C5ED&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Bouton Un&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;20&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;emphasized=<span style="color: #990000;">&quot;true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cornerRadius=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Bouton Deux&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;20&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cornerRadius=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fillAlphas=<span style="color: #990000;">&quot;[1.0, 1.0]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fillColors=<span style="color: #990000;">&quot;[#FF0000, #FF0000]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>Now the mediators which embed all the logic and the reference to their respective view (which is passed as an argument of the initMediator method):</p>
<p><cite><br />
<h3>Demo #11: src/views/mediators/FirstPanelMediator.as</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> views<span style="color: #000066; font-weight: bold;">.</span>mediators<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">EventDispatcher</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Alert<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>FirstPanel<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> FirstPanelMediator <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">EventDispatcher</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> component <span style="color: #000066; font-weight: bold;">:</span> FirstPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> initMediator<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component = <span style="color: #004993;">target</span> <span style="color: #0033ff; font-weight: bold;">as</span> FirstPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component<span style="color: #000066; font-weight: bold;">.</span>button1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> button1_clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component<span style="color: #000066; font-weight: bold;">.</span>button2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> button2_clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> button1_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Button1 Clicked&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> button2_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Button2 Clicked&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p><cite><br />
<h3>Demo #11: src/views/mediators/SecondPanelMediator.as</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> views<span style="color: #000066; font-weight: bold;">.</span>mediators<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">EventDispatcher</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Alert<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>SecondPanel<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SecondPanelMediator <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">EventDispatcher</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> component <span style="color: #000066; font-weight: bold;">:</span> SecondPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> initMediator<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component = <span style="color: #004993;">target</span> <span style="color: #0033ff; font-weight: bold;">as</span> SecondPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component<span style="color: #000066; font-weight: bold;">.</span>button1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> button1_clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component<span style="color: #000066; font-weight: bold;">.</span>button2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> button2_clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> button1_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Oh, I do not like this.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> button2_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Please, don't do that.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>And finally the eventMap which ties together views and mediators via injection:</p>
<p><cite><br />
<h3>Demo #11: src/maps/MainEventMap.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>mate=<span style="color: #990000;">&quot;http://mate.asfusion.com/&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>SecondPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>mediators<span style="color: #000066; font-weight: bold;">.</span>SecondPanelMediator<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>FlexEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>FirstPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>mediators<span style="color: #000066; font-weight: bold;">.</span>FirstPanelMediator<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Debugger <span style="color: #004993;">level</span>=<span style="color: #990000;">&quot;{Debugger.ALL}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{FirstPanel}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{FirstPanelMediator}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;initMediator&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">arguments</span>=<span style="color: #990000;">&quot;{event.injectorTarget}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{SecondPanel}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{SecondPanelMediator}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;initMediator&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">arguments</span>=<span style="color: #990000;">&quot;{event.injectorTarget}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>Whenever a view is instantiated then its related mediator is instantiated as well, its initMediator method is called and the injector&#8217;s target (the view: FirstPanel or SecondPanel) is passed as an argument. Important: note the use of Mate&#8217;s event.injectorTarget to retrieve the injector&#8217;s target reference. You cannot pass directly {FirstPanel} or {SecondPanel}. It wouldn&#8217;t work.</p>
<p>I&#8217;ll tell you what: this Mediator approach is quite simply my favourite at the moment as it leaves you with the maximum freedom to deal with the new Flex 4 paradigm (component + skin) without interfering with it at any point.</p>
<p>Next time (hopefully sooner than next month): Versioned Applications (think about Modules but more powerful)</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F10%2F13%2Fmate-examples-11-mediator-or-passive-view%2F';
  addthis_title  = 'Mate+examples%3A+%2311+Mediator+%28or+Passive+View%29';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/10/13/mate-examples-11-mediator-or-passive-view/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Flash Builder 4 beta2, Flash Catalyst Beta2 and CatalystBuilderSync? Good to go but&#8230;</title>
		<link>http://www.flexstuff.co.uk/2009/10/08/flash-builder-4-beta2-flash-catalyst-beta2-and-catalystbuildersync-good-to-go-but/</link>
		<comments>http://www.flexstuff.co.uk/2009/10/08/flash-builder-4-beta2-flash-catalyst-beta2-and-catalystbuildersync-good-to-go-but/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 06:51:02 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[CatalystBuilderSync]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Catalyst]]></category>
		<category><![CDATA[FlexStuff]]></category>
		<category><![CDATA[FlexStuff.co.uk]]></category>
		<category><![CDATA[gumbo]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=860</guid>
		<description><![CDATA[CatalystBuilderSync seems to work fairly well with the new Beta 2 versions of Adobe Flash Builder 4 and Adobe Flash Catalyst, although there's now a limitation with Catalyst.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F10%252F08%252Fflash-builder-4-beta2-flash-catalyst-beta2-and-catalystbuildersync-good-to-go-but%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Flash%20Builder%204%20beta2%2C%20Flash%20Catalyst%20Beta2%20and%20CatalystBuilderSync%3F%20Good%20to%20go%20but...%22%20%7D);"></div>
<h3>[Edit: there's a workaround for the preferences issue <a href="http://www.flexstuff.co.uk/2009/10/21/refresh-automatically-in-flash-catalyst-beta-2-a-quick-fix/">here</a>]</h3>
<p>I&#8217;ve been literally sucked up into a black hole of work recently (hence the obvious lack of activity on FlexStuff.co.uk), but not to the point I couldn&#8217;t check out the brand new <a href="http://labs.adobe.com/technologies/flashbuilder4/" target="_blank">Flash Builder 4 Beta 2</a> and its counterpart <a href="http://labs.adobe.com/technologies/flashcatalyst/" target="_blank">Flash Catalyst Beta 2</a> (like all good geeks I like novelties). So I took a couple of hours to see how the two of them behaved with <a href="http://www.flexstuff.co.uk/applications/catalystbuildersync/" target="_blank">CatalystBuilderSync</a> and for what I&#8217;ve seen so far it&#8217;s still all good, with the usual caveats (not all your Flash Builder 4 code will necessarily play well in Catalyst). It looks like my approach remains entirely valid and I suspect it&#8217;ll remain valid even after Catalyst 1.0 release, but I can be wrong and obviously Adobe doesn&#8217;t warmly encourage this approach according to Andrew Shorten&#8217;s (excellent) article: <a href="http://www.adobe.com/devnet/flashcatalyst/articles/flashbuilder_flashcatalyst_workflows_07.html" target="_blank">Exploring Flash Catalyst and Flash Builder workflows</a>:</p>
<blockquote>
<h3><strong>Other workflows</strong></h3>
<p>Whilst not an official list of recommended workflows, the approaches described in this article are all supported within the current versions of the Flash Catalyst and Flash Builder.</p>
<p>There are a number of third-party tools and alternative workflows that you might like to consider as you work with Flash Catalyst and Flash Builder; these can often improve productivity further for advanced developers. <em><strong>Note, however, that some of these tools may use unsupported or non-recommended approaches that may not work with future versions of Flash Catalyst and Flash Builder</strong></em>.</p></blockquote>
<p>So<a href="http://www.flexstuff.co.uk/applications/catalystbuildersync/" target="_blank"> CatalystBuilderSync</a> works well, BUT (of course there has to be a but) unfortunately Adobe limited one thing in Catalyst: there&#8217;s no right-click available anymore in Catalyst&#8217;s code view. Which means you can&#8217;t manually refresh the content of your project folder nor access Catalyst&#8217;s preferences in order to activate the Automatic Refresh (<a href="http://www.flexstuff.co.uk/2009/06/25/get-access-to-flash-catalyst-preferences/" target="_blank">as explained in this previous post</a>). There are a couple workarounds (like switching back and forth between design and code view or saving Catalyst project then choosing &#8220;Revert&#8221; in the file menu) but it&#8217;s a bit of a shame as we&#8217;re not children and I don&#8217;t really see the point of removing this functionality (now I&#8217;m also doomed to use the system&#8217;s default browser which is all but a convenience for me). I guess there must be somewhere in Catalyst some .ini file to edit (after all Catalyst is just another Eclipse distro) but I must say I don&#8217;t have a clue where this might be.<br />
I&#8217;ll keep searching when I have the time but if someone has a suggestion I&#8217;d love to hear it. Now the good thing is <a href="http://www.flexstuff.co.uk/applications/catalystbuildersync/" target="_blank">CatalystBuilderSync</a> is still working and it&#8217;s even more useful now with all the new Catalyst&#8217;s functionalities.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F10%2F08%2Fflash-builder-4-beta2-flash-catalyst-beta2-and-catalystbuildersync-good-to-go-but%2F';
  addthis_title  = 'Flash+Builder+4+beta2%2C+Flash+Catalyst+Beta2+and+CatalystBuilderSync%3F+Good+to+go+but%26%238230%3B';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/10/08/flash-builder-4-beta2-flash-catalyst-beta2-and-catalystbuildersync-good-to-go-but/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CatalystBuilderSync 0.6.2: First public alpha</title>
		<link>http://www.flexstuff.co.uk/2009/08/27/catalystbuildersync-0-6-2-first-public-alpha/</link>
		<comments>http://www.flexstuff.co.uk/2009/08/27/catalystbuildersync-0-6-2-first-public-alpha/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 10:06:11 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[CatalystBuilderSync]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Catalyst]]></category>
		<category><![CDATA[FlexStuff]]></category>
		<category><![CDATA[FlexStuff.co.uk]]></category>
		<category><![CDATA[gumbo]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=839</guid>
		<description><![CDATA[Introducing CatalystBuilderSync, a new tool to simplify exchanges between Adobe Flash Catalyst and Adobe Flash Builder.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F08%252F27%252Fcatalystbuildersync-0-6-2-first-public-alpha%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22CatalystBuilderSync%200.6.2%3A%20First%20public%20alpha%22%20%7D);"></div>
<p>Like some others I&#8217;ve been working a lot recently in trying to improve the <em><strong>Adobe Flash Catalyst</strong></em> / <em><strong>Flash Builder</strong></em> <em>workflow</em>. I came up with <a href="http://www.flexstuff.co.uk/2009/06/23/yet-another-flash-catalyst-builder-workflow-method/" target="_blank">a partial solution</a> not so long ago, but it wasn&#8217;t exactly seamless and it most definitely needed a tool to act as a middle-man, to simplify synchronization between both softwares.</p>
<p>This is that tool: <a href="http://www.flexstuff.co.uk/apps/catalystbuildersync/">CatalystBuilderSync</a></p>
<p>And more than a long story, the second of a series of screencasts I&#8217;ve recorded yesterday should give you a good taste of what <em><strong>CatalystBuilderSync</strong></em> is capable of&#8230;</p>
<div id="attachment_69" class="wp-caption aligncenter" style="width: 455px"><object width="445" height="364"><param name="movie" value="http://www.youtube-nocookie.com/v/CFKnqLnK7B8&#038;hl=en&#038;fs=1&#038;hd=1&#038;border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/CFKnqLnK7B8&#038;hl=en&#038;fs=1&#038;hd=1&#038;border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="445" height="364"></embed></object><p class="wp-caption-text">Part 2 - First synchronizations</p></div>
<blockquote><p>Remember, it&#8217;s a <span style="text-decoration: underline;"><em>very early alpha version</em></span>, so <em>bugs</em>, <em>hiccups</em> and <em>other funny things</em> are to be expected (and to be reported so I can fix them at some point).</p></blockquote>
<p>You can download <em>the latest version</em> and give some <em>feedback</em> (I really need them) here:</p>
<p><a href="http://www.flexstuff.co.uk/apps/catalystbuildersync/">CatalystBuilderSync 0.6.2</a></p>
<p>And please spread the word, I feel like this tool should be of interest to many of you.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F08%2F27%2Fcatalystbuildersync-0-6-2-first-public-alpha%2F';
  addthis_title  = 'CatalystBuilderSync+0.6.2%3A+First+public+alpha';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/08/27/catalystbuildersync-0-6-2-first-public-alpha/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mate examples: #10 Presentation Model</title>
		<link>http://www.flexstuff.co.uk/2009/08/25/mate-examples-10-presentation-model/</link>
		<comments>http://www.flexstuff.co.uk/2009/08/25/mate-examples-10-presentation-model/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 07:37:04 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mate Framework]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[London Flash Platform User Group]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=556</guid>
		<description><![CDATA[This is the tenth of a series of gradually more complex examples on how to use Mate. Here we see how to use the Presentation Model pattern with Mate.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F08%252F25%252Fmate-examples-10-presentation-model%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Mate%20examples%3A%20%2310%20Presentation%20Model%22%20%7D);"></div>
<p>This blog post is related to <a href="http://www.flexstuff.co.uk/2009/08/05/my-lfpug-presentation-about-mate/" target="_blank">My LFPUG Presentation about Mate</a> blog post.</p>
<p>If you haven&#8217;t done it yet you should have a look first at our previous examples: <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-1-a-very-basic-injectors-example/" target="_blank">#1,</a> <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-2-databinding-and-eventhandlers/" target="_blank">#2</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-3-multiple-counters/" target="_blank">#3</a>, <a href="http://www.flexstuff.co.uk/?p=521" target="_blank">#4</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-5-localeventmap/" target="_blank">#5</a>, <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-6-reset-countdown-pt-1/" target="_blank">#6</a>, <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-7-reset-countdown-pt-2/" target="_blank">#7</a>, <a href="http://www.flexstuff.co.uk/2009/08/18/mate-examples-8-modules-example-pt-1/" target="_blank">#8</a>, and <a href="http://www.flexstuff.co.uk/2009/08/23/mate-examples-9-modules-example-pt-2/" target="_blank">#9</a>.</p>
<p>Today we&#8217;re going to put aside our (I know: boooring) <em>counters</em>. We will come back to them in a couple of posts for <em>the great finale: Mate and versioned applications</em>.<br />
But for now I wanted to illustrate a really good practice with <em>Mate</em> (and in general): the <em>Presentation Model pattern</em>. For those who want to know more about the <em>Presentation Model</em>, have a look at <a href="http://blogs.adobe.com/paulw/archives/2007/10/presentation_pa_3.html">Paul Williams great article</a>. Basically, the idea is to keep the view <em>as simple as possible</em>, separating all the <em>logic</em> in a <em>dedicated class</em>. That way, <em>Mate</em> communicates with the <em>presentation model class</em> and not directly with the <em>view</em>, the latter being updated via <em>data binding</em>. In this configuration, the <em>view&#8217;s</em> only concern is its own elements and its only dependency is its <em>model</em>.</p>
<p>Let&#8217;s have a look at our very simple demo (source is available by right-clicking on the demo after launching it):</p>
<div class="wp-caption aligncenter" style="width: 360px"><a class="lightview" title="#10 Presentation Model :: Right-click to view the source. :: width: 1200, height: 768" href="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo10%20-%20Presentation%20Model/Demo.swf"><img src="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo10%20-%20Presentation%20Model/Mate_example10.png" alt="Mate example" width="350" height="250" /></a><p class="wp-caption-text">#10 Presentation Model (click to Launch)</p></div>
<p><span id="more-556"></span>So what do we have here (apart from the opportunity to learn a bit of French)? Two visually different <em>panels</em>, each with two <em>buttons</em>, each <em>button</em> triggering an <em>alert</em> with a different <em>message</em>. The structure is dead simple: the two different panels are instantiated in the now usual <strong>MainView</strong>:</p>
<p><cite><br />
<h3>Demo #10: src/views/MainView.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Canvas xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;656&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;314&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>views=<span style="color: #990000;">&quot;views.*&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>views<span style="color: #000066; font-weight: bold;">:</span>FirstPanel verticalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;25&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;298&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>views<span style="color: #000066; font-weight: bold;">:</span>SecondPanel verticalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;25&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Canvas<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p><strong>FirstPanel</strong> and <strong>SecondPanel</strong> are pretty similar, the main differences being various &#8220;cosmetic&#8221; <em>properties</em>:</p>
<p><cite><br />
<h3>Demo #10: src/views/FirstPanel.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;298&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;164&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;First Panel&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<span style="color: #000066; font-weight: bold;">.</span>IPresentationModel<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> pm <span style="color: #000066; font-weight: bold;">:</span> IPresentationModel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Button One&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;30&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;verticalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;pm.button1_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Button Two&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;30&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;verticalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;pm.button2_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p><cite><br />
<h3>Demo #10: src/views/SecondPanel.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;246&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;232&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;Deuxieme Panel&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderStyle=<span style="color: #990000;">&quot;inset&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#A5C5ED&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<span style="color: #000066; font-weight: bold;">.</span>IPresentationModel<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> pm <span style="color: #000066; font-weight: bold;">:</span> IPresentationModel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Bouton Un&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;20&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;emphasized=<span style="color: #990000;">&quot;true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cornerRadius=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;pm.button1_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;button2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Bouton Deux&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;20&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cornerRadius=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fillAlphas=<span style="color: #990000;">&quot;[1.0, 1.0]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fillColors=<span style="color: #990000;">&quot;[#FF0000, #FF0000]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;pm.button2_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>One important thing to notice though: they both share a same <strong>pm</strong> variable referring to an <em>Interface</em>, <strong>IPresentationModel</strong>. Also, the 2 <em>buttons</em> call 2 <em>methods</em> within this <em>interface</em>: <strong>button1_clickHandler</strong> and <strong>button2_clickHandler</strong>.</p>
<p><cite><br />
<h3>Demo #10: src/views/presentationmodel/IPresentationModel.as</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> interface IPresentationModel<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339966; font-weight: bold;">function</span> button1_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339966; font-weight: bold;">function</span> button2_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now, there are two <em>classes</em> in the <strong>views/presentationmodel</strong> package: <strong>PresentationModel1</strong> and <strong>PresentationModel2</strong>. Once again, those two are pretty similar, the only differences being the different messages thrown by the <strong>Alerts</strong>:</p>
<p><cite><br />
<h3>Demo #10: src/views/presentationmodel/PresentationModel1.as</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">EventDispatcher</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Alert<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PresentationModel1 <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">EventDispatcher</span> implements IPresentationModel<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> button1_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Button1 Clicked&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> button2_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Button2 Clicked&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p><cite><br />
<h3>Demo #10: src/views/presentationmodel/PresentationModel2.as</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">EventDispatcher</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Alert<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PresentationModel2 <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">EventDispatcher</span> implements IPresentationModel<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> button1_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Oh! I do not like this.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> button2_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Please don't do that.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>And now, the glue, as usual:</p>
<p><cite><br />
<h3>Demo #10: src/maps/MainEventMap.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>mate=<span style="color: #990000;">&quot;http://mate.asfusion.com/&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>SecondPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<span style="color: #000066; font-weight: bold;">.</span>PresentationModel2<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<span style="color: #000066; font-weight: bold;">.</span>PresentationModel1<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>FirstPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Debugger <span style="color: #004993;">level</span>=<span style="color: #990000;">&quot;{Debugger.ALL}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{FirstPanel}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ObjectBuilder generator=<span style="color: #990000;">&quot;{PresentationModel1}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{lastReturn}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;pm&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{SecondPanel}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ObjectBuilder generator=<span style="color: #990000;">&quot;{PresentationModel2}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{lastReturn}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;pm&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>The <strong>MainEventMap</strong> maps each <em>PresentationModel</em> to its related <em>view</em> and the job is done! The beauty of it is that you can swap <em>presentation models</em> and <em>views</em> as easily as this:</p>
<p><cite><br />
<h3>Demo #10: src/maps/MainEventMap.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>mate=<span style="color: #990000;">&quot;http://mate.asfusion.com/&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>SecondPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<span style="color: #000066; font-weight: bold;">.</span>PresentationModel2<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>presentationmodel<span style="color: #000066; font-weight: bold;">.</span>PresentationModel1<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>FirstPanel<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Debugger <span style="color: #004993;">level</span>=<span style="color: #990000;">&quot;{Debugger.ALL}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{FirstPanel}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ObjectBuilder generator=<span style="color: #990000;">&quot;{PresentationModel2}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{lastReturn}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;pm&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{SecondPanel}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ObjectBuilder generator=<span style="color: #990000;">&quot;{PresentationModel1}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{lastReturn}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;pm&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>Neat, isn&#8217;t it? You can as easily imagine using <em>data binding</em> to dynamically change <em>view&#8217;s properties</em> (<em>visible, enabled, label</em>, whatnot) with some <em>bindable</em> variables in the presentation model.</p>
<p>Here we go. Next, my new favourite one: a port of <em>PureMVC&#8217;s mediator pattern</em> which is one of the best ways to use <em>Mate</em> with the new <em>Flex 4 component architecture</em>.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F08%2F25%2Fmate-examples-10-presentation-model%2F';
  addthis_title  = 'Mate+examples%3A+%2310+Presentation+Model';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/08/25/mate-examples-10-presentation-model/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mate examples: #9 Modules Example (pt 2)</title>
		<link>http://www.flexstuff.co.uk/2009/08/23/mate-examples-9-modules-example-pt-2/</link>
		<comments>http://www.flexstuff.co.uk/2009/08/23/mate-examples-9-modules-example-pt-2/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 18:05:46 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mate Framework]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[London Flash Platform User Group]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=554</guid>
		<description><![CDATA[This is the ninth of a series of gradually more complex examples on how to use Mate. Here we see how to use Mate with Flex Modules.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F08%252F23%252Fmate-examples-9-modules-example-pt-2%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Mate%20examples%3A%20%239%20Modules%20Example%20%28pt%202%29%22%20%7D);"></div>
<p>This blog post is related to <a href="http://www.flexstuff.co.uk/2009/08/05/my-lfpug-presentation-about-mate/" target="_blank">My LFPUG Presentation about Mate</a> blog post.</p>
<p>This is the ninth of a series of gradually more complex examples on how to use <em>Mate</em>. If you haven&#8217;t done it yet you should have a look first at our previous examples: <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-1-a-very-basic-injectors-example/" target="_blank">#1,</a> <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-2-databinding-and-eventhandlers/" target="_blank">#2</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-3-multiple-counters/" target="_blank">#3</a>, <a href="http://www.flexstuff.co.uk/?p=521" target="_blank">#4</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-5-localeventmap/" target="_blank">#5</a>, <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-6-reset-countdown-pt-1/" target="_blank">#6</a>, <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-7-reset-countdown-pt-2/" target="_blank">#7</a>, and <a href="http://www.flexstuff.co.uk/2009/08/18/mate-examples-8-modules-example-pt-1/" target="_blank">#8</a>.</p>
<p>By now, you should reasonably be up to speed so I&#8217;m going to speed up as well and throw examples more regularly but with less explanations (it takes some time that I don&#8217;t exactly have those days). If you really don&#8217;t get it though don&#8217;t hesitate to ask for further explanations in the comments.</p>
<p>In <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-8-modules-example-pt-1/#more-552">the previous example</a>, we started to see how to use Mate with Modules but the main application was still keeping references to the module&#8217;s classes. </p>
<p>This example push decoupling a bit further (source is available by right-clicking on the demo after launching it):</p>
<div class="wp-caption aligncenter" style="width: 360px"><a class="lightview" title="#9 Modules Example (pt 2) :: Right-click to view the source. :: width: 1024, height: 768" href="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo09%20-%20Modules%20example%20(2)/Demo.swf"><img src="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo09%20-%20Modules%20example%20(2)/Mate_example7.png" alt="Mate example" width="350" height="250" /></a><p class="wp-caption-text">#9 Modules Example (pt 2) (click to Launch)</p></div>
<p><span id="more-554"></span>As you can see, MainEventMap doesn&#8217;t hold anymore any reference to the module&#8217;s classes:</p>
<p><cite><br />
<h3>Demo #9: src/maps/MainEventMap.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>mate=<span style="color: #990000;">&quot;http://mate.asfusion.com/&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CountdownEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> managers<span style="color: #000066; font-weight: bold;">.</span>CountdownManager<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>FlexEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>MainView<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> managers<span style="color: #000066; font-weight: bold;">.</span>CounterManager<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Debugger <span style="color: #004993;">level</span>=<span style="color: #990000;">&quot;{Debugger.ALL}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{FlexEvent.APPLICATION_COMPLETE}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ObjectBuilder generator=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CounterEvent.INCREASE_GLOBAL}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;increaseGlobal&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CounterEvent.DECREASE_GLOBAL}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;decreaseGlobal&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CounterEvent.RESET}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;reset&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CountdownEvent.START_COUNTDOWN}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;startCountdown&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CountdownEvent.STOP_COUNTDOWN}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;stopCountdown&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{MainView}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sourceKey=<span style="color: #990000;">&quot;globalAmount&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;globalAmount&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{MainView}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; debug=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sourceKey=<span style="color: #990000;">&quot;isCountdownRunning&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;isCountdownRunning&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ListenerInjector eventType=<span style="color: #990000;">&quot;{CountdownEvent.COUNTDOWN}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;updateTitle&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>Instead, the module Counter.mxml now instanciates 2 different EventMaps: ModuleEventMap and SubEventMap (we saw in <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-5-localeventmap/">Example #5 LocalEventMap</a> how to use LocalEventMap):</p>
<p><cite><br />
<h3>Demo #9: src/modules/Counter.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Module xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;264&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;380&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>modules=<span style="color: #990000;">&quot;modules.*&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>views=<span style="color: #990000;">&quot;modules.views.*&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>maps=<span style="color: #990000;">&quot;modules.maps.*&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> globalAmount <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> subTotal <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> amount <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _counterTitle <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;Counter Title&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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> counterTitle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _counterTitle<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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;">set</span> counterTitle<span style="color: #000000;">&#40;</span> v <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _counterTitle = v<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> increaseSubTotal<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CounterEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">++</span>subTotal<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> decreaseSubTotal<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CounterEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">--</span>subTotal<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CounterEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; subTotal = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>maps<span style="color: #000066; font-weight: bold;">:</span>ModuleEventMap <span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>maps<span style="color: #000066; font-weight: bold;">:</span>SubEventMap dispatcher=<span style="color: #990000;">&quot;{this}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;264&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;380&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;{counterTitle}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;27&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Global Amount:&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;121&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{globalAmount}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>views<span style="color: #000066; font-weight: bold;">:</span>SubCounter <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;64&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderStyle=<span style="color: #990000;">&quot;inset&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>views<span style="color: #000066; font-weight: bold;">:</span>SubCounter<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>views<span style="color: #000066; font-weight: bold;">:</span>SubCounter <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;208&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderStyle=<span style="color: #990000;">&quot;inset&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>views<span style="color: #000066; font-weight: bold;">:</span>SubCounter<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;63&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;35&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Subtotal:&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;124&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;35&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{subTotal}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Module<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>And here is ModuleEventMap which deals with global events thrown by the main application:</p>
<p><cite><br />
<h3>Demo #9: src/modules/maps/ModuleEventMap.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>mate=<span style="color: #990000;">&quot;http://mate.asfusion.com/&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> modules<span style="color: #000066; font-weight: bold;">.</span>views<span style="color: #000066; font-weight: bold;">.</span>SubCounter<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> managers<span style="color: #000066; font-weight: bold;">.</span>CounterManager<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> modules<span style="color: #000066; font-weight: bold;">.</span>Counter<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Debugger <span style="color: #004993;">level</span>=<span style="color: #990000;">&quot;{Debugger.ALL}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{Counter}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sourceKey=<span style="color: #990000;">&quot;globalAmount&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;globalAmount&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors targets=<span style="color: #990000;">&quot;{[Counter, SubCounter]}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ListenerInjector eventType=<span style="color: #990000;">&quot;{CounterEvent.RESET}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;reset&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>And SubEventMap which deals with local ones:</p>
<p><cite><br />
<h3>Demo #9: src/modules/maps/SubEventMap.mxml </h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>LocalEventMap xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #000066; font-weight: bold;">:</span>mate=<span style="color: #990000;">&quot;http://mate.asfusion.com/&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> modules<span style="color: #000066; font-weight: bold;">.</span>Counter<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> modules<span style="color: #000066; font-weight: bold;">.</span>views<span style="color: #000066; font-weight: bold;">.</span>SubCounter<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Debugger <span style="color: #004993;">level</span>=<span style="color: #990000;">&quot;{Debugger.ALL}&quot;</span> <span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors targets=<span style="color: #990000;">&quot;{[Counter, SubCounter]}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ListenerInjector eventType=<span style="color: #990000;">&quot;{CounterEvent.INCREASE_SUB_TOTAL}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;increaseSubTotal&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ListenerInjector eventType=<span style="color: #990000;">&quot;{CounterEvent.DECREASE_SUB_TOTAL}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;decreaseSubTotal&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>LocalEventMap<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>In the example #12 we will see how to use Mate with versioned applications but first we will have a look at two different approaches of the Presentation model design pattern.</p>
<p>Next: <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-10-presentation-model/">#10 Presentation Model</a>.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F08%2F23%2Fmate-examples-9-modules-example-pt-2%2F';
  addthis_title  = 'Mate+examples%3A+%239+Modules+Example+%28pt+2%29';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/08/23/mate-examples-9-modules-example-pt-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mate examples: #8 Modules Example (pt 1)</title>
		<link>http://www.flexstuff.co.uk/2009/08/18/mate-examples-8-modules-example-pt-1/</link>
		<comments>http://www.flexstuff.co.uk/2009/08/18/mate-examples-8-modules-example-pt-1/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 18:04:13 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mate Framework]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[London Flash Platform User Group]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=552</guid>
		<description><![CDATA[This is the eigth of a series of gradually more complex examples on how to use Mate. Here we see how to use Mate with Flex Modules.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F08%252F18%252Fmate-examples-8-modules-example-pt-1%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Mate%20examples%3A%20%238%20Modules%20Example%20%28pt%201%29%22%20%7D);"></div>
<p>This blog post is related to <a href="http://www.flexstuff.co.uk/2009/08/05/my-lfpug-presentation-about-mate/" target="_blank">My LFPUG Presentation about Mate</a> blog post.</p>
<p>This is the eigth of a series of gradually more complex examples on how to use <em>Mate</em>. If you haven&#8217;t done it yet you should have a look first at our previous examples: <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-1-a-very-basic-injectors-example/" target="_blank">#1,</a> <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-2-databinding-and-eventhandlers/" target="_blank">#2</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-3-multiple-counters/" target="_blank">#3</a>, <a href="http://www.flexstuff.co.uk/?p=521" target="_blank">#4</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-5-localeventmap/" target="_blank">#5</a>, <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-6-reset-countdown-pt-1/" target="_blank">#6</a>, and <a href="http://www.flexstuff.co.uk/2009/08/09/mate-examples-7-reset-countdown-pt-2/" target="_blank">#7</a>.</p>
<p>In our two previous examples, we saw how easy it was to handle communication between the <em>application</em> and its <em>subcomponents</em>, without mix-up between <em>events</em> intended to be listened by the whole <em>application</em> and <em>events</em> required only at the <em>subcomponent</em> level. But how would <em>Mate</em> hold up with with even looser <em>subcomponents</em>, of the kind that are loaded <em>on demand</em> and are not a concrete part of our main <em>application</em>, namely <em>Modules</em>?</p>
<p>I&#8217;m sure you know already it holds up pretty well, but let&#8217;s see how it does that:</p>
<div class="wp-caption aligncenter" style="width: 360px"><a class="lightview" title="#8 Modules Example (pt 1) :: Right-click to view the source. :: width: 1024, height: 768" href="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo08%20-%20Modules%20example%20(1)/Demo.swf"><img src="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo08%20-%20Modules%20example%20(1)/Mate_example7.png" alt="Mate example" width="350" height="250" /></a><p class="wp-caption-text">#8 Modules Example (pt 1) (click to Launch)</p></div>
<p><span id="more-552"></span>The great thing here is that we didn&#8217;t change much between this example and our previous <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-7-reset-countdown-pt-2/">Reset Countdown</a>. Basically, aside moving <strong>Counter.mxml</strong> and <strong>SubCounter.mxml</strong> into a new <strong>modules</strong> <em>package</em> and changing <strong>Counter.mxml</strong> from a <em>Panel</em> into a <em>Module</em>, that&#8217;s about it:</p>
<p><cite><br />
<h3>Demo #8: src/modules/Counter.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Module xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;264&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;380&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>maps=<span style="color: #990000;">&quot;maps.*&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>modules=<span style="color: #990000;">&quot;modules.*&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> globalAmount <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> subTotal <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> amount <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _counterTitle <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;Counter Title&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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> counterTitle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _counterTitle<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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;">set</span> counterTitle<span style="color: #000000;">&#40;</span> v <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _counterTitle = v<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> increaseSubTotal<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CounterEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">++</span>subTotal<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> decreaseSubTotal<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CounterEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">--</span>subTotal<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CounterEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; subTotal = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>maps<span style="color: #000066; font-weight: bold;">:</span>SubEventMap dispatcher=<span style="color: #990000;">&quot;{this}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;264&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;380&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;{counterTitle}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;27&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Global Amount:&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;121&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{globalAmount}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>modules<span style="color: #000066; font-weight: bold;">:</span>SubCounter <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;64&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderStyle=<span style="color: #990000;">&quot;inset&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>modules<span style="color: #000066; font-weight: bold;">:</span>SubCounter<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>modules<span style="color: #000066; font-weight: bold;">:</span>SubCounter <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;208&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderStyle=<span style="color: #990000;">&quot;inset&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>modules<span style="color: #000066; font-weight: bold;">:</span>SubCounter<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;63&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;35&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Subtotal:&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;124&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;35&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{subTotal}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Module<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>Don&#8217;t forget to declare <strong>Counter.mxml</strong> as a <em>Flex Module</em> in your project&#8217;s properties and of course update all your references to <strong>Counter</strong> and <strong>SubCounter</strong> from <strong>views</strong> to <strong>modules</strong> (i.e. <strong>import view.Counter</strong> => <strong>import modules.Counter</strong>).<br />
And then, all you need to do is to change your <strong>addCounterButton_clickHandler</strong> method in <strong>MainView.mxml</strong> from a simple <em>Class</em> instantiation into a <em>ModuleLoader</em> loader: </p>
<p><cite><br />
<h3>Demo #8: src/views/MainView.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;860&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;600&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;{mainTitle}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #000066; font-weight: bold;">:</span>views=<span style="color: #990000;">&quot;views.*&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>modules<span style="color: #000066; font-weight: bold;">.</span>ModuleLoader<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CountdownEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> globalAmount <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> isCountdownRunning <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> numCounters <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> mainTitle <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;MainView&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> buttonIncrease_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CounterEvent<span style="color: #000000;">&#40;</span> CounterEvent<span style="color: #000066; font-weight: bold;">.</span>INCREASE_GLOBAL <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> buttonDecrease_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CounterEvent<span style="color: #000000;">&#40;</span> CounterEvent<span style="color: #000066; font-weight: bold;">.</span>DECREASE_GLOBAL <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> addCounterButton_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> moduleLoader <span style="color: #000066; font-weight: bold;">:</span> ModuleLoader = <span style="color: #0033ff; font-weight: bold;">new</span> ModuleLoader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moduleLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span> = <span style="color: #990000;">&quot;modules/Counter.swf&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTile<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> moduleLoader <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">++</span>numCounters<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> deleteCounterButton_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> displayObject <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">DisplayObject</span> = mainTile<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getChildAt</span><span style="color: #000000;">&#40;</span>mainTile<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">numChildren</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ModuleLoader<span style="color: #000000;">&#40;</span> displayObject <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>unloadModule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTile<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span> displayObject <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">--</span>numCounters<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> updateTitle<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CountdownEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTitle = <span style="color: #990000;">&quot;MainView (&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> event<span style="color: #000066; font-weight: bold;">.</span>countdown <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;)&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> countdownButton_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> isCountdownRunning <span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countdownButton<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;START COUNTDOWN&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CountdownEvent<span style="color: #000000;">&#40;</span> CountdownEvent<span style="color: #000066; font-weight: bold;">.</span>STOP_COUNTDOWN <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countdownButton<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;STOP COUNTDOWN&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CountdownEvent<span style="color: #000000;">&#40;</span> CountdownEvent<span style="color: #000066; font-weight: bold;">.</span>START_COUNTDOWN <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Global Amount:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;28&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;16&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{globalAmount}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;124&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;16&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Tile id=<span style="color: #990000;">&quot;mainTile&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;82&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;10&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Tile<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;buttonIncrease&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;68&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;34&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;+&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;buttonIncrease_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;buttonDecrease&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;140&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;34&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;-&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;buttonDecrease_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;addCounterButton&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;614&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;31&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Add Counter&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;addCounterButton_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;countdownButton&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;366&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;31&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;STOP COUNTDOWN&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;countdownButton_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;deleteCounterButton&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;716&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;31&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Delete Counter&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">enabled</span>=<span style="color: #990000;">&quot;{numCounters &gt; 0}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;deleteCounterButton_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>And yet our application keeps behaving as it always did. Isn&#8217;t that great? It is, it is, but the example is still not perfect: the <em>views</em> are now separated from the <em>main application</em>, but the <em>logic</em> is still part of it and there are <em>references</em> to the <em>modules&#8217; classes</em> all around in the main application. We can clearly <em>decouple</em> a bit further and we&#8217;ll see how in our next part: <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-9-modules-example-pt-2/">#9 Modules Example (pt 2)</a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F08%2F18%2Fmate-examples-8-modules-example-pt-1%2F';
  addthis_title  = 'Mate+examples%3A+%238+Modules+Example+%28pt+1%29';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/08/18/mate-examples-8-modules-example-pt-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mate examples: #7 Reset Countdown (pt 2)</title>
		<link>http://www.flexstuff.co.uk/2009/08/09/mate-examples-7-reset-countdown-pt-2/</link>
		<comments>http://www.flexstuff.co.uk/2009/08/09/mate-examples-7-reset-countdown-pt-2/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 18:02:37 +0000</pubDate>
		<dc:creator>gillesguillemin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mate Framework]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[London Flash Platform User Group]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://www.flexstuff.co.uk/?p=550</guid>
		<description><![CDATA[This is the seventh of a series of gradually more complex examples on how to use Mate. Here we illustrate interaction between non visual components and the rest of the application.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.flexstuff.co.uk%252F2009%252F08%252F09%252Fmate-examples-7-reset-countdown-pt-2%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Mate%20examples%3A%20%237%20Reset%20Countdown%20%28pt%202%29%22%20%7D);"></div>
<p>This blog post is related to <a href="http://www.flexstuff.co.uk/2009/08/05/my-lfpug-presentation-about-mate/" target="_blank">My LFPUG Presentation about Mate</a> blog post.</p>
<p>This is the seventh of a series of gradually more complex examples on how to use <em>Mate</em>. If you haven&#8217;t done it yet you should have a look first at our previous examples: <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-1-a-very-basic-injectors-example/" target="_blank">#1,</a> <a href="http://www.flexstuff.co.uk/2009/08/05/mate-examples-2-databinding-and-eventhandlers/" target="_blank">#2</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-3-multiple-counters/" target="_blank">#3</a>, <a href="http://www.flexstuff.co.uk/?p=521" target="_blank">#4</a>, <a href="http://www.flexstuff.co.uk/2009/08/06/mate-examples-5-localeventmap/" target="_blank">#5</a>, and <a href="http://flexstuff.co.uk/548">#6</a>.</p>
<p>In the previous example, we added a <em>reset countdown</em> which sets all the <em>counters</em> to 0 when the <em>countdown</em> is off. But it&#8217;s a bit of a pain this <em>unstoppable countdown</em>. It would be cool to add a <em>start/stop button</em>, wouldn&#8217;t it?</p>
<p>OK, let&#8217;s do it (source is available by right-clicking on the demo after launching it):</p>
<div class="wp-caption aligncenter" style="width: 360px"><a class="lightview" title="#7 Reset Countdown (pt 2) :: Right-click to view the source. :: width: 1024, height: 768" href="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo07%20-%20Reset%20countdown%20(2)/Demo.swf"><img src="http://flexstuff.co.uk/wp-content/uploads/examples/mate_lfpug/_Demo07%20-%20Reset%20countdown%20(2)/Mate_example7.png" alt="Mate example" width="350" height="250" /></a><p class="wp-caption-text">#7 Reset Countdown (pt 2) (click to Launch)</p></div>
<p><span id="more-550"></span>So we&#8217;ve first added this <em>start/stop button</em> (yeah, let&#8217;s have a <em>toggle button</em> this time):</p>
<p><cite><br />
<h3>Demo #7: src/views/MainView.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;860&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;600&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title=<span style="color: #990000;">&quot;{mainTitle}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #990000;">&quot;absolute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #000066; font-weight: bold;">:</span>views=<span style="color: #990000;">&quot;views.*&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CountdownEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> globalAmount <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> isCountdownRunning <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> numCounters <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> mainTitle <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;MainView&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> buttonIncrease_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CounterEvent<span style="color: #000000;">&#40;</span> CounterEvent<span style="color: #000066; font-weight: bold;">.</span>INCREASE_GLOBAL <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> buttonDecrease_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CounterEvent<span style="color: #000000;">&#40;</span> CounterEvent<span style="color: #000066; font-weight: bold;">.</span>DECREASE_GLOBAL <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> addCounterButton_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> counter <span style="color: #000066; font-weight: bold;">:</span> Counter = <span style="color: #0033ff; font-weight: bold;">new</span> Counter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter<span style="color: #000066; font-weight: bold;">.</span>counterTitle = <span style="color: #990000;">&quot;Counter &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000066; font-weight: bold;">++</span>numCounters<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTile<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> counter <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> deleteCounterButton_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTile<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeChildAt</span><span style="color: #000000;">&#40;</span> mainTile<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">numChildren</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">--</span>numCounters<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> updateTitle<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> CountdownEvent <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainTitle = <span style="color: #990000;">&quot;MainView (&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> event<span style="color: #000066; font-weight: bold;">.</span>countdown <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;)&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> countdownButton_clickHandler<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> isCountdownRunning <span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countdownButton<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;START COUNTDOWN&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CountdownEvent<span style="color: #000000;">&#40;</span> CountdownEvent<span style="color: #000066; font-weight: bold;">.</span>STOP_COUNTDOWN <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countdownButton<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;STOP COUNTDOWN&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CountdownEvent<span style="color: #000000;">&#40;</span> CountdownEvent<span style="color: #000066; font-weight: bold;">.</span>START_COUNTDOWN <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Global Amount:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;28&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;16&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{globalAmount}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;124&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;16&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Tile id=<span style="color: #990000;">&quot;mainTile&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;82&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;10&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Tile<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;buttonIncrease&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;68&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;34&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;+&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;buttonIncrease_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;buttonDecrease&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;140&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;34&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;-&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;buttonDecrease_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;addCounterButton&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;614&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;31&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Add Counter&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;addCounterButton_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;countdownButton&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;366&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;31&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;STOP COUNTDOWN&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;countdownButton_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;deleteCounterButton&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;716&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;31&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label=<span style="color: #990000;">&quot;Delete Counter&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">enabled</span>=<span style="color: #990000;">&quot;{numCounters &gt; 0}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;deleteCounterButton_clickHandler(event)&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Panel<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>Depending on <strong>isCountdownRunning</strong> (note that it is <em>bindable</em>&#8230;), the <em>button&#8217;s label</em> will change, and a <em>click</em> on the <em>button</em> will <em>dispatch</em> the new <strong>CountdownEvent.START_COUNTDOWN</strong> or <strong>CountdownEvent.STOP_COUNTDOWN</strong>.</p>
<p><cite><br />
<h3>Demo #7: src/Events/CountdownEvent.as</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> Events<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CountdownEvent <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Event</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static const COUNTDOWN <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;countDown&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static const START_COUNTDOWN <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;startCountDown&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static const STOP_COUNTDOWN <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;stopCountDown&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> countdown <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CountdownEvent<span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">bubbles</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">cancelable</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">bubbles</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">cancelable</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>We can see those two new <em>types</em> here. What about <strong>CountdownManager</strong>?</p>
<p><cite><br />
<h3>Demo #7: src/managers/CountdownManager.as</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> managers<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CountdownEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>asfusion<span style="color: #000066; font-weight: bold;">.</span>mate<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>Dispatcher<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">EventDispatcher</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">IEventDispatcher</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TimerEvent</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Timer</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CountdownManager <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">EventDispatcher</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Timer</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> duration <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> countdown <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dispatcher <span style="color: #000066; font-weight: bold;">:</span> Dispatcher = <span style="color: #0033ff; font-weight: bold;">new</span> Dispatcher<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> isCountdownRunning <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CountdownManager<span style="color: #000000;">&#40;</span> <span style="color: #004993;">target</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">IEventDispatcher</span> = <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">target</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countdown = duration<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Timer</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">TimerEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TIMER_COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onTimerComplete <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onTimerComplete<span style="color: #000000;">&#40;</span> event <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">TimerEvent</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">--</span>countdown<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> counterEvent <span style="color: #000066; font-weight: bold;">:</span> CountdownEvent = <span style="color: #0033ff; font-weight: bold;">new</span> CountdownEvent<span style="color: #000000;">&#40;</span> CountdownEvent<span style="color: #000066; font-weight: bold;">.</span>COUNTDOWN <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counterEvent<span style="color: #000066; font-weight: bold;">.</span>countdown = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>countdown<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatcher<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> counterEvent <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> countdown <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatcher<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> CounterEvent<span style="color: #000000;">&#40;</span> CounterEvent<span style="color: #000066; font-weight: bold;">.</span>RESET <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countdown = duration<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startCountdown<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isCountdownRunning = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> stopCountdown<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isCountdownRunning = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>The same <em>bindable</em> <strong>isCountdownRunning</strong> here. And two dead simple methods: <strong>startCountdown()</strong> and <strong>stopCountdown().</strong></p>
<p>Last, but not least: the now famous <strong>MainEventMap</strong>:</p>
<p><cite><br />
<h3>Demo #7: src/maps/MainEventMap.mxml</h3>
<p></cite></p>
<div class="codecolorer-container actionscript3 dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span><br />
<span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns<span style="color: #000066; font-weight: bold;">:</span>mate=<span style="color: #990000;">&quot;http://mate.asfusion.com/&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CountdownEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>SubCounter<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> managers<span style="color: #000066; font-weight: bold;">.</span>CountdownManager<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>FlexEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>Counter<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views<span style="color: #000066; font-weight: bold;">.</span>MainView<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> managers<span style="color: #000066; font-weight: bold;">.</span>CounterManager<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> Events<span style="color: #000066; font-weight: bold;">.</span>CounterEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Debugger <span style="color: #004993;">level</span>=<span style="color: #990000;">&quot;{Debugger.ALL}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{FlexEvent.APPLICATION_COMPLETE}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ObjectBuilder generator=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CounterEvent.INCREASE_GLOBAL}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;increaseGlobal&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CounterEvent.DECREASE_GLOBAL}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;decreaseGlobal&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CounterEvent.RESET}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;reset&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CountdownEvent.START_COUNTDOWN}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;startCountdown&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;{CountdownEvent.STOP_COUNTDOWN}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>MethodInvoker generator=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;stopCountdown&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventHandlers<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors targets=<span style="color: #990000;">&quot;{[Counter, MainView]}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{CounterManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sourceKey=<span style="color: #990000;">&quot;globalAmount&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;globalAmount&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors targets=<span style="color: #990000;">&quot;{[Counter, SubCounter]}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ListenerInjector eventType=<span style="color: #990000;">&quot;{CounterEvent.RESET}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;reset&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{MainView}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; debug=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>PropertyInjector <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{CountdownManager}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sourceKey=<span style="color: #990000;">&quot;isCountdownRunning&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;targetKey=<span style="color: #990000;">&quot;isCountdownRunning&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;</span>mate<span style="color: #000066; font-weight: bold;">:</span>ListenerInjector eventType=<span style="color: #990000;">&quot;{CountdownEvent.COUNTDOWN}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">method</span>=<span style="color: #990000;">&quot;updateTitle&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>Injectors<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">&lt;/</span>mate<span style="color: #000066; font-weight: bold;">:</span>EventMap<span style="color: #000066; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p><strong>EventHandlers</strong> and <strong>ListenerInjectors</strong> catch events, then <em>invoke methods</em>, or <em>inject properties</em>, <em>blah, blah, blah</em>.</p>
<p>I bet you start to get it by now <img src='http://www.flexstuff.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Next: #8 Modules Example (pt 1)</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.flexstuff.co.uk%2F2009%2F08%2F09%2Fmate-examples-7-reset-countdown-pt-2%2F';
  addthis_title  = 'Mate+examples%3A+%237+Reset+Countdown+%28pt+2%29';
  addthis_pub    = 'gillesguillemin';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.flexstuff.co.uk/2009/08/09/mate-examples-7-reset-countdown-pt-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

