<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Almer/Blank Labs &#187; Uncategorized</title>
	<atom:link href="http://labs.almerblank.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.almerblank.com</link>
	<description>Blog of the Talent at Almer/Blank</description>
	<lastBuildDate>Mon, 19 Jul 2010 22:55:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>R Blank Speaking at FITC SF</title>
		<link>http://labs.almerblank.com/2010/06/r-blank-speaking-at-fitc-sf/</link>
		<comments>http://labs.almerblank.com/2010/06/r-blank-speaking-at-fitc-sf/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 02:07:00 +0000</pubDate>
		<dc:creator>rblank</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1513</guid>
		<description><![CDATA[Howdy all:
I know blogging&#039;s been light for the past several months. Work here at Almer/Blank has had me pretty consumed.
But, as I gear up and prepare for a busy autumn of talks and courses, you can expect some heavier posting.
First up, I&#039;ll be presenting at FITC San Francisco &#8212; the first SF installment of the [...]]]></description>
			<content:encoded><![CDATA[<p>Howdy all:</p>
<p>I know blogging&#039;s been light for the past several months. Work here at <a href="http://almerblank.com" target="_blank">Almer/Blank</a> has had me pretty consumed.</p>
<p>But, as I gear up and prepare for a busy autumn of talks and courses, you can expect some heavier posting.</p>
<p>First up, I&#039;ll be presenting at <a href="http://www.fitc.ca/events/schedule/?event=110" target="_blank">FITC San Francisco</a> &#8212; the first SF installment of the really amazing <a href="http://fitc.ca/" target="_blank">FITC conferences</a>.</p>
<p><a href="http://www.fitc.ca/events/schedule/?event=110"><img class="alignnone size-full wp-image-1055" src="http://www.rblank.com/wp-content/uploads/2010/06/FITC_sf2010_200x150_speaker_.jpg" alt="" width="200" height="150" /></a></p>
<p><span id="more-1513"></span>On day one, August 17th, I&#039;ll be giving my talk, <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=110&amp;presentation_id=1215" target="_blank">&#039;Hearing Pictures with Synthia&#039;</a> &#8212; you can see an earlier version of that talk, from FITC Toronto in April, <a href="http://labs.almerblank.com/hearing-pictures-with-synthia/" target="_blank">here</a>, and play with Synthia at <a href="http://SynthiaHearsPictures.com" target="_blank">SynthiaHearsPictures.com</a>.</p>
<p>Then, on day three, August 19th, I&#039;ll be giving a talk on <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=110&amp;presentation_id=1277" target="_blank">&#039;Getting Started with Adobe Open Source Media Framework (OSMF)&#039;</a> in the &#039;Adobe Under the Hood&#039; room &#8212; a version from FITC Toronto in April you can view <a href="http://labs.almerblank.com/2010/04/new-intro-to-adobe-osmf-videos/" target="_blank">here</a>.</p>
<p>It will be an amazing conference, with a ton of great talks. Early bird pricing ends July 2nd, so get your tickets now!</p>
<p>Share and enjoy!</p>
<p>-r</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2010/06/r-blank-speaking-at-fitc-sf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Simplest Possible OSMF Player</title>
		<link>http://labs.almerblank.com/2010/04/the-simplest-possible-osmf-player/</link>
		<comments>http://labs.almerblank.com/2010/04/the-simplest-possible-osmf-player/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 02:47:49 +0000</pubDate>
		<dc:creator>rblank</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1413</guid>
		<description><![CDATA[I&#039;m continuing work on my FITC Toronto talk, &#039;Standardize Your Flash with Adobe OSMF&#039;, and the files to accompany it.
OSMF certainly has features and functionality for hard-core developers to build powerful media-rich experiences. But OSMF also makes basic media player code really easy for those users of Flash who might not consider themselves developers, but [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;m continuing work on my <a href="http://fitc.ca/toronto" target="_blank">FITC Toronto</a> talk, &#039;<a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=102&amp;presentation_id=1159" target="_blank">Standardize Your Flash with Adobe OSMF</a>&#039;, and the files to accompany it.</p>
<p>OSMF certainly has features and functionality for hard-core developers to build powerful media-rich experiences. But OSMF also makes basic media player code really easy for those users of Flash who might not consider themselves developers, but who still are comfortable coding on the timeline.</p>
<p>One of the issues with the <a href="http://opensource.adobe.com/wiki/display/osmf/Developer+Documentation" target="_blank">still nascent, but growing at an impressive rate OSMF documentation</a>, is that almost all the sample code is for users of Flex Builder / Flash Builder &#8212; and all of the sample code for Flash assumes use of external class files.</p>
<p>But using OSMF does not require coding in external class files. So, to illustrate that point, I&#039;ve gone ahead and modified the <a href="http://help.adobe.com/en_US/OSMF/1.0/Dev/WSc6f922f643dd2e6d35eac4ec123ba018dfc-7ff6.html" target="_blank">simplest possible OSMF video player</a> from Adobe&#039;s documentation to code that works on the timeline. Which I&#039;m posting here.<span id="more-1413"></span></p>
<p>So this is code (OSMF Sprint 10 v0.93) you can paste onto any timeline that will play video with OSMF.</p>
<p>Want to make it stream the video instead of playing it progressively? Point it to an RTMP URL instead, and it will automatically play.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> org.<span style="color: #006600;">osmf</span>.<span style="color: #006600;">containers</span>.<span style="color: #006600;">MediaContainer</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">osmf</span>.<span style="color: #006600;">elements</span>.<span style="color: #006600;">VideoElement</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">osmf</span>.<span style="color: #006600;">media</span>.<span style="color: #006600;">MediaPlayer</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">osmf</span>.<span style="color: #006600;">media</span>.<span style="color: #006600;">URLResource</span>;
<span style="color: #808080; font-style: italic;">// Create the container class that displays the media.</span>
<span style="color: #000000; font-weight: bold;">var</span> container:MediaContainer = <span style="color: #000000; font-weight: bold;">new</span> MediaContainer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">//add the MediaContainer instance to the stage</span>
addChild<span style="color: #66cc66;">&#40;</span>container<span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// Create the resource to play and point it to the FLV</span>
<span style="color: #000000; font-weight: bold;">var</span> resource:URLResource=<span style="color: #000000; font-weight: bold;">new</span> URLResource<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;my.flv&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// Create the MediaElement</span>
<span style="color: #000000; font-weight: bold;">var</span> videoElement:VideoElement=<span style="color: #000000; font-weight: bold;">new</span> VideoElement<span style="color: #66cc66;">&#40;</span>resource<span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">//add the VideoElement to our container class</span>
container.<span style="color: #006600;">addMediaElement</span><span style="color: #66cc66;">&#40;</span>videoElement<span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">//create the MediaPlayer instance</span>
<span style="color: #000000; font-weight: bold;">var</span> mediaPlayer:MediaPlayer = <span style="color: #000000; font-weight: bold;">new</span> MediaPlayer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// Set the MediaElement on a MediaPlayer.</span>
<span style="color: #808080; font-style: italic;">//Because autoPlay defaults to true, playback begins immediately.</span>
mediaPlayer.<span style="color: #006600;">media</span>=videoElement;</pre></div></div>

<p>Share and enjoy!</p>
<p>-r</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2010/04/the-simplest-possible-osmf-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on PureMVC Mediators</title>
		<link>http://labs.almerblank.com/2010/02/thoughts-on-puremvc-mediators/</link>
		<comments>http://labs.almerblank.com/2010/02/thoughts-on-puremvc-mediators/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 05:01:52 +0000</pubDate>
		<dc:creator>Omar Gonzalez</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code & Samples]]></category>
		<category><![CDATA[code examples]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[PureMVC]]></category>

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

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

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

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

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

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

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

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

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

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

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

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

]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2010/02/thoughts-on-puremvc-mediators/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hearing Pictures &#8211; Homebrew Microphone Edition</title>
		<link>http://labs.almerblank.com/2009/11/hearing-pictures-homebrew-microphone-edition/</link>
		<comments>http://labs.almerblank.com/2009/11/hearing-pictures-homebrew-microphone-edition/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 03:48:12 +0000</pubDate>
		<dc:creator>rblank</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hearing pictures]]></category>

		<guid isPermaLink="false">http://labs.almerblank.com/?p=1278</guid>
		<description><![CDATA[This coming Wednesday, December 2nd, I'll be giving my new talk, <em>Hearing Pictures</em> at the <a href="http://laflash.eventbrite.com" target="_blank">LA Flash End-Of-Year Party</a>. This will be only the second time I've given this talk -- I first gave it at the <a href="http://www.fitc.ca/events/about/?event=100" target="_blank">FITC Unconference at MAX 2009</a>. Since I was speaking at an unconference (a less formal environment, with very different criteria for acceptability than the normal conference tracks), I used the opportunity to create a brand new talk on a sort of crazy idea that's been nagging me for a few years -- the idea of translating anything into anything.

But, that's not what this post is about.

One key limitation of this entire process is that I'm working with digital information. Now, I'm not complaining -- the fact that all information is digital is what permits us to execute the cross-modal translations with relative ease (i.e., it's easier to translate a picture into music, if both the picture and music are stored as 0s and 1s). However, working in digital is also a bit creatively limiting. When composing music on the computer, I'm composing from audio information already stored on the computer -- more like playing a synthesizer than a piano. Again, that's fine, but I thought it would be fun to start experimenting with analog inputs and outputs (which I can read and control from Flash using my <a href="http://makezine.com/controller/" target="_blank">MakingThings Controller Board</a>).

About a month ago, I picked up a copy of <a href="http://www.amazon.com/Handmade-Electronic-Music-Hardware-Hacking/dp/0415975921" target="_blank">Handmade Electronic Music: The Art of Hardware Hacking</a>, which describes, in a series of clearly written chapters, how to go about assembling synthesizers from inexpensive, easily available hardware.

[...]

]]></description>
			<content:encoded><![CDATA[<p>This coming Wednesday, December 2nd, I&#039;ll be giving my new talk, <em>Hearing Pictures</em> at the <a href="http://laflash.eventbrite.com" target="_blank">LA Flash End-Of-Year Party</a>. This will be only the second time I&#039;ve given this talk &#8212; I first gave it at the <a href="http://www.fitc.ca/events/about/?event=100" target="_blank">FITC Unconference at MAX 2009</a>. Since I was speaking at an unconference (a less formal environment, with very different criteria for acceptability than the normal conference tracks), I used the opportunity to create a brand new talk on a sort of crazy idea that&#039;s been nagging me for a few years &#8212; the idea of translating anything into anything.</p>
<p><a href="http://www.rblank.com/wp-content/uploads/2009/11/hearingPictures_20091129_b.001.png"><img style="border: 0px initial initial;" title="Hearing Pictures by R Blank" src="http://www.rblank.com/wp-content/uploads/2009/11/hearingPictures_20091129_b.001-300x225.png" alt="Hearing Pictures by R Blank" width="300" height="225" /></a></p>
<p><span id="more-1278"></span>The idea originated from a 1943 Hermann Hesse novel, <a href="http://en.wikipedia.org/wiki/The_Glass_Bead_Game" target="_blank"><em>The Glass Bead Game</em></a> (also published under the title, <em>Magister Ludi</em>, after the protagonist). The novel focuses around the life of Magister Ludi, who is a member of a monastic-style order at a time in the future.</p>
<p>The central activity of the order is the Glass Bead Game &#8212; it is their form of meditation. Although it is the central activity of the order, it is rather vaguely defined over the course of the text. Despite the lack of detail, the game has fascinated me since I read the novel. In the game, a glass bead represents an idea &#8212; any idea &#8212; such as an historical event, a work of music, a painting, a philosophical concept, anything. When it&#039;s your turn, you must play a bead &#8212; that is, you must play an idea on the game board. But the idea you play (the bead you place) must be related to the idea (bead) placed by the previous player, thus over the course of an entire game creating a thread uniting widely disparate parts of human knowledge and experience. In this way, being a successful player of the game requires an agile intellect with the capacity to relate any idea to a wide variety of other &#8212; seemingly unrelated &#8212; ideas. Playing the game well requires fluency in math, music, language, history, art and science.</p>
<p>Ever since I started working with Flash 11 years ago, I&#039;d always sort of envisioned Flash as a mini-Glass Bead Game. The term isn&#039;t really used any more, but when Flash was young, it was considered a <strong><em>multimedia</em></strong> tool. And, Flash took the idea of multimedia to a new level &#8212; that is, despite its drawbacks, Flash has, since version 4, made it <strong>ludicrously simple</strong> to work with information of many different kinds. Flash supports character animation, motion design, text, audio, video, images, 3D data, live data, interactivity &#8212; Flash basically supports any type of digital information (this is, more or less, literally true with the Flash Player 10 FileReference powers). So, using Flash, we can establish relationships between different types of information (which is what many of the early Flash luminaries did, in one form or another). Hence, my picture of Flash as a mini-Glass Bead Game.</p>
<p>The fact that, especially early on (until Flash 9), the most successful Flashers also tended to be the most eclectic, only strengthened this notion for me. Flash is really the only technology in the world that could give birth to a significant population of designer/developer hybrids (a.k.a., the deselopers), which speaks to the multi-disciplinary nature of the tool and the unique skill-sets that lead to success within Flash.</p>
<p>So, the idea of Flash as a Glass Bead Game kept percolating in my head for years, until I eventually decided to start trying to formalize the notion. The notion of creating a computer program that could translate anything into anything.</p>
<p>But of course, that&#039;s an insanely complex endeavor. So, I wanted to find a more focused niche that could serve as a starting point.</p>
<p>Then, Flash 9 came out, with its enhanced sound powers. All of a sudden you started seeing real-time audio analysis in Flash movies &#8212; sound visualizers translating sound into pictures. Now, of course, sound visualizers have been around for a while, but now I could build them myself, using the ActionScript code I already knew. And the thought occurred to me to create a machine that worked in reverse &#8212; translating pictures into music. Still, even with Flash 9&#039;s powers, it was a frustrating go. But, when Flash 10 came out, with the SampleDataEvent, I lost all excuses and picked things back up.</p>
<p>Of course, with the amount of time I&#039;ve been able to spend on the project, it&#039;s not even properly called a &#039;hobby&#039;. And so, I&#039;m now six months into what I consider to be a 40 year endeavor, and I have a few little experiments to show for the effort. Those experiments &#8212; and the thought that went into them &#8212; is what <a href="http://laflash.eventbrite.com" target="_blank">my talk at Wednesday&#039;s LA Flash End-Of-Year Party</a> is about.</p>
<p>But, that&#039;s not what this post is about.</p>
<p>One key limitation of this entire process is that I&#039;m working with digital information. Now, I&#039;m not complaining &#8212; the fact that all information is digital is what permits us to execute the cross-modal translations with relative ease (i.e., it&#039;s easier to translate a picture into music, if both the picture and music are stored as 0s and 1s). However, working in digital is also a bit creatively limiting. When composing music on the computer, I&#039;m composing from audio information already stored on the computer &#8212; more like playing a synthesizer than a piano. Again, that&#039;s fine, but I thought it would be fun to start experimenting with analog inputs and outputs (which I can read and control from Flash using my <a href="http://makezine.com/controller/" target="_blank">MakingThings Controller Board</a>).</p>
<p>About a month ago, I picked up a copy of <a href="http://www.amazon.com/Handmade-Electronic-Music-Hardware-Hacking/dp/0415975921" target="_blank">Handmade Electronic Music: The Art of Hardware Hacking</a>, which describes, in a series of clearly written chapters, how to go about assembling synthesizers from inexpensive, easily available hardware.</p>
<p><a href="http://www.rblank.com/wp-content/uploads/2009/11/IMG_0492.jpg"><img class="alignnone size-medium wp-image-641" title="An Electret Condenser Mic in Progress" src="http://www.rblank.com/wp-content/uploads/2009/11/IMG_0492-225x300.jpg" alt="An Electret Condenser Mic in Progress" width="225" height="300" /></a></p>
<p><a href="http://www.rblank.com/wp-content/uploads/2009/11/IMG_0492.jpg"></a>I&#039;m not done with the book yet, but in the early chapters, you learn how to build your own microphones &#8212; a few different types, including contact mics, compressor mics &#8212; even electromagnetic mics (microphones that &#039;play&#039; the sounds of the electromagnetic fields that surround the microphone).</p>
<p>When I rewrote the <em>Hearing Pictures</em> presentation this past weekend I found a neat way to integrate one of these piezo contact microphones into my talk. A contact microphone is one that can pick up vibrations in a surface, but not from the air. So, you can plug the contact mic into an amplifier, then hold the contact mic up to something that is vibrating and you will hear the vibration through the amp. They&#039;re fun to play around with (you can even hear the sound of metal heating up with these mics).</p>
<p>The simple, cheap (&lt;$1.50) contact microphone that I&#039;ve built relies on a <a href="http://en.wikipedia.org/wiki/Piezoelectric_sensor" target="_blank">Piezo disc, or piezo sensor</a> (~$0.75). These Piezo sensors rely on the Piezoelectric effect (discovered by Pierre and Marie Curie in 1880, but not industrialized as a sensor until the 1950s) to convert pressure, acceleration, strain or force into an electrical signal.</p>
<p><a href="http://www.rblank.com/wp-content/uploads/2009/11/IMG_0488.jpg"><img class="size-medium wp-image-642" title="The Contact Mic Ready To Go" src="http://www.rblank.com/wp-content/uploads/2009/11/IMG_0488-225x300.jpg" alt="The Contact Mic Ready To Go" width="225" height="300" /></a></p>
<p>You need a:</p>
<ul>
<li>Piezo disc</li>
<li>An amp</li>
<li>An audio jack (that fits your amp)</li>
<li>A little bit of audio cabling</li>
</ul>
<p>Audio cables are composed of two wires.</p>
<p>Step 1) Take one wire and solder it to the outer plate of the piezo disc, and solder the other end to one hookup in the audio jack.</p>
<p>Step 2) Then take the other wire and solder it to the inner plate of the piezo disc, and then solder the other end to the 2nd hookup in the audio jack.</p>
<p>Step 3) Plug the jack into the amp, and start rubbing your piezo disc against things to see how they sound</p>
<p>That&#039;s it! You don&#039;t even need a battery to power this mic. As you&#039;ll quickly see, you can not pick up any vibrations from the air &#8212; so it&#039;s totally unusable as a traditional mic (read the chapter on building a condenser mic if you&#039;re interested in that). But, if you place it on the end of a styrofoam cup, and then speak into the cup, you have a neat Halloween microphone!</p>
<p><a href="http://www.rblank.com/wp-content/uploads/2009/11/meAndContactMic_20091116.jpg"><img style="border: 0px initial initial;" title="Applying Styrofoam to the Contact Mic to Fake a Condenser Mic" src="http://www.rblank.com/wp-content/uploads/2009/11/meAndContactMic_20091116-300x259.jpg" alt="Applying Styrofoam to the Contact Mic to Fake a Condenser Mic" width="300" height="259" /></a></p>
<p><a href="http://www.rblank.com/wp-content/uploads/2009/11/meAndContactMic_20091116.jpg"></a>If you&#039;re interested to see how I integrated this contact mic into my talk, well then, all I can say is, show up on Wednesday. It&#039;s free, and it&#039;ll be a really cool and interesting talk. (Oh, and there&#039;s free beer &#8212; did I mention that?).</p>
<p>Share and enjoy!</p>
<p>-r</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.almerblank.com/2009/11/hearing-pictures-homebrew-microphone-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
