<?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>Nobien</title>
	<atom:link href="http://blog.nobien.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nobien.net</link>
	<description>A nerd blog about nerdy things by ... nerdy guys?</description>
	<lastBuildDate>Tue, 09 Feb 2010 23:25:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using BitmapData to Improve Performance (And One Small Annoyance)</title>
		<link>http://blog.nobien.net/2010/02/09/using-bitmapdata-to-improve-performance-and-one-small-annoyance/</link>
		<comments>http://blog.nobien.net/2010/02/09/using-bitmapdata-to-improve-performance-and-one-small-annoyance/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 22:37:49 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.nobien.net/?p=199</guid>
		<description><![CDATA[Lately I've been experimenting with generative art in Flash/ActionScript 3. Its been pretty fun and I've created some interesting results. In my experience, and I can only assume in most other artists and developers cases, I really got familiar with the Flash Player's performance limitiations. More specifically, I came to truly find out just how [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I've been experimenting with generative art in Flash/ActionScript 3. Its been pretty fun and I've created some interesting results. In my experience, and I can only assume in most other artists and developers cases, I really got familiar with the Flash Player's performance limitiations. More specifically, I came to truly find out just how bad the Flash Player is at rendering a lot of display objects at once, even if they're just Shape objects, even if cacheAsBitmap = true, and even if they're not animating in any way. This, of course, forces you to look into performance enhancing techniques.</p>
<p><span id="more-199"></span></p>
<p>The most common technique that I see artists and developers using involves  rendering bitmaps from a display object. Rendering a bitmap of your display objects is a great way to keep the memory of your piece under control. If you were to just leave every Shape, Sprite or MovieClip you created on the stage, the memory your piece consumes would continually grow and eventually cripple your piece. So what you do is render a bitmap every so often and discard any "dead" display objects. By "dead" I mean display objects that are not animating or updating themselves in any way. Its a pretty simple technique. The following example illustrates how this is done:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_BitmapTest01_1944094962"
			class="flashmovie"
			width="500"
			height="300">
	<param name="movie" value="/examples/bitmapdata/BitmapTest01.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/examples/bitmapdata/BitmapTest01.swf"
			name="fm_BitmapTest01_1944094962"
			width="500"
			height="300">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The code for this example looks like so:</p>
<pre class="actionscript"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> circles:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>,
	<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>, <span style="color: #000000; font-weight: bold;">true</span>, 0x00FFFFFF <span style="color: #66cc66;">&#41;</span>;
bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span> circles <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> bitmap:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span> bitmapData <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> bitmap <span style="color: #66cc66;">&#41;</span>; 
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> onStageClick<span style="color: #66cc66;">&#40;</span> event:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i &amp;lt; <span style="color: #cc66cc;">10</span>; i++ <span style="color: #66cc66;">&#41;</span>
		circles.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> getRandomCircle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
	bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span> circles <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span> circles.<span style="color: #006600;">numChildren</span> <span style="color: #66cc66;">&#41;</span>
		circles.<span style="color: #006600;">removeChildAt</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getRandomCircle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Shape
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> c:Shape = <span style="color: #000000; font-weight: bold;">new</span> Shape<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * 0xFFFFFF <span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>;
	c.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>;
	<span style="color: #b1b100;">return</span> c;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, onStageClick <span style="color: #66cc66;">&#41;</span>;</pre>
<p>In this example a bitmap is rendered based on the contents of the circles Sprite object every time the user clicks the stage. However, before the bitmap is rendered, 10 random circles are placed inside the circles Sprite. After the bitmap is rendered, the random circles are removed. One of the best parts of rendering a bitmap is that you don't have to continually create new BitmapData or Bitmap objects when its time to render. If you add more display objects to your subject and want to render them in the bitmap you just have to call the draw() method on the BitmapData object again. Also, notice that the memory used by the piece doesn't increase over time even thought it looks like you're adding hundreds of display objects to the stage. Cool stuff.</p>
<p><strong>The One Small Annoyance</strong></p>
<p>As I've been messing around with this stuff I came across a little oddity which caused me great annoyance for a few hours. I decided to start adding filters to the shapes I was creating. No big deal, right? Well, lets take a look at what I did by adjusting the previous example to apply a BlurFilter instance on each circle that's created.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_BitmapTest02_597208946"
			class="flashmovie"
			width="500"
			height="300">
	<param name="movie" value="/examples/bitmapdata/BitmapTest02.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/examples/bitmapdata/BitmapTest02.swf"
			name="fm_BitmapTest02_597208946"
			width="500"
			height="300">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The code for this example looks like so:</p>
<pre class="actionscript"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filters</span>.<span style="color: #006600;">BlurFilter</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> circles:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>,
	<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>, <span style="color: #000000; font-weight: bold;">true</span>, 0x00FFFFFF <span style="color: #66cc66;">&#41;</span>;
bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span> circles <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> bitmap:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span> bitmapData <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> bitmap <span style="color: #66cc66;">&#41;</span>; 
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> onStageClick<span style="color: #66cc66;">&#40;</span> event:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i &amp;lt; <span style="color: #cc66cc;">10</span>; i++ <span style="color: #66cc66;">&#41;</span>
		circles.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> getRandomCircle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
	bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span> circles <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span> circles.<span style="color: #006600;">numChildren</span> <span style="color: #66cc66;">&#41;</span>
		circles.<span style="color: #006600;">removeChildAt</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getRandomCircle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Shape
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> c:Shape = <span style="color: #000000; font-weight: bold;">new</span> Shape<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * 0xFFFFFF <span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	c.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>;
	c.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>;
	c.<span style="color: #006600;">filters</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> BlurFilter<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">150</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #b1b100;">return</span> c;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, onStageClick <span style="color: #66cc66;">&#41;</span>;</pre>
<p>You should notice occasionally that when the bitmap is rendered there are some clipping issues. You might see some hard lines on a blurred circle as if it was masked. This not only occured for BlurFilter instances, but also any other filters with blur-like effects, such as DropShadowFilter and GlowFilter. The following screen shot illustrates this:</p>
<p><img src="http://blog.nobien.net/examples/bitmapdata/clipping.jpg" border="0" alt="Clipping Screenshot" width="500" height="300" /></p>
<p>I couldn't for the life of me figure out what was causing this to occur until I accidentally stumbled across a fix while creating these examples. <strong>To avoid the clipping, simply add the display object that you're rendering to the stage</strong>. Why this works is beyond me, but at least its a fix. As an additional performance measure, you can set the visibility of that display object to false. In the case of these examples we're talking about the circles Sprite. Adjust the line where the circles Sprite is created to look like this:</p>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> circles:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> circles <span style="color: #66cc66;">&#41;</span>;
circles.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</pre>
<p>And the resulting piece should render properly like so:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_BitmapTest03_1437853433"
			class="flashmovie"
			width="500"
			height="300">
	<param name="movie" value="/examples/bitmapdata/BitmapTest03.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/examples/bitmapdata/BitmapTest03.swf"
			name="fm_BitmapTest03_1437853433"
			width="500"
			height="300">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>While this is just a basic example, this technique can be applied in many different ways to improve performance. For example, I've been working on a painting program that paints a loaded image using organic moving brushes that uses a similar technique. The brushes even animate a bit before the are discarded. At any rate, I hope to find more time to be able to share more things that I find useful while working with generative art. Until then, please post questions or any suggestions to techniques you find useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nobien.net/2010/02/09/using-bitmapdata-to-improve-performance-and-one-small-annoyance/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Get yourself to NYC for Flash and the City</title>
		<link>http://blog.nobien.net/2010/01/29/get-yourself-to-nyc-for-flash-and-the-city/</link>
		<comments>http://blog.nobien.net/2010/01/29/get-yourself-to-nyc-for-flash-and-the-city/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 16:32:07 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.nobien.net/?p=195</guid>
		<description><![CDATA[I had the pleasure of hanging out with Elad Elrom last night. He's one of the organizers of the upcoming Flash and the City conference here in NYC. I highly recommend attending this conference for the following reasons:
1. Its in F*ckin' New York City!
I know NYC isn't for everyone but there's everything you could imagine [...]]]></description>
			<content:encoded><![CDATA[<p>I had the pleasure of hanging out with <a href="http://www.elromdesign.com/blog" target="_blank">Elad</a> <a href="http://www.twitter.com/EladElrom" target="_blank">Elrom</a> last night. He's one of the organizers of the upcoming <a href="http://www.flashandthecity.com/" target="_blank">Flash and the City</a> conference here in NYC. I highly recommend attending this conference for the following reasons:</p>
<p><strong>1. Its in F*ckin' New York City!</strong><br />
I know NYC isn't for everyone but there's everything you could imagine here. On top of learning and getting inspired about Flash you'll have everything NYC has to offer at your finger tips. The organizers of the conference know this and have created what they call the "City Track". They've organized a few "field trips" throughout the city that you can tag along with. Just think of all the cool stuff you'll be able to check out, eat, and do while you're here!</p>
<p><strong>2. Its at the 3-Legged Dog Art &amp; Technology Center</strong><br />
This place is just plain cool. Its entirely artist-run and have been supporting the arts in NYC since the center was built in 2006 just three blocks south of the WTC site. Personally, it feels good to be supporting such an organization.</p>
<p><strong>3. The ridiculously good list of attending speakers</strong><br />
ZOMG! Srsly u guys! There hasn't been a large Flash conference in NYC...since...I don't know...2004? And that one pretty much sucked. But just look at the <a href="http://blog.flashandthecity.com/speakers/" target="_blank">list of speakers</a>! If you don't recognize the names, just trust me on this. They're are some really sharp people speaking about some great developments in the industry.</p>
<p><strong>4. The Price is Right</strong><br />
Tickets right now are $299 (but lets just be real and say $300). In comparison to other conferences, this is CHEAP, especially for NYC standards.  And if you keep your ear in the community (Twitter, blogs, etc), you might even be able to find a coupon code!</p>
<p>I'd say these are my main reasons for anyone to attend the conference right now. I'm sure I'll come up with more and if I do, I'll update this post. Naturally, I plan on attending seeing as I live here and I hope to see you along with my other friends and colleagues here as well! It's gonna be a blast.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nobien.net/2010/01/29/get-yourself-to-nyc-for-flash-and-the-city/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Source Media Framework (Sprint 8) Bug in NetStreamPlayTrait and NetStreamTimeTrait?</title>
		<link>http://blog.nobien.net/2009/12/28/open-source-media-framework-sprint-8-bug-in-netstreamplaytrait-and-netstreamtimetrait/</link>
		<comments>http://blog.nobien.net/2009/12/28/open-source-media-framework-sprint-8-bug-in-netstreamplaytrait-and-netstreamtimetrait/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 22:01:45 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Frameworks]]></category>

		<guid isPermaLink="false">http://blog.nobien.net/?p=184</guid>
		<description><![CDATA[Over the last two months or so I've been keeping my eyes on Adobe's Open Source Media Framework (OSMF) project. I started fiddling around with Sprint 7, seeing if I could build a progressive video player component on top of it. My first impression was that the project was still in its infancy solely based [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last two months or so I've been keeping my eyes on Adobe's <a href="http://www.opensourcemediaframework.com/">Open Source Media Framework</a> (OSMF) project. I started fiddling around with Sprint 7, seeing if I could build a progressive video player component on top of it. My first impression was that the project was still in its infancy solely based on the naming conventions of the framework's events. It just didn't feel intuitive. Additionally, there seemed to be some bugs surrounding the seeking of progressive videos. Alas, the development team has made some major improvements in Sprint 8 with regards to both of these items.</p>
<p>Upon downloading Sprint 8 I was immediately happy with the renaming of the framework event classes. They make much more sense now. Seeking progressive videos seemed to have improved as well, but I was still experiencing some buggy behavior when continuously scrubbing a progressive video.</p>
<p><span id="more-184"></span></p>
<p>My conclusion is that there is a bug in the NetStreamPlayTrait class and NetStreamTimeTrait classes. Basically, the NetStream.Play.Stop status code is sometimes dispatched when it shouldn't be. For instance, when I continuously scrub a video using the seek() method, there are times at which the aforementioned status code is dispatched when the playhead isn't at the very end of the video. More specifically, when I scrub to the end of the video for the first time the status code is dispatched and caught by the mentioned framework classes. Thus, this causes two things to happen.</p>
<p>First, the NetStreamTimeTrait class dispatches a TimeEvent.DURATION_REACHED event whenever this status code is received. Thus, the MediaPlayer redispatches this event at times when the playhead is not at the end, causing registered listeners to think the playback has completed when it hasn't. This was very strange, so I put some trace statements in the onNetStatus event handler of this class to check the currentTime and duration properties. When this event was dispatched during continuous scrubbing these values were never the same and often not close to being equal at all. Even when the video reached the duration during playback, these values weren't always equal. In one case the currentTime property was larger than the duration by one decimal place. I'm guessing this is a discrepancy between the NetStream.time property and the value of the duration provided by the meta data. At any rate, I thought it might be good to add a condition into the status handler to check if the currentTime was equal to the duration, thus verifying the playhead has in fact truly reached the end of the video. First, I edited the currentTime setter to look like this:</p>
<pre class="actionscript">override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> currentTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">min</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">duration</span>, <span style="color: #0066CC;">netStream</span>.<span style="color: #0066CC;">time</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>
<p>This ensures that the currentTime is never larger than the duration and avoids the bug I described earlier. Next I added a condition into the onNetStatus handler of the NetStream.Play.Stop code. It now looks like this:</p>
<pre class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onNetStatus<span style="color: #66cc66;">&#40;</span>event:NetStatusEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">info</span>.<span style="color: #006600;">code</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">case</span> NetStreamCodes.<span style="color: #006600;">NETSTREAM_PLAY_STOP</span>:
            <span style="color: #808080; font-style: italic;">// For progressive,	NetStream.Play.Stop means the duration</span>
            <span style="color: #808080; font-style: italic;">// was reached.  But this isn't fired for streaming.</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>NetStreamUtils.<span style="color: #006600;">isRTMPResource</span><span style="color: #66cc66;">&#40;</span>resource<span style="color: #66cc66;">&#41;</span> == <span style="color: #000000; font-weight: bold;">false</span> &amp;&amp;
                currentTime == <span style="color: #0066CC;">duration</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
                processDurationReached<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #b1b100;">break</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>Notice the additional condition to check if the currentTime is equal to the duration. This ensures that the TimeEvent.DURATION_REACHED event isn't dispatched until the playhead time has reached the duration. These two fixes took care of the TimeEvent.DURATION_REACHED event from being dispatched when it shouldn't be, however I was still experiencing a problem when I tried to resume playback of the progressive video if I happened to scrub it to the end.</p>
<p>Just as in the NetStreamTimeTrait class, the NetStreamPlayTrait class handles the NetStream.Play.Stop status code. As mentioned, the status code tends to get dispatched when it shouldn't, especially when continuously scrubbing and you happen to scrub to the end of the video. So, in the NetStreamPlayTrait class is that when this status code is dispatched, the following code is executed:</p>
<pre class="actionscript"><span style="color: #b1b100;">case</span> NetStreamCodes.<span style="color: #006600;">NETSTREAM_PLAY_STOP</span>:
    <span style="color: #808080; font-style: italic;">// Fired when streaming connections buffer, but also when</span>
    <span style="color: #808080; font-style: italic;">// progressive connections finish.  In the latter case, we</span>
    <span style="color: #808080; font-style: italic;">// halt playback.</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>urlResource != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp;
        NetStreamUtils.<span style="color: #006600;">isRTMPStream</span><span style="color: #66cc66;">&#40;</span>urlResource.<span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// Explicitly stop to prevent the stream from restarting on seek();</span>
        streamStarted = <span style="color: #000000; font-weight: bold;">false</span>;
        <span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">break</span>;</pre>
<p>So for progressive videos, the streamStarted property is set to false and the video is stopped. Confused, I followed the stop method around and determined that is just pauses the NetStream object. Then I looked around for where the streamStarted property is used and found it being used within the processPlayStateChange() method. From what I can tell it's used to denote if stream/video data exists in the NetStream object. Why would this be set to false for a progressive video's NetStream.Play.Stop status? Is not the video data still in memory? So I commented out that line and the code now looks like this:</p>
<pre class="actionscript"><span style="color: #b1b100;">case</span> NetStreamCodes.<span style="color: #006600;">NETSTREAM_PLAY_STOP</span>:
    <span style="color: #808080; font-style: italic;">// Fired when streaming connections buffer, but also when</span>
    <span style="color: #808080; font-style: italic;">// progressive connections finish.  In the latter case, we</span>
    <span style="color: #808080; font-style: italic;">// halt playback.</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>urlResource != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp;
        NetStreamUtils.<span style="color: #006600;">isRTMPStream</span><span style="color: #66cc66;">&#40;</span>urlResource.<span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// Explicitly stop to prevent the stream from restarting on seek();</span>
        <span style="color: #808080; font-style: italic;">//streamStarted = false;</span>
        <span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">break</span>;</pre>
<p>Upon testing my video player my continuous scrubbing seems to behave properly! Woohoo! Now let me just say that I have not tested this extensively and I know that OSMF is still in development. I could very well have created a new bug by doing this, but at least things are behaving the way I would assume they would now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nobien.net/2009/12/28/open-source-media-framework-sprint-8-bug-in-netstreamplaytrait-and-netstreamtimetrait/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New Flash Community Developments: Robotlegs and Signals</title>
		<link>http://blog.nobien.net/2009/12/14/new-flash-community-developments-robotlegs-and-signals/</link>
		<comments>http://blog.nobien.net/2009/12/14/new-flash-community-developments-robotlegs-and-signals/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 21:19:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Frameworks]]></category>

		<guid isPermaLink="false">http://blog.nobien.net/?p=178</guid>
		<description><![CDATA[I've come to realize that I'm always a bit hesitant to change. I was late to get a cell phone, late to join Facebook, late to join Twitter, and often late to look into developments within the Flash community. Lately I've been trying to change how often I tune into Flash community developments. As of [...]]]></description>
			<content:encoded><![CDATA[<p>I've come to realize that I'm always a bit hesitant to change. I was late to get a cell phone, late to join Facebook, late to join Twitter, and often late to look into developments within the Flash community. Lately I've been trying to change how often I tune into Flash community developments. As of late I've stumbled across two projects that struck my fancy: <a href="http://www.robotlegs.org/">Robotlegs</a> and <a href="http://github.com/robertpenner/as3-signals">Signals</a>. Robotlegs is a lightweight MVCS architecture that is very focused on dependency injection. Signals is the result of Robert Penner's frustration with the Flash Player's native event system. Thus he has created an event system inspired by C# events and signals/aslots in Qt. Both looked like interesting projects so I decided to dive into them further. I'll start with robotlegs.</p>
<p><span id="more-178"></span></p>
<p>Having some experience with PureMVC and even having some pleasant success with it, I was quite intrigued by some claims that robotlegs is "<a href="http://jessewarden.com/2009/10/how-to-use-robotlegs-on-top-of-gaia-part-1-of-3-quickstart.html">PureMVC done right</a>". Hmm...At any rate, I can't help but be intrigued by a claim such as this and I always enjoy looking reading about developers' often unwavering opinions about how an MVC pattern should be implemented. So after reading the docs, development forums and checking out the examples, I feel that robotlegs is a great concept and has fulfilled its development philosophy very well. It seems to me that its primary focus has been the use of dependency injection. This allows you to keep the layers of your application nicely decoupled. In my early research, I was a bit annoyed by the fact that the injection module, <a href="http://github.com/tschneidereit/SwiftSuspenders">SwiftSuspenders</a>, was only compatible with the mxmlc compiler. However, the latest version includes the ability to use XML to configure the injection points so I can now use it with the Flash IDE. Yes, I, <em>and a lot of other people</em>, still use the Flash IDE to compile applications.</p>
<p>My only complaint about Robotlegs is very subjective. And let me preface this with the fact that I'm not a classically trained developer (I have a degree in design, not computer science). But Robotlegs was rather difficult to get my head partially wrapped around. More specifically, <a href="http://en.wikipedia.org/wiki/Dependency_injection">dependency injection</a> was, and still is, rather difficult for me to understand. I understand the point of it, but how its implemented in Robotlegs still seems like magic to me. And because I don't understand the dependency injection all that well, its hard for me to feel really comfortable using the framework to develop anything. In comparison, what I really like about <a href="http://puremvc.org/">PureMVC</a> was that it was pretty easy to learn and the core concepts are also easy to understand (at least to me). Regardless, this is not to say that Robotlegs is any better or worse than PureMVC.</p>
<p>Unlike my apprehensiveness for Robotlegs, I am really excited about Robert Penner's <a href="http://github.com/robertpenner/as3-signals">Signals</a> project. I stumbled across this project while researching Robotlegs. I didn't quite understand it at first, but after checking out the source and giving a go I became instantly hooked on the idea and hope I can integrate it into my future projects. Basically what Penner has done is create an event/notification system that can pass around strongly typed objects to listeners instead of the native/traditional <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html">Event</a> object. Signals are, to put it simply, an object that represents an event. Thus a signal object has its own API for registering and unregistering listeners. Signals also gives you the ability to define the types of signals an object should possess in your interfaces. This fulfills one of my biggest wishes for interfaces: a way to define the types of events an object should have to dispatch. As of now the project seems to still be in development with Penner experimenting how to make working with native events a bit easier. I highly recommend looking into his work, but don't expect much as he's apparently in Thailand until the beginning of January.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nobien.net/2009/12/14/new-flash-community-developments-robotlegs-and-signals/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AIR:CMR &#8211; Free Books? Academia?</title>
		<link>http://blog.nobien.net/2009/10/08/aircmr-free-books-academia/</link>
		<comments>http://blog.nobien.net/2009/10/08/aircmr-free-books-academia/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 12:25:43 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://blog.nobien.net/?p=118</guid>
		<description><![CDATA[I just received a couple copies of the Chinese translation of Adobe AIR -Create Modify Reuse. It's pretty exciting to see your book translated into other languages, even if you can't read them. 
I'd like to donate them to a High School or College. Would anyone in academia like a Chinese or Spanish translated copy [...]]]></description>
			<content:encoded><![CDATA[<p>I just received a couple copies of the Chinese translation of <a href="http://www.amazon.com/Adobe-AIR-Create-Modify-Programmer/dp/0470182075/ref=sr_1_4?ie=UTF8&s=books&qid=1255004549&sr=8-4">Adobe AIR -Create Modify Reuse</a>. It's pretty exciting to see your book translated into other languages, even if you can't read them. </p>
<p>I'd like to donate them to a High School or College. Would anyone in academia like a <strong>Chinese </strong><em>or <strong>Spanish </strong></em>translated copy of our <a href="http://www.amazon.com/Adobe-AIR-Create-Modify-Programmer/dp/0470182075/ref=sr_1_4?ie=UTF8&s=books&qid=1255004549&sr=8-4">book</a>? I'd prefer to hear from people who instruct New Media or IT courses, or is involved with a school's library. </p>
<p>I will only ship these to a school address. No home addresses. No student dorms and housing. Please email me at aircmr "@" nobien.net.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nobien.net/2009/10/08/aircmr-free-books-academia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pretty Pleased with the SWFAddress Apache, mod_rewrite, and PHP SEO Implementation</title>
		<link>http://blog.nobien.net/2009/09/11/swfaddress-apache-mod_rewrite-php-seo-implementation/</link>
		<comments>http://blog.nobien.net/2009/09/11/swfaddress-apache-mod_rewrite-php-seo-implementation/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 19:30:07 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Server Side Scripting]]></category>

		<guid isPermaLink="false">http://blog.nobien.net/?p=162</guid>
		<description><![CDATA[The latest project I've been working on at Rokkan has been umbro.com. When the project first came to us there was quite a bit of discussion over what technology to use, specifically HTML vs. Flash. The client, naturally, was concerned about SEO but also wanted a nice "rich" experience. Sure, there's been a little bit [...]]]></description>
			<content:encoded><![CDATA[<p>The latest project I've been working on at Rokkan has been umbro.com. When the project first came to us there was quite a bit of discussion over what technology to use, specifically HTML vs. Flash. The client, naturally, was concerned about SEO but also wanted a nice "rich" experience. Sure, there's been a little bit of talk lately over the fact that Google can now index certain types of content with regards to SWF files and the files which they load, but its still sketchy at best. Not to mention you have to pay close attention to how you setup your text fields 'n such. Hell, when is the last time you searched on Google for something significant and got a result that takes you to a specific page of a Flash site/app? I honestly can't think of that every happening to me.</p>
<p><span id="more-162"></span></p>
<p>At any rate, after much debate we decided that the experience was a bit more important to us so we would focus on the Flash front end. Regardless of that decision, we also would create a text-only/HTML/SEO friendly version of the site for search engines to crawl using <a href="http://www.asual.com/swfaddress/" target="_blank">SWFAddress's SEO setup</a> that uses a little special JavaScript, Apache's mod_rewrite and PHP. If you haven't checked this out yet, I highly recommend it.</p>
<p>If you're too lazy to go check out the SWFAddress site, I'll summarize what it does for you. Essentially, with the combination of the aforementioned technologies, SWFAddress now ships with a simple rule-based URL rewriting engine to handle entry URLs that do not contain the SWFAddress hash mark (#). This allows us to display equivalent content under the same folder structure that the Flash site/app uses for users that do not have both JavaScript and the Flash Player. For example, if you have JavaScript enabled and the Flash Player installed and go to <a href="http://www.umbro.com/en_UK/about/" target="_blank">www.umbro.com/en_UK/about/</a> you will be redirected to the SWFAddress/Flash friendly URL <a href="http://www.umbro.com/en_UK/#/about/" target="_blank">www.umbro.com/en_UK/#/about/</a>. If you don't have JavaScript enabled or the Flash Player installed at all, mod_rewrite sends the folder path as a string to a PHP script. In this script you setup rules that determine what HTML content to display. Thus, you can display equivalent textual/semantic/SEO friendly content to anything that doesn't use JavaScript and Flash, eg: search engine spiders.</p>
<p>The only drawback I can see with this implementation at this point is the way in which users share URLs with each other. I'm guessing most users are more apt to simply copy and paste the URL from their browser's address bar than anything else. In this case they're grabbing the SWFAddress/Flash friendly URL with the hash (#) mark in it. Unfortunately if this is the URL that gets posted around the internet and shared via blogs, twitter, facebook, etc, then these pages aren't really going to increase in page rank all that much. However, in order to facilitate the sharing of the non-hash-marked URL, we've placed a "Share This" tool on as many pages within the Flash app as possible. This button uses the link sharing API's for a few social networks and passes in the SEO friendly URLs (without the hash mark) instead of whats in the address bar.</p>
<p>One thing I will say if you do decide to use this approach is to be aware of the amount of extra work that it will entail. You're essentially creating two sites, one in HTML and one in Flash. This can become rather time consuming depending on the scope fo the project and the amount of content. In the case of umbro.com we didn't really have that many pages to duplicate but we did have four markets/languages. On top of this, we initially created very bare-bones and unstyled HTML content that we knew would get indexed as long as it was being spidered. However, once a few people checked out umbro.com on their mobile devices and noticed that the "mobile" version was different than the version they saw on the desktops or laptops, those people suddenly thought that they were indeed seeing THE "mobile" version, not the version that anyone or anything that doesn't have JavaScript and Flash will see. So suddenly we had to pretty up that content with some nice images and CSS styles which required a bit more work than we had anticipated from the start.</p>
<p>I'm pretty happy with how things turned out with umbro.com, if you do some obvious Google searches such as '<a href="http://www.google.com/search?rlz=1C1GGLS_enUS291US304&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=about+umbro" target="_blank">about umbro</a>' or '<a href="http://www.google.com/search?hl=en&amp;rlz=1C1GGLS_enUS291US304&amp;q=where+to+buy+umbro&amp;aq=f&amp;oq=&amp;aqi=g10" target="_blank">where to buy umbro</a>' you can see that pages from umbro.com are appearing pretty high in the results right now and thats honestly good enough for me at this point as I've never built an entire site in Flash and had any sort of results show up in Google before. I'm also pretty curious as to who else out there has implemented this with good results, so if you or any other sites you know of that have gone with this solution please leave a comment and URL. Thanks in advance.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nobien.net/2009/09/11/swfaddress-apache-mod_rewrite-php-seo-implementation/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
