<?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/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Streamhead &#187; Flash and ActionScript</title>
	<atom:link href="http://www.streamhead.com/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.streamhead.com</link>
	<description>multimedia webapplication thoughts and experiments</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:58:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Recreating the Ticket to Ride Game in ActionScript 3</title>
		<link>http://www.streamhead.com/actionscript-3-ticket-to-ride/</link>
		<comments>http://www.streamhead.com/actionscript-3-ticket-to-ride/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 14:00:47 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=3148</guid>
		<description><![CDATA[Creating an ActionScript 3 game: it&#8217;s all fun and games until it actually has to work. Over the last 3 weeks, I&#8217;ve been trying to recreate Ticket to Ride, one of my favorite board games, in Flash. It&#8217;s been a voyage of triumphs and, ultimately, defeat. In this article, I&#8217;d like to share the code [...]]]></description>
			<content:encoded><![CDATA[<img width="300" height="250" src="http://www.streamhead.com/wp-content/uploads/2011/04/license-to-journey.jpg" class="attachment-post-thumbnail wp-post-image" alt="license-to-journey" title="license-to-journey" /><blockquote><p>Creating an ActionScript 3 game: it&#8217;s all fun and games until it actually has to work.</p></blockquote>
<p>Over the last 3 weeks, I&#8217;ve been trying to recreate Ticket to Ride, one of my favorite board games, in Flash. It&#8217;s been a voyage of triumphs and, ultimately, defeat. In this article, I&#8217;d like to share the code and my experiences with ActionScript 3.</p>
<p><span id="more-3148"></span>If one is talking about creating a casual online game, there isn&#8217;t much discussion. ActionScript is the language. The most obvious reason is that it compiles to Flash, which runs on any desktop PC in the world and on many mobile devices. iPhone/iPad being the sole major exception, although even that is changing.</p>
<p>I wanted to figure out whether there were other reasons to use ActionScript. And I did find some. <a title="Github License to Journey, a Ticket to Ride clone" href="https://github.com/pbackx/License-to-Journey" target="_blank">But first, let me give you the code. It&#8217;s far from perfect, but you&#8217;re free to extend on it.</a></p>
<p>What I really liked about ActionScript was the <strong>impressive speed</strong> with which you can <strong>build graphical interfaces</strong>. It&#8217;s very clear that this language is focused on building graphical applications. It was designed for it and you feel that in every possible way. Although the interface of my game isn&#8217;t very advanced, it also didn&#8217;t take any time to program. It just grew out of the way I structured the code.</p>
<p>What I didn&#8217;t like too much was the <strong>absence of more advanced data structures</strong> and ways to process them. It felt pretty awkward to have static typing for everything but the collection types. The contents of those is all dynamically typed. Compare it to Java before generics. Furthermore, I really missed a lot of the more advanced collection operation that a language like Python has.</p>
<p>Overall, I worked about 10 to 12 hours on this game in FlashDevelop. It was a great and motivating experience on the GUI side, but frustrating for the back-end code. In the end, I just couldn&#8217;t convince myself to push on and finish the scoring system for the game. Which is the only thing that&#8217;s really missing. That and much error handling.</p>
<p>I might come back to it later, until then, <a title="License to Journey, inspired by Ticket to Ride" href="https://github.com/pbackx/License-to-Journey" target="_blank">here&#8217;s the code. Have fun with it!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/actionscript-3-ticket-to-ride/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2011/04/license-to-journey.jpg" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2011/04/license-to-journey.jpg" medium="image">
			<media:title type="html">license-to-journey</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2011/04/license-to-journey.jpg" medium="image">
			<media:title type="html">license-to-journey</media:title>
		</media:content>
	</item>
		<item>
		<title>Three Ways to Trace in ActionScript 3</title>
		<link>http://www.streamhead.com/tracing-actionscript/</link>
		<comments>http://www.streamhead.com/tracing-actionscript/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 14:00:25 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=2864</guid>
		<description><![CDATA[It&#8217;s been a while since I mentioned the all important discipline of tracing in ActionScript to get an inside look at what your application is doing. Getting feedback from your program at important points can mean the difference between hours of debugging and a quick analysis of the issue at hand. Previously there was the [...]]]></description>
			<content:encoded><![CDATA[<img width="300" height="250" src="http://www.streamhead.com/wp-content/uploads/2010/12/actionscript_tracing.png" class="attachment-post-thumbnail wp-post-image" alt="actionscript_tracing" title="actionscript_tracing" /><p>It&#8217;s been a while since I mentioned the all important discipline of tracing in ActionScript to get an inside look at what your application is doing. Getting feedback from your program at important points can mean the difference between hours of debugging and a quick analysis of the issue at hand. <a title="Quick tip: ActionScript trace statement" href="http://www.streamhead.com/quick-tip-actionscript-trace-statements/" target="_blank">Previously there was the FDTracer plugin</a>, but this is no longer needed. There are actually three much better ways that suite different situations.</p>
<p><span id="more-2864"></span>Outputting information to a debug log can help you tremendously when struggling with annoying problems. Depending on the situation, there are a few options you can try out.</p>
<p><a title="ActionScript tracing FlashDevelop example project" href="http://www.streamhead.com/wp-content/uploads/2010/12/ASTracing.zip" target="_blank">You might want to follow along in this FlashDevelop project</a>.</p>
<h2>Plain old trace()</h2>
<p>ActionScript  already has a trace statement. It&#8217;s probably not so well known because you need to have the right Flash player for this to work. You either need to use the standalone player or the debug player. If you&#8217;ve <a title="Setting up FlashDevelop to embed images" href="http://www.streamhead.com/embedding-images/" target="_blank">installed FlashDevelop correctly</a>, you should be fine. Keep in mind that an automatic Flash upgrade might have replaced your manually installed debug vesion.</p>
<h2>FlashDevelop&#8217;s FlashConnect</h2>
<p>If you&#8217;re developing with FlashDevelop, you can also use the build-in org.flashdevelop.utils.FlashConnect. The FlashConnect.trace directive connects to your running FlashDevelop instance and sends trace information directly to the console. If you have a Flash debug player installed this looks exactly like the previous statement.</p>
<p>It is useful if you don&#8217;t have a debug player, because it will work with any Flash player.</p>
<h2>Firebug tracing</h2>
<p>Both of the above options won&#8217;t be very handy when you are developing for the web. You can try to <a title="Flash log file" href="http://livedocs.adobe.com/flex/3/html/help.html?content=logging_04.html" target="_blank">find your Flash log file</a>, but wouldn&#8217;t is be much easier to see trace information directly in our favorite web debugging tool, Firebug?</p>
<p>It&#8217;s actually possible and fairly easy to get trace output to Firebug:</p>

<div class="wp_codebox"><table><tr id="p28642"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2864code2"><pre class="actionscript" style="font-family:monospace;">ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;console.log&quot;</span>, <span style="color: #ff0000;">&quot;tracing in firebug&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>That&#8217;s all there is to it. Keep in mind that, due to security restrictions, this will only work when you deploy the Flash file to a remote server and use swfobject.js to start the program. FlashDevelop creates this configuration by default for you.</p>
<p><a title="ActionScript tracing FlashDevelop example project" href="../wp-content/uploads/2010/12/ASTracing.zip" target="_blank">FlashDevelop example project<br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/tracing-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/12/actionscript_tracing.png" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/12/actionscript_tracing.png" medium="image">
			<media:title type="html">actionscript_tracing</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/12/actionscript_tracing.png" medium="image">
			<media:title type="html">actionscript_tracing</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorial: FlashDevelop and Papervision3D, the Basics</title>
		<link>http://www.streamhead.com/tutorial-flashdevelop-and-papervision3d-the-basics/</link>
		<comments>http://www.streamhead.com/tutorial-flashdevelop-and-papervision3d-the-basics/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 08:00:44 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=2773</guid>
		<description><![CDATA[It&#8217;s been a while since I indulged in my Flash and 3D hobby. I&#8217;ve been a longtime Sandy 3D fan, but it was about time I tried the competition. This post gives a short overview of how to set up FlashDevelop to run your first Papervision3D application. Before you get started, you&#8217;ll need a few [...]]]></description>
			<content:encoded><![CDATA[<img width="300" height="250" src="http://www.streamhead.com/wp-content/uploads/2010/11/FlashDevelop_Papervision3D_tutorial.png" class="attachment-post-thumbnail wp-post-image" alt="Tutorial: FlashDevelop and Papervision3D" title="FlashDevelop_Papervision3D_tutorial" /><p>It&#8217;s been a while since I <a title="Flash and ActionScript Game Engines" href="http://www.streamhead.com/flash-actionscript-game-engines/" target="_blank">indulged in my Flash and 3D hobby</a>. I&#8217;ve been a longtime Sandy 3D fan, but it was about time I tried the competition. This post gives a short overview of how to set up FlashDevelop to run your first <a title="Papervision3D" href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> application.</p>
<p><span id="more-2773"></span>Before you get started, you&#8217;ll need a few essential tools:</p>
<ul>
<li>I&#8217;ll use <a title="TortoiseSVN downloads" href="http://tortoisesvn.net/downloads" target="_blank">TortoiseSVN</a> (or any other SVN client) to get the latest version of Papervision3D. You can download a zip file of the current version, but setting this up once will make it a lot easier to follow all the latest development.</li>
<li>I like <a title="FlashDevelop" href="http://www.flashdevelop.org/wikidocs/index.php?title=Main_Page" target="_blank">FlashDevelop</a> because it&#8217;s free and it has everything an IDE needs. I&#8217;m going to assume you&#8217;ve gone through the setup process and have configured FlashDevelop to use ActionScript 3 with the Flex SDK. This is also entirely free of charge and <a title="Installing the Flex SDK" href="http://www.flashdevelop.org/wikidocs/index.php?title=AS3#Installing_the_Flex_SDK" target="_blank">isn&#8217;t as much work as you might think</a>.</li>
</ul>
<h2>Getting the Papervision3D code</h2>
<p>Start of by creating a directory where you want to put the Papervision3D distribution. This won&#8217;t be your project directory because the distribution also contains the API documents and some examples.</p>
<p>In this directory right click and choose &#8220;SVN Checkout &#8230;&#8221; (adapt this to your system and SVN client) and enter the Papervision3D repository URL, which is <a title="Papervision3D SVN repository" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/" target="_blank">http://papervision3d.googlecode.com/svn/trunk/as3/trunk/</a>. Choose &#8220;Fully recursive&#8221; if it isn&#8217;t already selected and click ok.</p>
<p>After a while you&#8217;ll have the distribution on your PC. It&#8217;ll contain a few directories, most importantly &#8220;src&#8221; containing the actual Papervision3D library.</p>
<h2>Setting up a Papervision3D project in FlashDevelop</h2>
<p>No we&#8217;re ready to start a FD project. Open FlashDevelop and create a new AS3 Project. Put it in a different location than where you previously check out the Papervision3D distribution in order to avoid conflicts.</p>
<p>FlashDevelop will set up the project and create a &#8220;src&#8221; directory. It will also create an initial Main.as Flash application, but we&#8217;ll be replacing that in the next steps.</p>
<p>Copy the Papervision3D code into the src directory. Go into the src directory of the Papervision3D distribution and copy both directories (&#8220;nochump&#8221; and &#8220;org&#8221;) into the src directory of the FlashDevelop project.</p>
<p>Your workspace is ready.</p>
<h2>Running the MeshCutting example</h2>
<p>Papervision3D comes with a few examples, most of them require you to set up external resources, but not the MeshCutting example.</p>
<p>You&#8217;ll find it in the &#8220;examples/FlexSDK/MeshCutting&#8221; directory of the Papervision3D distribution.</p>
<p>Copy the files in the &#8220;examples/FlexSDK/MeshCutting/src&#8221; to your project&#8217;s &#8220;src&#8221; directory. Make sure you replace the Main.as.</p>
<p>That should do it. Run the FlashDevelop project and you&#8217;ll be looking at this (animated):</p>
<p><a href="http://www.streamhead.com/wp-content/uploads/2010/11/Papervision3D_mesh_cutting_example.png"><img class="alignnone size-medium wp-image-2788" title="Papervision3D_mesh_cutting_example" src="http://www.streamhead.com/wp-content/uploads/2010/11/Papervision3D_mesh_cutting_example-300x241.png" alt="Papervision3D mesh cutting example" width="300" height="241" /></a></p>
<p>And now the real work starts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/tutorial-flashdevelop-and-papervision3d-the-basics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/11/FlashDevelop_Papervision3D_tutorial.png" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/11/FlashDevelop_Papervision3D_tutorial.png" medium="image">
			<media:title type="html">FlashDevelop_Papervision3D_tutorial</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/11/FlashDevelop_Papervision3D_tutorial.png" medium="image">
			<media:title type="html">FlashDevelop_Papervision3D_tutorial</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/11/Papervision3D_mesh_cutting_example.png" medium="image">
			<media:title type="html">Papervision3D_mesh_cutting_example</media:title>
			<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/11/Papervision3D_mesh_cutting_example-300x250.png" />
		</media:content>
	</item>
		<item>
		<title>Embedding Bitmap Images in ActionScript 3 with FlashDevelop</title>
		<link>http://www.streamhead.com/embedding-images/</link>
		<comments>http://www.streamhead.com/embedding-images/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 08:00:32 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=2516</guid>
		<description><![CDATA[ActionScript is probably one of the easiest languages to program visual effects. It has a wealth of APIs to manipulate images in all kinds of different ways. However, getting images into your program isn&#8217;t all that well documented. Especially if you are not working with Adobe&#8217;s commercial Flash products. For instance, the wonderful and free [...]]]></description>
			<content:encoded><![CDATA[<img width="300" height="250" src="http://www.streamhead.com/wp-content/uploads/2010/08/embed_actionscript.png" class="attachment-post-thumbnail wp-post-image" alt="embed_actionscript" title="embed_actionscript" /><p>ActionScript is probably one of the easiest languages to program visual effects. It has a wealth of APIs to manipulate images in all kinds of different ways. However, getting images into your program isn&#8217;t all that well documented. Especially if you are not working with Adobe&#8217;s commercial Flash products. For instance, the wonderful and free FlashDevelop. This article shows how to use the &#8220;embed&#8221; tag to embed images inside your Flash applet, which is one of the cleanest ways you can add those bitmaps to your application.</p>
<p><span id="more-2516"></span></p>
<p>This article is based on <a href="http://www.flashdevelop.org/community/viewtopic.php?f=11&amp;t=6956">FlashDevelop 3.2.2 RTM</a> but will probably work with almost any FlashDevelop version. It is an updated, rewritten and more focused version of <a href="../how-to-use-images-in-actionscript-3-with-flashdevelop-and-some-other-as3-tips">this article</a>, published back in May 2008. In this tutorial I&#8217;ll show you how to get started with FlashDevelop, embed a bitmap and show it on screen.</p>
<h2>Setup your system</h2>
<p>Before you get started with this tutorial, you should make sure that you have configured FlashDevelop as explained in the <a href="http://www.flashdevelop.org/wikidocs/index.php?title=Getting_Started">FlashDevelop getting started guide</a>. When the debug players are installed (I went with version 10.1), choose <a href="http://www.flashdevelop.org/wikidocs/index.php?title=AS3">the ActionScript 3 option</a> at the bottom of the page and install <a href="http://opensource.adobe.com/wiki/display/flexsdk/Downloads">the free Flex SDK</a> (I picked the free Adobe Flex 4 SDK).</p>
<h2>Creating a project</h2>
<p>With FlashDevelop installed and configured, the next step is creating a new project:</p>
<ul>
<li>Project &gt; New Project</li>
<li>We&#8217;re going to write an ActionScript 3 application, so pick AS3 Project</li>
<li>At the bottom of the dialog, enter a name and a location. It doesn&#8217;t really matter what you enter here, just choose something that suits you.</li>
<li>I left the package blank, which creates files in the default package.</li>
<li>OK</li>
</ul>
<p>You should see your project structure on the right. Now open the &#8220;src&#8221; folder and double-click Main.as. This should open the file. If you test the movie (the blue arrow triangle in the top bar, just to the left of the &#8220;debug&#8221; dropdown), you&#8217;ll probably see an error in the output pane (bottom): &#8220;No application is associated with the specified file for this operation&#8221;.</p>
<div>Go back to the project window on the right (I had to click on the little tab at the bottom)</div>
<div>
<ul>
<li>Right click on your projects top folder.</li>
<li>Choose &#8220;Properties&#8230;&#8221;</li>
<li>At the bottom, in the &#8220;Test Movie&#8221; dropdown, pick &#8220;Play in new tab&#8221; (this is my preferred method, feel free to experiment with the others)</li>
</ul>
<p>After clicking ok and rerunning the test (blue triangle), a new tab should open which displays absolutely nothing. That&#8217;s fine though, it means everything is working. Close the tab and we&#8217;ll get started on the program.</p>
</div>
<h2>Embedding an image</h2>
<div>Now it&#8217;s time to get to the gist of the tutorial, actually embedding the image. If you look at your project structure, you&#8217;ll also see that FlashDevelop has created a &#8220;lib&#8221; folder, this is where we&#8217;re going to put the images we use in the program.</div>
<div>First, find an image somewhere on the Internet and put it in that lib folder. If it shows up on the project view in FlashDevelop, you did it correctly.</div>
<div>The final step before we can use the image is to add it to the library: right click on the image in the project view and choose &#8220;Add to library&#8221;. If everything goes well, it will now display in blue instead of black.</div>
<div>With the Main.as file open:</div>
<div>
<ul>
<li>Put the cursor somewhere just above the &#8220;function Main()&#8221; declaration</li>
<li>Right click on the image you want to embed and choose &#8220;Insert Into Document&#8221;</li>
<li>An &#8220;Embed&#8221; code should have appeared.</li>
<li>Just underneath this new line, add the variable declaration for this image.</li>
</ul>
<pre>private var layer0Class : Class;</pre>
<ul>
<li>On the next line, instantiate the class, so that we can use it:</li>
</ul>
<pre>private var layer0:Bitmap = new layer0Class();</pre>
<ul>
<li>If you type this, you will see a FlashDevelop popup when you start typing Bitmap. As soon as you see this, you can select the class you need, which is &#8220;flash.display.Bitmap&#8221;. This will also import that class.</li>
<li>If that didn&#8217;t happen, you will need to manually add the import. Right at the top of the file, where there are two import statements, add:</li>
</ul>
<pre>import flash.display.Bitmap;</pre>
<h2>Displaying the bitmap</h2>
</div>
<div>Now comes the easiest part:</div>
<div>
<ul>
<li>Find the function where it says &#8220;// entry point&#8221; (feel free to remove this line as it is not functional)</li>
<li>Just underneath that line add</li>
</ul>
<pre>addChild(layer0);</pre>
<div>You should now have the following program:</div>
</div>

<div class="wp_codebox"><table><tr id="p25165"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p2516code5"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</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;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite 
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source = <span style="color: #ff0000;">'../lib/Parallax-scroll-example-layer-0.gif'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> layer0Class:<span style="color: #000000; font-weight: bold;">Class</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> layer0:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> layer0Class<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span><span style="color: #66cc66;">&#41;</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">else</span> addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, init<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			removeEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, init<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			addChild<span style="color: #66cc66;">&#40;</span>layer0<span style="color: #66cc66;">&#41;</span>;			
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>	
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>If you test the movie again, the image should show up. You&#8217;ve just embedded and instantiated your first bitmap in ActionScript.</p>
<div>With this knowledge and some very basic ActionScript 3 programming experience, you can already create some nice effects, such as <a href="http://en.wikipedia.org/wiki/Parallax_scrolling">this parallax scrolling</a> example:</div>
<p><object type="application/x-shockwave-flash" data="http://www.streamhead.com/examples/embedtutorial/embedtutorial.swf" width="320" height="200" class="embedflash"><param name="movie" value="http://www.streamhead.com/examples/embedtutorial/embedtutorial.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><small>(Please open the article to see the flash file or player.)</small></object></p>
<p><a title="Parallax Scrolling AS3" href="http://github.com/pbackx/ParallaxScrollingAS3" target="_blank">You can find the full source and project files on GitHub</a>.</p>
<p>(<a href="http://www.flickr.com/photos/liamngls/413522957/">Image credit</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/embedding-images/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/08/embed_actionscript.png" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/08/embed_actionscript.png" medium="image">
			<media:title type="html">embed_actionscript</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/08/embed_actionscript.png" medium="image">
			<media:title type="html">embed_actionscript</media:title>
		</media:content>
	</item>
		<item>
		<title>Flash and ActionScript Game Engines</title>
		<link>http://www.streamhead.com/flash-actionscript-game-engines/</link>
		<comments>http://www.streamhead.com/flash-actionscript-game-engines/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 08:00:36 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flashdevelop]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=2194</guid>
		<description><![CDATA[There are many resources to get you started with game programming in ActionScript. Many articles and tutorials will discuss the basics, but if you really want a quick start, a game engine is a great help. This post lists a number of interesting options. Game engines come in many flavors, some offer you just a [...]]]></description>
			<content:encoded><![CDATA[<img width="300" height="250" src="http://www.streamhead.com/wp-content/uploads/2010/04/the_kings_game.png" class="attachment-post-thumbnail wp-post-image" alt="the_kings_game" title="the_kings_game" /><p>There are many resources to get you started with <a title="13 Resources to Get Started in Game Programming" href="http://www.streamhead.com/13-game-programming-links/" target="_blank">game programming</a> in ActionScript. Many articles and tutorials will discuss the basics, but if you really want a quick start, a game engine is a great help. This post lists a number of interesting options.</p>
<p><span id="more-2194"></span>Game engines come in many flavors, some offer you just a framework for showing 3D images, others almost don&#8217;t require any programming at all. Here are some of my favorite ones.</p>
<p><a title="Yogurt3D" href="http://www.yogurt3d.com/" target="_blank">Yogurt3D</a></p>
<p><a href="http://www.yogurt3d.com/"><img class="alignnone size-full wp-image-2339" title="yogurt3d" src="http://www.streamhead.com/wp-content/uploads/2010/04/yogurt3d.png" alt="" width="498" height="90" /></a></p>
<p>If you want to create a 3D Flash game, you could start with one of the 3 major 3D engines (<a title="Sandy 3D Tutorial" href="http://www.streamhead.com/sandy-3d-tutorial/" target="_blank">Sandy</a>, <a title="Papervision3D and physics" href="http://www.streamhead.com/obsession-flash-physics-3d/" target="_blank">Papervision</a>, Away) But if you want even more help, there&#8217;s Yogurt3D. While the others are more general 3D engines, Yogurt3D is directly aimed at 3D game development. It has higher level constructs, like animation, to support game development. My main gripe is the lack of documentation. There is a pretty extensive tutorial, but that&#8217;s about it. There&#8217;s no forum, so you&#8217;re going to have to Google a bit (but there seems to be quite a few articles around).</p>
<p><a title="FFilmation" href="http://www.ffilmation.org/website/" target="_blank">FFilmation</a></p>
<p><a href="http://www.ffilmation.org/website/"><img class="alignnone size-full wp-image-2341" title="ffilmation" src="http://www.streamhead.com/wp-content/uploads/2010/04/ffilmation.png" alt="" width="385" height="79" /></a></p>
<p>An isometric engine. If you like the style, you&#8217;re going to love this engine. Again, the documentation is lacking, but there&#8217;s a great demo that might convince you to give this engine a try.</p>
<p><a title="Flixel" href="http://flixel.org/" target="_blank">Flixel</a></p>
<p><a href="http://flixel.org/"><img class="alignnone size-full wp-image-2343" title="flixel" src="http://www.streamhead.com/wp-content/uploads/2010/04/flixel.png" alt="" width="498" height="85" /></a></p>
<p>This is the way to go if you want to create a 2D game. There are detailled tutorials to get you started with almost any ActionScript editor immaginable (including <a title="Getting started with Sandy 3D and FlashDevelop" href="http://www.streamhead.com/tutorial-getting-started-with-sandy-3d-and-flashdevelop/" target="_blank">FlashDevelop</a>). The engine is still under very active development and there&#8217;s a lively community that will surely help you out if the wiki is insufficient.</p>
<p><a title="PushButton Engine" href="http://pushbuttonengine.com/" target="_blank">PushButton Engine</a></p>
<p><a href="http://pushbuttonengine.com/"><img class="alignnone size-full wp-image-2344" title="pushbutton-engine" src="http://www.streamhead.com/wp-content/uploads/2010/04/pushbutton-engine.png" alt="" width="343" height="91" /></a></p>
<p>Probably the most known, best documented and most active game engine for ActionScript. The PushButton Engine is build around the concept of &#8220;components&#8221;, which, to me, feels very natural, especially for a game. Watch this short introduction to get the gist of it (<a title="Component Based Game Architecture" href="http://www.bit-101.com/blog/?p=2408" target="_blank">via BIT-101</a>)</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/auaqZzcjl-Y&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/auaqZzcjl-Y&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>(<a title="The King's Game" href="http://www.flickr.com/photos/levyfulop/4200540217/" target="_blank">image credit</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/flash-actionscript-game-engines/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/04/the_kings_game.png" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/04/the_kings_game.png" medium="image">
			<media:title type="html">the_kings_game</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/04/the_kings_game.png" medium="image">
			<media:title type="html">the_kings_game</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/04/yogurt3d.png" medium="image">
			<media:title type="html">yogurt3d</media:title>
			<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/04/yogurt3d-300x90.png" />
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/04/ffilmation.png" medium="image">
			<media:title type="html">ffilmation</media:title>
			<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/04/ffilmation-300x79.png" />
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/04/flixel.png" medium="image">
			<media:title type="html">flixel</media:title>
			<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/04/flixel-300x85.png" />
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/04/pushbutton-engine.png" medium="image">
			<media:title type="html">pushbutton-engine</media:title>
			<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/04/pushbutton-engine-300x91.png" />
		</media:content>
	</item>
		<item>
		<title>ActionScript 3 Minimal Comps for Quick Prototyping</title>
		<link>http://www.streamhead.com/minimal-components/</link>
		<comments>http://www.streamhead.com/minimal-components/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 08:00:41 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flashdevelop]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=2069</guid>
		<description><![CDATA[Recently, Keith Peters has been putting overtime into his Minimal Comps library. It&#8217;s an ActionScript 3 library that offers a large number of typical user interface components. Easily and quickly you can construct basic user interfaces in ActionScript. When Flex is a little too heavy, this is a really neat solution. This is basically the [...]]]></description>
			<content:encoded><![CDATA[<img width="300" height="250" src="http://www.streamhead.com/wp-content/uploads/2010/03/minimal_duck.png" class="attachment-post-thumbnail wp-post-image" alt="minimal_duck" title="minimal_duck" /><p>Recently, <a title="About / Contact - BIT-101" href="http://www.bit-101.com/blog/?page_id=2" target="_blank">Keith Peters</a> has been putting overtime into his <a title="Minimal Comps" href="http://www.minimalcomps.com/" target="_blank">Minimal Comps</a> library. It&#8217;s an ActionScript 3 library that offers a large number of typical user interface components. Easily and quickly you can construct basic user interfaces in ActionScript. When Flex is a little too heavy, this is a really neat solution.</p>
<p><span id="more-2069"></span>This is basically the most minimal minimal component application you&#8217;re going to see:</p>

<div class="wp_codebox"><table><tr id="p20698"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p2069code8"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">bit101</span>.<span style="color: #006600;">components</span>.<span style="color: #006600;">PushButton</span>;
	<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;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">flashdevelop</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">FlashConnect</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span><span style="color: #66cc66;">&#41;</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">else</span> addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, init<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			removeEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, init<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">new</span> PushButton<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #ff0000;">&quot;Click me&quot;</span>, onBtnClick<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onBtnClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			FlashConnect.<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;clicked&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Inspired by this <a title="Minimal tutorial 01" href="http://www.minimalcomps.com/tutorials/minimal_tutorial_01.html" target="_blank">minimal tutorial</a> and written for <a title="FlashDevelop" href="http://www.flashdevelop.org/" target="_blank">FlashDevelop</a> (remove the FlashConnect statements if you&#8217;re working in another editor).</p>
<p>BTW I wanted to give a demonstration where I integrated the YouTube data API, but it appears that none of the libraries are really up-to-date and/or well enough documented to get started in under 15 minutes. <a title="as3-youtube-data-api" href="http://code.google.com/p/as3-youtube-data-api/" target="_blank">This one comes closest</a>, but if you have a good suggestion, please let me know.</p>
<p>(<a href="http://www.flickr.com/photos/ahudson/2053348794/">image credit</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/minimal-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/03/minimal_duck.png" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/03/minimal_duck.png" medium="image">
			<media:title type="html">minimal_duck</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/03/minimal_duck.png" medium="image">
			<media:title type="html">minimal_duck</media:title>
		</media:content>
	</item>
		<item>
		<title>Degrafa, Graphics Framework for Flex</title>
		<link>http://www.streamhead.com/degrafa-graphics-framework-flex/</link>
		<comments>http://www.streamhead.com/degrafa-graphics-framework-flex/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 08:00:17 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=1835</guid>
		<description><![CDATA[Flex and ActionScript combined give you a very powerful environment for programming graphics intensive application. The technology makes it easy to design and create animation rich interfaces. And now Degrafa adds yet another compelling choice if you want to easily create complex graphical interfaces. In Flex, many graphics operations require knowledge of ActionScript. Degrafa allows [...]]]></description>
			<content:encoded><![CDATA[<img width="300" height="250" src="http://www.streamhead.com/wp-content/uploads/2010/02/degrafa_sun.png" class="attachment-post-thumbnail wp-post-image" alt="degrafa_sun" title="degrafa_sun" /><p>Flex and ActionScript combined give you a very powerful environment for programming graphics intensive application. The technology makes it easy to design and create animation rich interfaces. And now Degrafa adds yet another compelling choice if you want to easily create complex graphical interfaces.</p>
<p><span id="more-1835"></span></p>
<p>In Flex, many graphics operations require knowledge of ActionScript. <a title="Degrafa : Declarative Graphics Framework" href="http://www.degrafa.org/about/" target="_blank">Degrafa</a> allows you to decoratively specify those programs in the Flex MXML files that define graphic interfaces. Designers can thus more easily create and comprehend programs, while developers don&#8217;t need to switch back to ActionScript for many operations (or even complete programs).</p>
<p>Degrafa is open source and thus <a title="download Degrafa" href="http://www.degrafa.org/code/" target="_blank">freely available</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/degrafa-graphics-framework-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2010/02/degrafa_sun.png" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/02/degrafa_sun.png" medium="image">
			<media:title type="html">degrafa_sun</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2010/02/degrafa_sun.png" medium="image">
			<media:title type="html">degrafa_sun</media:title>
		</media:content>
	</item>
		<item>
		<title>YouTube ActionScript 3.0 Player, Welcome to the ActionScript future</title>
		<link>http://www.streamhead.com/youtube-actionscript-30-player-actionscript-future/</link>
		<comments>http://www.streamhead.com/youtube-actionscript-30-player-actionscript-future/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 08:00:53 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=1791</guid>
		<description><![CDATA[This weekend, I finally brought The Couch TVs frontpage up to date. It had been broken for a while, ever since my little YouTube ActionScript 3 hack stopped working. Since YouTube announced their ActionScript 3.0 player, a few months ago, there is no need for a hack anyway. Now there is a clean way to [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend, I finally brought <a title="The Couch TV - random YouTube at your command" href="http://www.thecouchtv.com/" target="_blank">The Couch TV</a>s frontpage up to date. It had been broken for a while, ever since my little YouTube ActionScript 3 hack stopped working. Since YouTube announced their ActionScript 3.0 player, a few months ago, there is no need for a hack anyway. Now there is a clean way to integrate YouTube in your ActionScript 3 programs.</p>
<p>Integration is incredibly easy, you can read <a title="YouTube ActionScript 3.0 Player API reference" href="http://code.google.com/intl/nl/apis/youtube/flash_api_reference.html" target="_blank">the documentation</a> in about 10 minutes and that&#8217;s really all you need to know. No hidden options or special URLs necessary.</p>
<p>I did create a small wrapper class, to make addressing the player a little more typesafe (and this also gives you autocompletion). Check out my <a title="The Couch TV SVN repo" href="http://svn.assembla.com/svn/thecouch/" target="_blank">Assembla SVN repository</a> for the full code of what you can see on <a title="The Couch TV - random YouTube at your command" href="http://www.thecouchtv.com/" target="_blank">The Couch TV</a> (there&#8217;s code for full screen in there that doesn&#8217;t work right now).</p>
<p>You can find the wrapper <a title="YouTubePlayer.as on Assembla SVN" href="http://svn.assembla.com/svn/thecouch/trunk/src/thecouch/YouTubePlayer.as" target="_blank">right here</a>. The YouTubePlayer class extends Loader, which means you can add it anywhere you like. The class first needs to load the actual YouTube player on YouTube.com. This means you need to wait until everything is loaded before you can use the player. In ActionScript code it looks like this:</p>

<div class="wp_codebox"><table><tr id="p179111"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code" id="p1791code11"><pre class="actionscript" style="font-family:monospace;">package thecouch 
<span style="color: #66cc66;">&#123;</span>
	<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;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #808080; font-style: italic;">/**
	 * @author Peter Backx - thecouchtv.com
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleExample <span style="color: #0066CC;">extends</span> Sprite 
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> player:YouTubePlayer;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SimpleExample<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
		<span style="color: #66cc66;">&#123;</span>
	        addChild<span style="color: #66cc66;">&#40;</span>player = <span style="color: #000000; font-weight: bold;">new</span> YouTubePlayer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			player.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>YouTubePlayer.<span style="color: #006600;">PLAYER_READY</span>, playerReady<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> playerReady<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			player.<span style="color: #006600;">loadVideoById</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;2gGopKNPqVk&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>I&#8217;ve also added wrappers for the loadVideoByUrl methods and a listener for the &#8220;ended&#8221; even. That means, you can use those directly on the YouTubePlayer object. You&#8217;ll have nice code completion in your editor. And unlike the example in the documentation this means you also have compile time type safety. The joy of typesafe object oriented programming.</p>
<p>The <a title="Main.as on Assembla SVN" href="http://svn.assembla.com/svn/thecouch/trunk/src/thecouch/Main.as" target="_blank">Main class</a> shows you how to use them. If you want other methods or events, feel free to add them, or you can always ask me. I&#8217;d be delighted to expand this wrapper a little more.</p>
<p>The previous posts in this series (not all of them are still applicable, but will be updated shortly):</p>
<ul>
<li><a href="http://www.streamhead.com/create-fully-customizable-actionscript-30-youtube-player/" title="Fully Customizable AS3 YouTube Player" target="_blank">Getting a list of videos (and some project setup)</a></li>
<li><a href="http://www.streamhead.com/flash-developer-flashdisplaystagescalemode/" title="The Flash stage" target="_blank">A bit about how the Flash stage works and fullscreen</a></li>
<li><a href="http://www.streamhead.com/youtube-flash-video-flv-secret/" title="PHP proxy-ing around security contraints" target="_blank">Install a php script to get the video parameters</a></li>
<li><a href="http://www.streamhead.com/tying-youtube-services-pro-web-20-developer/" title="YouTube hacking" target="_blank">Getting the parameters for a video</a></li>
<li><a href="http://www.streamhead.com/lazy-actionscript-developers-stream-flash-video/" title="Playing FLV files in ActionScript 3" target="_blank">playing the video using Flash’s FLV player classes</a></li>
</ul>
<p>Next up, I&#8217;m going to remove the proprietary YouTube Data API calls with <a title="AS3-YouTube-Data-API" href="http://code.google.com/p/as3-youtube-data-api/" target="_blank">this project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/youtube-actionscript-30-player-actionscript-future/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>gSkinner gPlays gMP3 gAs gVinyl</title>
		<link>http://www.streamhead.com/gskinner-gplays-gmp3-gas-gvinyl/</link>
		<comments>http://www.streamhead.com/gskinner-gplays-gmp3-gas-gvinyl/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 08:00:57 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=1725</guid>
		<description><![CDATA[2010 is almost here and I like to end 2009 with a clean slate. One of those slates that needs cleaning is my starred items in Google Reader. I tend to star everything that looks like it might be interesting. The idea is that I can back to it later when I have a little [...]]]></description>
			<content:encoded><![CDATA[<p>2010 is almost here and I like to end 2009 with a clean slate. One of those slates that needs cleaning is my starred items in Google Reader. I tend to star everything that looks like it might be interesting. The idea is that I can back to it later when I have a little more time. One item I found on that list is <a title="gBlog: Playing Records with ActionScript" href="http://www.gskinner.com/blog/archives/2009/11/playing_records.html" target="_blank">gSkinner&#8217;s Flash applet that plays perfectly good MP3 files as if it were slightly damaged vinyl records</a>.</p>
<p>What&#8217;s even more interesting than the great funny little Flash toy, is the fact that Grant gives all details of how it was implemented in ActionScript. There&#8217;s no source, but by the time you&#8217;ve read the entire blogpost, you have enough information to create the thing on your own.</p>
<p>Lots of links to very useful resources if you want to play MP3 files in Flash and lots of little details on how to obtain different visual effects.</p>
<p><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" id="Player_852ef3f5-256f-4754-9e0c-0696cf6cd2c1"  WIDTH="600px" HEIGHT="200px"> <PARAM NAME="movie" VALUE="http://ws.amazon.co.uk/widgets/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Fwatje-21%2F8010%2F852ef3f5-256f-4754-9e0c-0696cf6cd2c1&#038;Operation=GetDisplayTemplate"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#FFFFFF"><PARAM NAME="allowscriptaccess" VALUE="always"><embed src="http://ws.amazon.co.uk/widgets/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Fwatje-21%2F8010%2F852ef3f5-256f-4754-9e0c-0696cf6cd2c1&#038;Operation=GetDisplayTemplate" id="Player_852ef3f5-256f-4754-9e0c-0696cf6cd2c1" quality="high" bgcolor="#ffffff" name="Player_852ef3f5-256f-4754-9e0c-0696cf6cd2c1" allowscriptaccess="always"  type="application/x-shockwave-flash" align="middle" height="200px" width="600px"></embed></OBJECT> <NOSCRIPT><A HREF="http://ws.amazon.co.uk/widgets/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Fwatje-21%2F8010%2F852ef3f5-256f-4754-9e0c-0696cf6cd2c1&#038;Operation=NoScript">Amazon.co.uk Widgets</A></NOSCRIPT></p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/gskinner-gplays-gmp3-gas-gvinyl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>Exporting Models From Blender to Flash Sandy 3D, Experiments in 3D</title>
		<link>http://www.streamhead.com/export-3d-models-blender-flash-sandy-3d/</link>
		<comments>http://www.streamhead.com/export-3d-models-blender-flash-sandy-3d/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 08:00:28 +0000</pubDate>
		<dc:creator>Peter Backx</dc:creator>
				<category><![CDATA[Flash and ActionScript]]></category>

		<guid isPermaLink="false">http://www.streamhead.com/?p=1438</guid>
		<description><![CDATA[Last week, reader rafbaf asked how to use Blender models in Sandy 3D. There are a few options, for instance Sandy 3D can import the Collada format that Blender exports. But there is also an easier way. A Python script for Blender allows you to export models straight to ActionScript code. However, as you will [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, reader <em>rafbaf</em> asked how to use Blender models in Sandy 3D. There are a few options, for instance Sandy 3D can import the <a title="COLLADA - Wikipedia" href="http://en.wikipedia.org/wiki/COLLADA" target="_blank">Collada</a> format that Blender exports. But there is also an easier way. <a title="Export your Blender objects straight to Away3D, Papervision3D and Sandy" href="http://www.rozengain.com/blog/2008/01/02/export-your-blender-objects-straight-to-away3d-papervision3d-and-sandy/" target="_blank">A Python script for Blender allows you to export models straight to ActionScript code</a>. However, as you will see in this post, it&#8217;s not as straightforward as it seems.</p>
<p><a title="example project: importing Blender models in Sandy 3D" href="http://www.streamhead.com/wp-content/uploads/2009/07/BlenderAndSandy.zip" target="_blank"><img class="alignleft size-full wp-image-498" title="download" src="http://www.streamhead.com/wp-content/uploads/2008/11/download.png" alt="download" width="30" height="24" />Example FlashDevelop project.</a></p>
<p>There&#8217;s a reason this post is titled &#8220;experiments&#8221;. It is actually an unfinished work, but I wanted to give you a look at what I&#8217;ve already been able to create. This is how far I got for now:</p>
<p><object type="application/x-shockwave-flash" data="http://www.streamhead.com/wp-content/uploads/2009/07/BlenderAndSandy.swf" width="778" height="400" class="embedflash"><param name="movie" value="http://www.streamhead.com/wp-content/uploads/2009/07/BlenderAndSandy.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><small>(Please open the article to see the flash file or player.)</small></object></p>
<ol>
<li>First, I got an A-Wing from <a title="blendermodels" href="http://www.blendermodels.org/models/sci_fi/" target="_blank">the blendermodels archive</a>. Before I got the first render result shown in the picture above, I had to fix the normals of most of the meshes in there (in Blender: go into edit mode, select vertices and ctrl-n)</li>
<li>Next, get the export script from <a title="Export your Blender objects straight to Away3D, Papervision3D and Sandy" href="http://www.rozengain.com/blog/2008/01/02/export-your-blender-objects-straight-to-away3d-papervision3d-and-sandy/" target="_blank">Dennis&#8217;s page</a> and install it. Take care to get the correct directory, it&#8217;s not that easy to find. If you have one of the latest versions of Blender, you should look in your user folder. For Windows that&#8217;s &#8220;C:Documents and Settings&lt;username&gt;Application DataBlender FoundationBlender.blenderscripts&#8221;.</li>
<li>If you haven&#8217;t already done so, you also need to have <a title="Python Programming Language" href="http://www.python.org/" target="_blank">Python</a> installed. Python is necessary to execute the script.</li>
<li>Once you got this out of the way, you will need to restart Blender. Check the file &gt; export menu and verify that the ActionScript option is available. If it&#8217;s not, you probably placed the AS3Export.py file in the wrong directory.</li>
<li>Select the object you want to export and click the export to ActionScript menu item. It&#8217;s probably a good idea to enter a package name, as this will keep your code cleaner.</li>
</ol>
<p>Now you should have one or more .as files: one for every mesh and texture in your model. This model doesn&#8217;t come with textures, so there are none.</p>
<p>Next we are going to use those files in a FlashDevelop project. The first step is to create a new project in FlashDevelop and put the Sandy 3D library inside the src folder. <a title="Sandy 3D Tutorial: Getting Started" href="http://www.streamhead.com/sandy-3d-tutorial/" target="_blank">Like described in previous blog posts</a>.</p>
<p>Now inside the src directory, you should create a directory with the same name as the package you specified in step 5 above. If you forgot the package name or are not sure, you can open one of the files that was created and check the first line.</p>
<p>That&#8217;s pretty much it: add the meshes as Shape3D objects to your scene, just like you would add a cube or other shape:</p>

<div class="wp_codebox"><table><tr id="p143814"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1438code14"><pre class="actionscript" style="font-family:monospace;">scene.<span style="color: #006600;">root</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Mesh<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>(you might want to add an appearance too)</p>
<p>You&#8217;ll notice I&#8217;m skipping a few steps here, but they are all very basic. If you download the example project and read through <a title="Sandy 3D Tutorial: Getting Started" href="http://www.streamhead.com/sandy-3d-tutorial/" target="_blank">my previous</a> <a title="Tutorial - getting started with Sandy 3D and FlashDevelop" href="http://www.streamhead.com/tutorial-getting-started-with-sandy-3d-and-flashdevelop/" target="_blank">blog posts</a>, everything should be clear (feel free to comment if it isn&#8217;t).</p>
<p>You&#8217;ll notice a few issues/problems (correct me if I&#8217;m wrong):</p>
<ul>
<li>The 3D object I choose, consists of several meshes. Each with their own texture (material in Sandy3D terminology). The export plugin doesn&#8217;t really help you on this point. You need to create every mesh and add them individually to the scene.</li>
<li>There seems to be an issue with the normal calculations. I did correct them in Blender as you can see in the small rendering at the top of my post, but still there seem to be missing triangles in the Sandy 3D version.</li>
<li>It looks like there is an issue with a bounding box or <a title="Sandy 3D tutorial on performance" href="http://www.flashsandy.org/tutorials/3.0/sandy_cs3_tut05" target="_blank">face culling</a>. I still need to investigate this thoroughly.</li>
</ul>
<p>To be continued&#8230;</p>
<p><a title="example project: importing Blender models in Sandy 3D" href="http://www.streamhead.com/wp-content/uploads/2009/07/BlenderAndSandy.zip" target="_blank"><img class="alignleft size-full wp-image-498" title="download" src="http://www.streamhead.com/wp-content/uploads/2008/11/download.png" alt="download" width="30" height="24" />Example FlashDevelop project.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.streamhead.com/export-3d-models-blender-flash-sandy-3d/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:thumbnail url="http://www.streamhead.com/wp-content/uploads/2008/11/download.png" />
		<media:content url="http://www.streamhead.com/wp-content/uploads/2008/11/download.png" medium="image">
			<media:title type="html">download</media:title>
		</media:content>
		<media:content url="http://www.streamhead.com/wp-content/uploads/2008/11/download.png" medium="image">
			<media:title type="html">download</media:title>
		</media:content>
	</item>
	</channel>
</rss>

