<?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>kenny bunch &#187; ActionScript</title>
	<atom:link href="http://www.kennybunch.com/blog/category/flash/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kennybunch.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 25 Sep 2009 16:11:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Embedding JavaScript into a SWF</title>
		<link>http://www.kennybunch.com/blog/2009/09/embedding-javascript-into-a-swf/</link>
		<comments>http://www.kennybunch.com/blog/2009/09/embedding-javascript-into-a-swf/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 16:11:59 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=272</guid>
		<description><![CDATA[Developers that have been using Flex should be pretty familiar by now with the Embed metadata tag which allows you to embed assets into a SWF (like images, SWFs, XML, etc). This option has also been added to CS4 (CS4 uses the Flex SDK to complete this task). 
What some of you may not know [...]]]></description>
			<content:encoded><![CDATA[<p>Developers that have been using Flex should be pretty familiar by now with the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=embed_3.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://livedocs.adobe.com/flex/3/html/help.html?content=embed_3.html');">Embed metadata tag</a> which allows you to embed assets into a SWF (like images, SWFs, XML, etc). This option has also been added to CS4 (CS4 uses the Flex SDK to complete this task). </p>
<p>What some of you may not know or though of, is that you can actually embed JavaScript libraries into your SWF and have your SWF write those libs to the pages DOM. We've been using this technique for a while. However, when someone asked for a reference on the subject, I searched the web and didn't find one. So here we are <img src='http://www.kennybunch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>This technique is quite simple. The basics of it are that you embed the JavaScript library using the embed syntax, then create a Class that references it when instantiated, instantiate that class, get the string representation of the instance, and send that string to the page to be embedded using a JavaScript eval statement.</p>
<p>To illustrate this, lets create a JavaScript file called hello.js which has a single function hello that throws an JS alert.</p>
<p>Hello.js</p>
<div class="igBar"><span id="ljavascript-3"><a href="#" onclick="javascript:showPlainTxt('javascript-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-3">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> hello<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"hello"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now lets create the ActionScript file that embeds the JS into a SWF, writes it to the page, and calls the hello function in the lib.</p>
<div class="igBar"><span id="lactionscript-4"><a href="#" onclick="javascript:showPlainTxt('actionscript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-4">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EmbeddedJavaScriptExample <span style="color: #0066CC;">extends</span> Sprite</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// embed the JavaScript into the SWF</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"hello.js"</span>, mimeType=<span style="color: #ff0000;">"application/octet-stream"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create a class that can instantiate the JavaScript for embedding</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const HelloJS:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> EmbeddedJavaScriptExample<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>ExternalInterface.<span style="color: #006600;">available</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// embed the JavaScript to the page</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"eval"</span>, <span style="color: #000000; font-weight: bold;">new</span> HelloJS<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the embedded JavaScript has a function call named hello</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// now that it has been embedded to the page call it</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"hello"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You can <a href="http://www.kennybunch.com/blog/wp-content/uploads/2009/09/embeddedjavascriptexample.zip" onclick="javascript:pageTracker._trackPageview('/downloads/blog/wp-content/uploads/2009/09/embeddedjavascriptexample.zip');">download the full example here.</a></p>
<p>Pretty nifty eh? Hope this shows you a neat little trick to use in distributing some of your SWF/JS libraries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2009/09/embedding-javascript-into-a-swf/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Media Framework license and pricing changes</title>
		<link>http://www.kennybunch.com/blog/2009/04/media-framework-license-and-pricing-changes/</link>
		<comments>http://www.kennybunch.com/blog/2009/04/media-framework-license-and-pricing-changes/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 18:52:14 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=255</guid>
		<description><![CDATA[Today we introduced a new license and pricing model for the Dreamsocket Media Framework. 
The new license model:

$99   - Individual
$350 - Small Business (2 - 20 employees)
$895 - Midsize Business (21 -50 employees)
$1895 - Large Business (51+ employees)

To see all the details of the change and why we did it, check the post [...]]]></description>
			<content:encoded><![CDATA[<p>Today we introduced a <a href="http://dreamsocket.com/news/category/general/media-framework-license-and-price-changes" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://dreamsocket.com/news/category/general/media-framework-license-and-price-changes');">new license and pricing model</a> for the <a href="http://dreamsocket.com/products/actionscript-media-framework/overview" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://dreamsocket.com/products/actionscript-media-framework/overview');">Dreamsocket Media Framework</a>. </p>
<h2>The new license model:</h2>
<ul>
<li>$99   - Individual</li>
<li>$350 - Small Business (2 - 20 employees)</li>
<li>$895 - Midsize Business (21 -50 employees)</li>
<li>$1895 - Large Business (51+ employees)</li>
</ul>
<p>To see all the details of the change and why we did it, <a href="http://dreamsocket.com/news/category/general/media-framework-license-and-price-changes" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://dreamsocket.com/news/category/general/media-framework-license-and-price-changes');">check the post over on our site</a>.</p>
<p>If you haven't <a href="http://dreamsocket.com/products/actionscript-media-framework/overview" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://dreamsocket.com/products/actionscript-media-framework/overview');">checked out or grabbed your copy of the product</a>, now is a great time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2009/04/media-framework-license-and-pricing-changes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introducing the Dreamsocket Media Player</title>
		<link>http://www.kennybunch.com/blog/2009/03/introducing-the-dreamsocket-media-player/</link>
		<comments>http://www.kennybunch.com/blog/2009/03/introducing-the-dreamsocket-media-player/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 19:57:38 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=195</guid>
		<description><![CDATA[Today we released the first "face/player" to our framework today, which you are free to throw on your site and use yourself. Check out below, go read the article we wrote up about it, and download it for yourself today!

]]></description>
			<content:encoded><![CDATA[<p>Today we released the first "face/player" to our framework today, which you are free to throw on your site and use yourself. Check out below, go read <a href="https://dreamsocket.com/news/category/media-framework/introducing-dreamsocket-media-player" onclick="javascript:pageTracker._trackPageview('/outbound/article/https://dreamsocket.com/news/category/media-framework/introducing-dreamsocket-media-player');">the article we wrote up about it,</a> and <a href="http://dreamsocket.com/files/products/asmf/downloads/Dreamsocket_MediaPlayer.zip" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://dreamsocket.com/files/products/asmf/downloads/Dreamsocket_MediaPlayer.zip');">download it for yourself</a> today!</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="260"><param name="movie" value="http://dreamsocket.com/files/global/swf/mediaplayer.swf" /><param name="allowFullScreen" value="true" /><param name="FlashVars" value="file=http://examples.dreamsocket.com/asmf_site_example/test.flv&#038;image=http://examples.dreamsocket.com/asmf_site_example/poster.jpg"/><param name="bgcolor" value="#000000"><embed src="http://dreamsocket.com/files/global/swf/mediaplayer.swf" allowfullscreen="true" FlashVars="file=http://examples.dreamsocket.com/asmf_site_example/test.flv&#038;image=http://examples.dreamsocket.com/asmf_site_example/poster.jpg" bgcolor="#000000" quality="high" width="320" height="260" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2009/03/introducing-the-dreamsocket-media-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event type naming: qualifying vs simple</title>
		<link>http://www.kennybunch.com/blog/2009/02/event-type-naming-qualifying-vs-simple/</link>
		<comments>http://www.kennybunch.com/blog/2009/02/event-type-naming-qualifying-vs-simple/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 15:25:17 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=155</guid>
		<description><![CDATA[I have put a lot of thought into event naming recently.  In my research, I've seen a few developers fully qualifying their event type names. This is something I actually debated myself when writing our Media Framework, but opted not to do. The subject is debatable, so let me describe what I mean by [...]]]></description>
			<content:encoded><![CDATA[<p>I have put a lot of thought into <a href="http://www.kennybunch.com/blog/2009/01/event-type-naming/" >event naming recently</a>.  In my research, I've seen a few developers fully qualifying their event type names. This is something I actually debated myself when writing our <a href="http://dreamsocket.com/products/actionscript-media-framework/overview" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://dreamsocket.com/products/actionscript-media-framework/overview');">Media Framework</a>, but opted not to do. The subject is debatable, so let me describe what I mean by fully qualified names and why I decided not to use them. Based on the points I outline you can make your own decision of whether to use them yourself.</p>
<p><strong>What is a fully qualified event type name?</strong><br />
ActionScript 3 has a formal event framework where objects dispatch events and others subscribe to them and react accordingly. Each event dispatched is represented by an event object. All of the native AS3 event objects follow a formal convention of defining the types of events they can be dispatched as. This convention places a static constant representing the type name directly on their class to allow for <a href="/blog/2005/01/magic-strings-vs-strict-typing/">strict typing</a>. For example, Event.RESIZE denotes an event type of "resize" for the flash.events.Event object.  The property value itself equates to a simple string. In all native AS3 objects these strings are simple and only represent the action (ex: "resize").</p>
<p>Some programmers are actually fully qualifying these strings. Instead of Event.RESIZE representing the string "resize", it is equal to "flash.events.Event.RESIZE". Now why do this? Well say you had another event ComponentEvent which had a resize event. If you fully qualified it as well, you would have ComponentEvent.RESIZE equating to "com.dreamsocket.events.ComponentEvent.RESIZE". Notice that now both events could be thrown from the same object and subscribed to distinctly. If they both represented the string "resize" then you would run into cases where you thought you subscribed to one event but would potentially receive both.</p>
<p><strong>Why I chose not to use full qualifed names</strong><br />
Even though fully qualifying the string that represents the event type resolves subscription conflicts, for the most part you can resolve them just by prepending your event's name to the type. ComponentEvent.RESIZE could be "componentResize". In a sense this allows you to qualifying it without having a very long unique string. This is what I opted to do. One of the reasons I did this was for less advanced users and for code spiking. Simply, if you want to do things fast, it is easier just to type in a short magic string when listening to an event vs actually importing in the class and typing it out statically.</p>
<div class="igBar"><span id="lactionscript-7"><a href="#" onclick="javascript:showPlainTxt('actionscript-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-7">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">foo.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"componentResize"</span>, <span style="color: #0066CC;">this</span>.<span style="color: #006600;">onEvent</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
vs</p>
<div class="igBar"><span id="lactionscript-8"><a href="#" onclick="javascript:showPlainTxt('actionscript-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-8">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dreamsocket</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ComponentEvent</span>.<span style="color: #006600;">RESIZE</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">foo.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ComponentEvent.<span style="color: #006600;">RESIZE</span>, <span style="color: #0066CC;">this</span>.<span style="color: #006600;">onEvent</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Yes, this is kind of the lazy approach and one might also say its bad practice since without strict typing it could result in a "magic error". However, I do it when I'm trying to spike an idea real fast, and I know others do it as well. I'd even venture to say designer/developer hybrids are especially prone to use it since it serves as a comfort concept they brought over from ActionScript 2. It is a practice that exists and I can't say whether it is right or wrong.</p>
<p><strong>Summary</strong><br />
In summary, fully qualified event types have a purpose and serve their purpose well. In our case, we wanted to take into account developers who were used to exploiting existing conventions. I feel even bad habits have advantages if it creates productivity, so the coin toss resulted in a choice not to take them away.</p>
<p>What are your thoughts?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2009/02/event-type-naming-qualifying-vs-simple/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Importance of Event.clone</title>
		<link>http://www.kennybunch.com/blog/2009/01/importance-of-eventclone/</link>
		<comments>http://www.kennybunch.com/blog/2009/01/importance-of-eventclone/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 03:41:42 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=98</guid>
		<description><![CDATA[In Actionscript 3, the Event object has a method called clone.  This method does exactly what it says, it clones or duplicates the Event object, returning an entire new instance with the same values for all properties.   The importance of this method comes into play not when you call it directly, but when [...]]]></description>
			<content:encoded><![CDATA[<p>In Actionscript 3, the Event object has a method called clone.  This method does exactly what it says, it clones or duplicates the Event object, returning an entire new instance with the same values for all properties.   The importance of this method comes into play not when you call it directly, but when the player calls it behind the scenes. As stated in the docs,</p>
<blockquote><p>"When creating your own custom Event class, you must override the    inherited             <code>Event.clone()</code> method in order for it to duplicate the    properties of your custom class. If you do not set all the properties that you add    in your event subclass, those properties will not have the correct values when listeners    handle the redispatched event."</p></blockquote>
<p>After yesterday I feel like I don't pay attention well, because for some reason I was thinking that clone only got called by the player when bubbling an event in the display list. Yet as clear as it is stated in the docs, this occurs in non display objects which subscribe to an event, then redispatch it using their own dispatchEvent method.  In these cases, if you don't implement clone, then your custom event will cast to the base Event class and will not contain any of it's properties. This will in turn throw runtime errors.</p>
<p>I always implement the clone method in my Event sub classes, but somehow missed it in one and was wondering why it was casting to Event. Though it confused me for a minute, at least it opened my eyes to a simple concept I overlooked. Hopefully this post opens anyone else's who didn't realize the player's behavior with clone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2009/01/importance-of-eventclone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Event type naming: Tense</title>
		<link>http://www.kennybunch.com/blog/2009/01/event-type-naming/</link>
		<comments>http://www.kennybunch.com/blog/2009/01/event-type-naming/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 13:28:10 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=91</guid>
		<description><![CDATA[I tend to be a real stickler when it comes to naming elements of code that I know are going to be part of a widely used API. It's odd to me that there is not, or I have just not been privileged to find, a good resource on the subject.
Events are a programming paradigm [...]]]></description>
			<content:encoded><![CDATA[<p>I tend to be a real stickler when it comes to naming elements of code that I know are going to be part of a widely used API. It's odd to me that there is not, or I have just not been privileged to find, a good resource on the subject.</p>
<p>Events are a programming paradigm that exist in several different languages. However, even though the concept is exactly the same, the naming tends to differ in tense a lot. In many languages you see things with past tense like Closed versus Flash which has a present or transient tense like Close (Event.CLOSE).</p>
<p><em>Which is right? </em></p>
<p>Well neither is right or wrong, but I do believe one is better. If you take the example Close, there are actually different event states, Closing and Closed. By using just Close you have no idea of what state that truly represents.</p>
<p><em>What impact does this tense have?</em></p>
<p>If you look at the function that is creating the Close event, where does it emmit it? Is it at the top of the function or at the bottom? If the event is cancellable and that cancel has effects (like it stops executing the rest of the function), then tense is very important to know. For example, you may have a dialog closing, but if you haven't saved information in it yet you want to stop it from closing.  If it is ok to close, then you may want to allow it to close, but clean up information on close. In this case you want detailed information of the Event breakdown. The present tense Close does not denote that. Therefore, it is better to use Closing, which gives you the option of an additional Closed to represent the same event in a latter state. This holds true with all Event types.</p>
<p>There is a lot of power in just how you name things, so give it a little thought.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2009/01/event-type-naming/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Project: SonyBMG Viral Video Player</title>
		<link>http://www.kennybunch.com/blog/2007/07/project-sonybmg-viral-video-player/</link>
		<comments>http://www.kennybunch.com/blog/2007/07/project-sonybmg-viral-video-player/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 12:16:22 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=64</guid>
		<description><![CDATA[Has sexy been gone so long, that the idea of JT bringing it back is making you itch to tell everyone? Wait no longer my American Idol inspired friend, because now you can show them. That's right SHOW is the word, as SonyBMG has opened up their music video library for all to see and [...]]]></description>
			<content:encoded><![CDATA[<p>Has sexy been gone so long, that the idea of <a href="http://www.justintimberlake.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.justintimberlake.com');">JT</a> bringing it back is making you itch to tell everyone? Wait no longer my American Idol inspired friend, because now you can show them. That's right SHOW is the word, as SonyBMG has opened up their music video library for all to see and share. <a href="http://musicbox.sonybmg.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://musicbox.sonybmg.com');">MusicBox</a> is the name of the game and the site has a plethora of music content with a nice community wrapper over top of it to boot.</p>
<p>For those in the know, <a href="http://musicbox.sonybmg.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://musicbox.sonybmg.com');">MusicBox</a> didn't just launch yesterday. Instead it has been evolving over this past year. Being the lucky lad that I am, I have been fortunate enough to be involved with it. So why all the fuss over something that has been around for longer than a month? Well we just brought sexy back to the video player.</p>
<div style="width: 424px;"><object id="sonybmg_viralplayer_1103" width="425" height="350"><param name="allowFullScreen" value="true"></param><param name="movie" value="http://musicbox.sonybmg.com/share/widgets/viral"></param><param name="FlashVars" value="id=1103"><embed name="sonybmg_viralplayer_1103" src="http://musicbox.sonybmg.com/share/widgets/viral" type="application/x-shockwave-flash" flashvars="id=1103" allowfullscreen="true" width="425" height="350"></embed></param></object>
<div style="text-align: right; background: #000; font-size: 11px;">
<div style = "padding: 3px 6px 3px 6px;">
<div style = "float: left;"><a href="http://www.justintimberlake.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.justintimberlake.com');" style="font-family: Verdana, Arial; text-decoration:none; color: #FFF">Artist Site</a></div>
<p><a href="http://musicbox.sonybmg.com/justin_timberlake" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://musicbox.sonybmg.com/justin_timberlake');" style="font-family: Verdana, Arial; text-decoration:none; color: #FFF">More Videos</a></div>
</div>
</div>
<p>That's right as you can see above, SonyBMG has a sexy new viral video player to play that "Sexy Back", brought to you by yours truly.  The distribution code is all over the MusicBox site waiting to be grabbed.</p>
<p>For my fellow nerds who are curious on the tech side of things, the player is a custom interface wrapped over top of the embeddable Brightcove template.  If you want to make your own custom BC viral player, the embeddable template is only available for higher end Brightcove accounts. However, if you have access to that template, and you are wanting to get your sexy on as well, below are a few pointers to save some headaches:</p>
<ul>
<li>don't use the APIs to set settings, instead all settings can be set up front when loading the BC module using config values.</li>
<li>want the pesky menu to disappear? set the useOverlayMenu config value to false</li>
<li>with a viral player, BC loves Javascript and sites hate it.  set the config disableJavascriptAPI to true, call System.security.allowDomain("*");, and if you are aiming for MySpace set the config domain to embed.</li>
<li> using streaming media, call {player_instance_here}.base.mWorkArea.layout.mPlayer_mp.mContentCompleted = false; in your media start events, which will ensure that mediaComplete event gets called.</li>
</ul>
<p>All of the above are simple actions, but if you don't know them you'll be searching the docs and scratching your head wondering why things don't work. On that note, good luck to the nerds and happy sharing to my pop loving buddies.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2007/07/project-sonybmg-viral-video-player/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flash CS3 List.addItem selection BUG</title>
		<link>http://www.kennybunch.com/blog/2007/07/flash-cs3-listadditem-selection-bug/</link>
		<comments>http://www.kennybunch.com/blog/2007/07/flash-cs3-listadditem-selection-bug/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 20:12:21 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=61</guid>
		<description><![CDATA[The new Flash CS3 components took a giant leap forward in usability and functionality by simplifying their internals.  However, in the process of doing a rewrite, they didn't do a good job on unit testing. If you add an item to the List component or it's dataProvider, you will see a nice little glitch. [...]]]></description>
			<content:encoded><![CDATA[<p>The new Flash CS3 components took a giant leap forward in usability and functionality by simplifying their internals.  However, in the process of doing a rewrite, they didn't do a good job on unit testing. If you add an item to the List component or it's dataProvider, you will see a nice little glitch. Adding an item causes the selection to be incorrect, because the selection isn't being shifted correctly.</p>
<p>The culprit to the issue is in the function handleDataChange in fl.controls.SelectableList.as. The update to the index for the DataChangeType.ADD conditional in this function is incorrect. <br />
Instead of<br />
<em>   _selectedIndices[i] += startIndex-endIndex;</em><br />
it should be<br />
<em>  _selectedIndices[i] += startIndex-endIndex + 1;</em></p>
<p>As you can see it's a simple change, but a nasty bug if it hits your application. Grant and his team were brilliant with their execution, however QA should have hit it a little harder.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2007/07/flash-cs3-listadditem-selection-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Project: Adult Swim Video 2.0</title>
		<link>http://www.kennybunch.com/blog/2007/07/project-adult-swim-video-20/</link>
		<comments>http://www.kennybunch.com/blog/2007/07/project-adult-swim-video-20/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 17:01:21 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=60</guid>
		<description><![CDATA[Last month we relaunched Adult Swim's video gallery application and brought it up to the to cool for school 2.0 status. For those not in the know, the first release was just a reskin of the Cartoon release and the point release after that was an update from Windows Media to Flash video. This new [...]]]></description>
			<content:encoded><![CDATA[<p>Last month we relaunched <a href="http://www.adultswim.com/video" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.adultswim.com/video');">Adult Swim's video gallery application</a> and brought it up to the to cool for school 2.0 status. For those not in the know, the first release was just a reskin of the <a href="http://www.cartoonnetwork.com/video" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.cartoonnetwork.com/video');">Cartoon release</a> and the point release after that was an update from Windows Media to Flash video. This new release is a reskin, relayout, and interaction change.</p>
<p><strong>Layout Choice</strong><br />
So why the new layout? Well if you look at the app, it's very apparent that it resembles a YouTube layout. This was done because the layout provided advantages over the existing layout. For starters it uses a common interaction model that users are familiar with, so it automatically yields ease of use based on that notion alone. YouTube also does a good job of separating out functions of browse, search, and view. Typically most of the Flash video apps tie these functions together. For example, the Cartoon player has video as the main focus but always maintains a consistent navigation. In this model you have limited room for the current video's details and browsing. By separating and opening it up in the way that YouTube does, the browse and search sections are a lot larger and the amount of content is more apparent. In addition, subsections and filters can be listed out beneath sections in context which allow for quick jumping. For example, the navigation options Comedy, Robot Chicken, and Most Viewed are available all at the same time. In the previous model, this required navigating between screens. Keeping search as a consistent function also provides for quicker jump points, since it is always present. Just like the browse perspective, the video perspective has more space to focus on everything that defines a video. It seems a little bare now, but you can imagine that there are a lot of elements you can attach to a video. By design this setup allows for that. All in all the new layout provides a more focused experience.</p>
<p><strong>Flash vs HTML</strong><br />
Ok great layout, but why is it all in Flash and not HTML like YouTube? Good question and there are a few reasons. One of the main reasons is the nature of Adult Swim's servers and deployment. For the most part, everything is statically deployed pages vs dynamically deployed pages. Most of their service based offerings are just that, services. In the case of video, the system was already deployed as a service based system. Although we did updates to the system, it is the exact same system and can be used for multiple frontend clients. In this case, the main task was simply modifying the client. Since I handled the entire client and it took me a relatively short time to update, time to market was minimal. Thus time and existing systems were a factor. On the other side of the foot, you have interaction models. Having the application in Flash allowed us to create a unified experience. Unlike YouTube, viewing and browsing aren't completely broken. When switching in between tasks, you are able to continue viewing while browsing. This type of unification is also seen in browsing, where page to page navigation doesn't require a page refresh. With all that said, the application does suffer from the fact that it doesn't offer browser history navigation using the previous and back buttons, defined urls in the browser for deeplinking, and indexable content. It suffers now, but I have solutions that don't require many changes which may be integrated in the near future <img src='http://www.kennybunch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p><strong>New Features</strong><br />
You are thinking lovely this is a great new layout, but does it do anything new other than look fabulously cool? How about the new sorting features Chuck? Now you can actually sort your video results by most viewed, most popular, most hated, and most recent.  Even better, you can apply these sorts to the entire video collection. Yes, you can browse or search the entire collection. This is unlike the previous version which only allowed you to browse per section. More control over choosing what you want to view is always a good thing and control over the content itself can be even better. Well we updated it to be like YouTube and added one of YouTube's most successful features.  Oh buddy that's right, we got viral. Now you can find a clip that you want and post it to your blog. Free AS content for the taking! That said, there is a constraint. Currently full episodes aren't shareable. This is primarily due to the fact that networks posting content online are only allowed to maintain specific amounts of content at a any given time. There are many restrictions placed on them by their cable and content creator relationships, and this is one of them. It is unfortunate, but I think I have a few solutions up my sleeve that can address these constraints.</p>
<p><strong>Future changes</strong><br />
Love the new features, but are you wanting more or feel like something was taken away? My biggest gripe with the player is that we can't go true fullscreen right now. This happened with the point release from Windows Media to Flash. The reason is that the companion image ad for videos is in HTML (even though it appears to be part of the Flash movie).  Having the ad this way requires changing the WMode of Flash to render correctly and ties the renderer to the browser.  This restriction makes going fullscreen technically impossible. We are taking steps to change this and provide a true fullscreen experience. If you are viewing a show you want to be able VIEW the show! The other changes would be related to things I hinted to before. I'd like to provide a means of sharing episodes, allowing browser history browsing and deeplinking, indexing the content, and opening up the things that you can "view and do" in relation a video. Regardless of what I want to do, comment in on what you think and what you might want to do.  In the meantime, check out some great <a href="http://www.adultswim.com/video/?section=Comedy&#038;collectionID=8a25c3920eaf5fa6010eaffb99c438bf" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.adultswim.com/video/?section=Comedy&#038;collectionID=8a25c3920eaf5fa6010eaffb99c438bf');">LEGAL Family Guy clips</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2007/07/project-adult-swim-video-20/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Project: CNN Image Gallery</title>
		<link>http://www.kennybunch.com/blog/2007/07/project-cnn-image-gallery/</link>
		<comments>http://www.kennybunch.com/blog/2007/07/project-cnn-image-gallery/#comments</comments>
		<pubDate>Tue, 10 Jul 2007 20:31:49 +0000</pubDate>
		<dc:creator>Kenny Bunch</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.kennybunch.com/blog/?p=58</guid>
		<description><![CDATA[A few weeks ago, CNN launched their spiffy new site which I was fortunate enough to have my hands dirtied from. I'll save my comments for the redesign for another post, but wanted to point out the image gallery I worked on.
Details about the gallery
generic and allows setting any gallery feed on embed
allows deeplinking to [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, CNN launched their spiffy new site which I was fortunate enough to have my hands dirtied from. I'll save my comments for the redesign for another post, but wanted to point out the <a href="http://www.cnn.com/2007/WORLD/asiapcf/07/10/pakistan.mosque/index.html#cnnSTCPhoto" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.cnn.com/2007/WORLD/asiapcf/07/10/pakistan.mosque/index.html#cnnSTCPhoto');">image gallery I worked on</a>.</p>
<p><strong>Details about the gallery</strong></p>
<li>generic and allows setting any gallery feed on embed</li>
<li>allows deeplinking to specific images on embed</li>
<li>allows navigating to specific images from javascript</li>
<li>allows changing gallery feed via javascript</li>
<li>tracks image clicks</li>
<li>tracks gallery loads</li>
<li>allows emailing of gallery</li>
<p></p>
<p>Overall the experience with the gallery is pretty smooth. However, because it is competing with a bunch of other processes on the page, you can visually see the lag it is experiencing (via captions hide/reveal animation).</p>
<p>For those with a bit of Flash community knowledge the new image gallery has a <a href="http://www.slideshowpro.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.slideshowpro.com');">pretty familiar look</a>.  One might even venture to think that the module is indeed what it appears to be, <a href="http://www.slideshowpro.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.slideshowpro.com');">SlideShow Pro</a>.  However, you would be wrong. Despite it's drastically similar resemblance, it is a ground up custom write. Should it have been? Thats a good question. My first response when I saw the design firm's mocks were, go get <a href="http://www.slideshowpro.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.slideshowpro.com');">SlideShow Pro</a>. I even pointed them to <a href="http://www.whatdoiknow.org" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.whatdoiknow.org');">Todd</a> and told him about it (since he was still at Turner). It was obvious they had used it as a model, so why not just customize it, right?</p>
<p>Well in the case of CNN, they wanted control. Control over the UI, control over the effects, control over the data, control over the internals, control over events, and basically the control to modify everything and anything to do with the module. I granted their wish and did a ground up write, which took little time.  It was a clean implementation that did only what they asked and was fine tuned to their needs. It was the details that you don't see that made the custom write the correct decision, and in the end I agree with their choice.</p>
<p>With all that said, I think it is a compliment to Todd that they followed his design. Though it made me feel odd with the project being so close his work, it points out the validity of his component. If CNN mirrors SlideShowPro, then that should tell you the component rocks. I wasn't able to use it here, but I highly recommend it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennybunch.com/blog/2007/07/project-cnn-image-gallery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
