<?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 &#187; Frameworks</title>
	<atom:link href="http://blog.nobien.net/category/frameworks/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>Mon, 19 Jul 2010 14:27:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<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>Anyone Using PureMVC Multicore For Non-Flex Flash Sites/Apps?</title>
		<link>http://blog.nobien.net/2008/11/16/anyone-using-puremvc-multicore-for-non-flex-flash-sitesapps/</link>
		<comments>http://blog.nobien.net/2008/11/16/anyone-using-puremvc-multicore-for-non-flex-flash-sitesapps/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 00:37:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Frameworks]]></category>

		<guid isPermaLink="false">http://blog.nobien.net/?p=89</guid>
		<description><![CDATA[Lately I've been experimenting with PureMVC. I'm really curious if it could aid in the development of side projects and even projects at work. In fact, I gave it a go on the project I'm currently on at work right now. All started out well, but then I ran into a dilemma. Basically, if you [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I've been experimenting with PureMVC. I'm really curious if it could aid in the development of side projects and even projects at work. In fact, I gave it a go on the project I'm currently on at work right now. All started out well, but then I ran into a dilemma. Basically, if you know anything about PureMVC, a mediator is register for a view component at runtime. Not being a total MVC genius, I figured I'd write some sort of proxy to load a section and register a mediator for the section once it was loaded.</p>
<p><span id="more-89"></span></p>
<p>Let me outline my situation hypothetically...</p>
<p>1. I have an Application class. This class is the document class of an FLA. The application has a navigation component in it. Each navigation button corresponds to a section. Hypothetically these sections are Home, Gallery and News.</p>
<p>2. I have 5 mediators. ApplicationMediator , NavMediator, HomeMediator, GalleryMediator, and NewsMediator. ApplicationMediator and NavMediator are registered in the shell during startup. Note, I'm using the Flash IDE so the Nav component is on the stage already and a child of Application.</p>
<p>3. NavMediator listens for clicks on the nav component and sends out a note to load a section. The ApplicationMediator hears this note and unloads the current section (if there is one) then loads the necessary section into a new Loader object. By default the home nav button is selected to load the home section when the app starts.</p>
<p>4. Once a section is loaded, lets assume its the Home section, the HomeMediator must be registered in the View. This is where I got stumped. Here are my two initial ways of register the mediator:</p>
<p>4.A. After loading is complete, the HomeMediator is registered in the view from ithin ApplicationMediator like so:</p>
<pre class="actionscript">facade.<span style="color: #006600;">regsiterMediator</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span><span style="color: #66cc66;">&#40;</span> HomeMediator<span style="color: #66cc66;">&#40;</span> loader.<span style="color: #006600;">content</span> as <span style="color: #0066CC;">Home</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre>
<p>The problem with this is that it requires HomeMediator be imported into ApplicationMediator (including the mediators for the other sections as well). Additionally, within HomeMediator (and other section nediators), I have a getter for the view component that looks like this:</p>
<pre class="actionscript"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">home</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Home</span>
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #b1b100;">return</span> viewComponent as <span style="color: #0066CC;">Home</span>;
<span style="color: #66cc66;">&#125;</span></pre>
<p>This ends up compiling Home (the section's FLA document class) into the main application SWF in addition to HomeMediator. I certainly don't want this to happen. I want all the code for the home section to be contained within the home SWF.</p>
<p>4.B. Rather than register the mediator in the ApplicationMediator, I would register the HomeMediator in the constructor of the Home component similar to the way the Application starts up. Like so:</p>
<pre class="actionscript"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">Home</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
   ApplicationFacade.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">registerMediator</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> HomeMediator<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">this</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>
<p>In some cases I would also manually send a notification to initialize the section so that it would run standalone. This method requires that I import ApplicationFacade into the Home component, thus compiling any classes that are imported into that class (commands, and the Application view component) into the Home SWF. I don't want this to happen either because I don't want to bloat each section with main application code.</p>
<p>So therein lies my dilemma. Each section is unloaded when a new section is requested to keep the memory usage of the site/app to a minimum because, in the real project, each section is rather large (some even use Papervision). I'm just totally stumped when to register the mediator for the loaded section without having unnecessary code compiled into the shell or the section.</p>
<p>Also, thanks to Simon for making me rewrite my situation a bit better. It was perhaps a bit confusing before.</p>
<p>I resorted to the PureMVC forums and was told that the Multicore version of PureMVC would solve my problems. I haven't had time to look into Multicore yet, but I was wondering if anyone out there has used the Multicore version on a, what might be, smiliar project (one that loads and unloads sections). Also note, that I'm not using Flex here, I'm using the Flash IDE (and FlashDevelop) to publish my content. So I'd love to hear the thoughts, experiences, etc from any one thats gone this route or has some sort of solution for using the non-multicore version of PureMVC. Thanks in advance.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nobien.net/2008/11/16/anyone-using-puremvc-multicore-for-non-flex-flash-sitesapps/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
