<?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"
	>

<channel>
	<title>Aksel Kornesjo</title>
	<atom:link href="http://boxmonster.890m.com/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://boxmonster.890m.com/wordpress</link>
	<description>1 + 1 = 3</description>
	<pubDate>Wed, 06 May 2009 20:46:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Blog&#8217;s movin&#8217; sometime</title>
		<link>http://boxmonster.890m.com/wordpress/?p=173</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=173#comments</comments>
		<pubDate>Wed, 06 May 2009 20:46:57 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=173</guid>
		<description><![CDATA[I&#8217;ve been dead for some time, heh. Anyways, this tutorial blog is probably going to be moved to some other place, I just need a catchy domain name. Then I hope I&#8217;m going to do some average tutorials, and make the request tutorials also  
What should the domain name be :/
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been dead for some time, heh. Anyways, this tutorial blog is probably going to be moved to some other place, I just need a catchy domain name. Then I hope I&#8217;m going to do some average tutorials, and make the request tutorials also <img src='http://boxmonster.890m.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>What should the domain name be :/</p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=173</wfw:commentRss>
		</item>
		<item>
		<title>Circular collision detection 2</title>
		<link>http://boxmonster.890m.com/wordpress/?p=154</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=154#comments</comments>
		<pubDate>Wed, 05 Nov 2008 19:55:07 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Actionscript 3 tutorials]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[3]]></category>

		<category><![CDATA[action]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[circle]]></category>

		<category><![CDATA[circular]]></category>

		<category><![CDATA[collision]]></category>

		<category><![CDATA[detection]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=154</guid>
		<description><![CDATA[In the last circular collision tutorial we could find when the circle hits the other one, but nothing more.
So this tutorial will contain how to make the circles un-overlappable.

To read the first tutorial in these series isn&#8217;t compulsory, but you could do that if you want.

Part 1


I&#8217;ll start all over, with a new .fla file, [...]]]></description>
			<content:encoded><![CDATA[<p>In the last circular collision tutorial we could find when the circle hits the other one, but nothing more.<br />
So this tutorial will contain how to make the circles un-overlappable.<br />
<span id="more-154"></span></p>
<p>To read the first tutorial in these series isn&#8217;t compulsory, but you could do that if you want.</p>
<ul>
<li><a href="http://boxmonster.890m.com/wordpress/?p=138">Part 1</a></li>
</ul>
<p><!--more--></p>
<p>I&#8217;ll start all over, with a new .fla file, mostly because thats simpler.</p>
<p>So. Create an <strong>ActionScript 3.0</strong> .fla file. Good good. As far everything is just good.</p>
<p>Lets create 2 circle MovieClips by opening up the ActionScript panel (<strong>F9</strong>) and typing in this there:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p154code3'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p1543"><td class="code" id="p154code3"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> c1:<span style="color: #0066CC;">MovieClip</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Circle 1</span>
<span style="color: #000000; font-weight: bold;">var</span> c1r:uint=<span style="color: #000000; font-weight: bold;">new</span> uint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Circle 1 Radius</span>
c1.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xCCCCCC<span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Fill color </span>
c1.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawEllipse</span><span style="color: #66cc66;">&#40;</span>-c1r,-c1r,c1r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>,c1r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Draws the circle</span>
c1.<span style="color: #006600;">x</span>=<span style="color: #cc66cc;">275</span>;
c1.<span style="color: #006600;">y</span>=<span style="color: #cc66cc;">200</span>;
addChild<span style="color: #66cc66;">&#40;</span>c1<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> c2:<span style="color: #0066CC;">MovieClip</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Circle 2</span>
<span style="color: #000000; font-weight: bold;">var</span> c2r:uint=<span style="color: #000000; font-weight: bold;">new</span> uint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Circle 2 Radius</span>
c2.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xCCFFCC<span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Fillcolor</span>
c2.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawEllipse</span><span style="color: #66cc66;">&#40;</span>-c1r,-c1r,c1r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>,c1r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Draws circle</span>
c2.<span style="color: #006600;">x</span>=<span style="color: #cc66cc;">100</span>;
c2.<span style="color: #006600;">y</span>=<span style="color: #cc66cc;">100</span>;
addChild<span style="color: #66cc66;">&#40;</span>c2<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Now this creates the circles, and places them on the stage.<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic12.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic12.png" alt="" title="Circles" width="331" height="214" class="aligncenter size-full wp-image-161" /></a></p>
<p>Then we need the code for moving the other circle.<br />
And its here:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p154code4'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p1544"><td class="code" id="p154code4"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> dx:<span style="color: #0066CC;">int</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Distance x</span>
<span style="color: #000000; font-weight: bold;">var</span> dy:<span style="color: #0066CC;">int</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Distanve y</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">Number</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Length</span>
<span style="color: #000000; font-weight: bold;">var</span> df:<span style="color: #0066CC;">Number</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Force off</span>
&nbsp;
<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>,mouse_move<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> mouse_move<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
&nbsp;
	dx=c1.<span style="color: #006600;">x</span>-mouseX;<span style="color: #808080; font-style: italic;">//Distance x</span>
	dy=c1.<span style="color: #006600;">y</span>-mouseY;<span style="color: #808080; font-style: italic;">//Dist. y</span>
&nbsp;
	len=<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span>dx<span style="color: #66cc66;">*</span>dx+dy<span style="color: #66cc66;">*</span>dy<span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Length</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>len<span style="color: #66cc66;">&lt;</span>=<span style="color: #66cc66;">&#40;</span>c1r+c2r<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//if the length is shorter than the 2 added radiuses</span>
		df=len-<span style="color: #66cc66;">&#40;</span>c1r+c2r<span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//set the force to dist minus the 2 radiuses</span>
		dx=dx<span style="color: #66cc66;">/</span>len<span style="color: #66cc66;">*</span>df;<span style="color: #808080; font-style: italic;">//Divide distance x with the length, this makes the dx a value of &quot;1&quot;, and then multiplies with df, which makes it as long as its overlapping.</span>
		dy=dy<span style="color: #66cc66;">/</span>len<span style="color: #66cc66;">*</span>df;<span style="color: #808080; font-style: italic;">//Same here.</span>
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//Else dx and dy is nothing</span>
		dx=<span style="color: #cc66cc;">0</span>;
		dy=<span style="color: #cc66cc;">0</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	c2.<span style="color: #006600;">x</span>=mouseX+dx;<span style="color: #808080; font-style: italic;">//Sets the x pos of the circle to mouseX+ the x-distance thats left.</span>
	c2.<span style="color: #006600;">y</span>=mouseY+dy;<span style="color: #808080; font-style: italic;">//Same with y-position</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This code is almost the same, but with small differences. It doesn&#8217;t set the moving circles x, and y directly. </p>
<p>First it calculates the offset for it.<br />
The code describes how it works, but not so fantastically. If you experiment with it a little and think a bit I think you could understand what happens with the code.</p>
<p>It should be like this anyways:<br />
<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="500" height="400" id="square" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="http://boxmonster.890m.com/wordpress/wp-content/uploads/circular-hitdetection-part-2.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#00CC00" /><embed src="http://boxmonster.890m.com/wordpress/wp-content/uploads/circular-hitdetection-part-2.swf" quality="high" bgcolor="#00CC00" width="500" height="400" name="square" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
</object><script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><a href='http://boxmonster.890m.com/wordpress/wp-content/uploads/circular-hitdetection-part-2.fla'>If you couldn&#8217;t get this to work click here for the source.</a></p>
<p>A follow up will be written, probably. </p>
<p>Hopefully you liked this tutorial. And if you did, I&#8217;m happy <img src='http://boxmonster.890m.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bye bye.</p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=154</wfw:commentRss>
		</item>
		<item>
		<title>Circular collision detection</title>
		<link>http://boxmonster.890m.com/wordpress/?p=138</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=138#comments</comments>
		<pubDate>Wed, 05 Nov 2008 18:12:34 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Actionscript 3 tutorials]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[3]]></category>

		<category><![CDATA[action]]></category>

		<category><![CDATA[circle]]></category>

		<category><![CDATA[circular]]></category>

		<category><![CDATA[detection]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[hit]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=138</guid>
		<description><![CDATA[Hi everyone who reads my tutorials. Now I&#8217;ve jumped over to AS3 myself, and I think it&#8217;s better than as2, so hereby my tutorials will be in AS3. This tutorial is about really simple circular hit detection.

I&#8217;m making the flash file at the same time as I write this so there could be some errors [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone who reads my tutorials. Now I&#8217;ve jumped over to AS3 myself, and I think it&#8217;s better than as2, so hereby my tutorials will be in AS3. This tutorial is about really simple circular hit detection.<br />
<span id="more-138"></span></p>
<p>I&#8217;m making the flash file at the same time as I write this so there could be some errors in it. But I think I could.</p>
<p>First off. Open a <strong>ActionScript 3.0</strong> .fla file. We&#8217;re not going to use classes in this tutorial, mostly because it&#8217;s simpler without them. </p>
<p>Then we could create a new circle movieClip by opening the code window by pressing F9.</p>
<p>And typing this in:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p138code12'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p13812"><td class="code" id="p138code12"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> circ1:<span style="color: #0066CC;">MovieClip</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Now we have a empty MovieClip there, we could position it to the middle:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p138code13'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p13813"><td class="code" id="p138code13"><pre class="actionscript" style="font-family:monospace;">circ1.<span style="color: #006600;">x</span>=<span style="color: #cc66cc;">275</span>;
circ1.<span style="color: #006600;">y</span>=<span style="color: #cc66cc;">200</span>;</pre></td></tr></table></div>

<p>And add it to the stage:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p138code14'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p13814"><td class="code" id="p138code14"><pre class="actionscript" style="font-family:monospace;">addChild<span style="color: #66cc66;">&#40;</span>circ1<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>But when you run this, it shows nothing. That&#8217;s because it&#8217;s just a empty movieClip. So lets add these lines to it:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p138code15'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p13815"><td class="code" id="p138code15"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> circle1r:uint=<span style="color: #000000; font-weight: bold;">new</span> uint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>;
circ1.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFF0000<span style="color: #66cc66;">&#41;</span>;
circ1.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawEllipse</span><span style="color: #66cc66;">&#40;</span>-circle1r,-circle1r,circle1r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>,circle1r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
circ1.<span style="color: #006600;">alpha</span>=.5;</pre></td></tr></table></div>

<p>Now it has a fine looking circle. Its red and dandy. Yay.</p>
<p>But now lets see how we can see if something is colliding with it. Lets say that well see when the mouse pointer is colliding with it:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p138code16'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p13816"><td class="code" id="p138code16"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> vx:<span style="color: #0066CC;">int</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//&quot;velocity-x&quot;</span>
<span style="color: #000000; font-weight: bold;">var</span> vy:<span style="color: #0066CC;">int</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//velocity-y</span>
<span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">int</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Distance/Length</span>
<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>,mouse_move<span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Adds mouse event listener</span>
<span style="color: #000000; font-weight: bold;">function</span> mouse_move<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//The function for it.</span>
	vx=circ1.<span style="color: #006600;">x</span>-mouseX;<span style="color: #808080; font-style: italic;">//Calculates velocity x</span>
	vy=circ1.<span style="color: #006600;">y</span>-mouseY;<span style="color: #808080; font-style: italic;">//Calculates velocity y</span>
	len=<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span>vx<span style="color: #66cc66;">*</span>vx+vy<span style="color: #66cc66;">*</span>vy<span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//sees the length.</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>len<span style="color: #66cc66;">&lt;</span>circle1r<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//if the distance is shorter than the circles radius, its a hit.</span>
		circ1.<span style="color: #006600;">alpha</span>=<span style="color: #cc66cc;">1</span>;<span style="color: #808080; font-style: italic;">//Putting the alpha to full.</span>
                <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;*Collission*&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//else not.</span>
		circ1.<span style="color: #006600;">alpha</span>=.5;<span style="color: #808080; font-style: italic;">//half of the alpha.</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Now you can see that the detection is very precise. But at this moment, we can&#8217;t do much with it. So lets continue With a collision detection between 2 circles, and that&#8217;s not so much harder. </p>
<p>The other circle will be like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p138code17'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p13817"><td class="code" id="p138code17"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> circ2:<span style="color: #0066CC;">MovieClip</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> circle2r:uint=<span style="color: #000000; font-weight: bold;">new</span> uint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>;
circ2.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0x00FF00<span style="color: #66cc66;">&#41;</span>;
circ2.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawEllipse</span><span style="color: #66cc66;">&#40;</span>-circle2r,-circle2r,circle2r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>,circle2r<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span>circ2<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Add this code directly after where <em>circ1</em> ends.<br />
We also need to change the code in the <em>mouse_move</em> function. Change the whole function to this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p138code18'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p13818"><td class="code" id="p138code18"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mouse_move<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//The function for it.</span>
	circ2.<span style="color: #006600;">x</span>=mouseX;
	circ2.<span style="color: #006600;">y</span>=mouseY;
	vx=circ1.<span style="color: #006600;">x</span>-circ2.<span style="color: #006600;">x</span>;<span style="color: #808080; font-style: italic;">//Calculates velocity x</span>
	vy=circ1.<span style="color: #006600;">y</span>-circ2.<span style="color: #006600;">y</span>;<span style="color: #808080; font-style: italic;">//Calculates velocity y</span>
	len=<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span>vx<span style="color: #66cc66;">*</span>vx+vy<span style="color: #66cc66;">*</span>vy<span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//sees the length.</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>len<span style="color: #66cc66;">&lt;</span>circle1r+circle2r<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//if the distance is shorter than the circles radius plus the moving circles radius, its a hit.</span>
		circ1.<span style="color: #006600;">alpha</span>=<span style="color: #cc66cc;">1</span>;<span style="color: #808080; font-style: italic;">//Putting the alpha to full.</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;*Collission*&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//else not.</span>
		circ1.<span style="color: #006600;">alpha</span>=.5;<span style="color: #808080; font-style: italic;">//half of the alpha.</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>The only thing that&#8217;s changed in this code, is that the green circle is moved to the mouse pointer.<br />
And that instead of creating a collision at circ1&#8217;s radius, it adds both circles radiuses, and then sees if the distance is below that value.<br />
It&#8217;s really simple.</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="500" height="400" id="square" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="http://boxmonster.890m.com/wordpress/wp-content/uploads/circular-hitdetection-part1.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#00CC00" /><embed src="http://boxmonster.890m.com/wordpress/wp-content/uploads/circular-hitdetection-part1.swf" quality="high" bgcolor="#00CC00" width="500" height="400" name="square" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
</object><script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><a href='http://boxmonster.890m.com/wordpress/wp-content/uploads/circular-hitdetection-part1.fla'>But if it wasn&#8217;t simple enough, and you didn&#8217;t get it to work, here&#8217;s the source for it.</a></p>
<p>A follow up to this will come soon. Probably.</p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=138</wfw:commentRss>
		</item>
		<item>
		<title>Actionscript 3 - Real bitmap paint.</title>
		<link>http://boxmonster.890m.com/wordpress/?p=123</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=123#comments</comments>
		<pubDate>Sun, 02 Nov 2008 18:21:22 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Actionscript 3 tutorials]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[3]]></category>

		<category><![CDATA[action]]></category>

		<category><![CDATA[bitmap]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[paint]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=123</guid>
		<description><![CDATA[Hello again. You&#8217;ve probably seen these tutorials that shows you how to create a paint program in flash or something like that. But most of them just uses flash&#8217;s vector lineTo method, and that&#8217;s not such a good way to create a paint program, mostly because it starts to lag pretty much.
So I&#8217;ll show how [...]]]></description>
			<content:encoded><![CDATA[<p>Hello again. You&#8217;ve probably seen these tutorials that shows you how to create a paint program in flash or something like that. But most of them just uses flash&#8217;s vector lineTo method, and that&#8217;s not such a good way to create a paint program, mostly because it starts to lag pretty much.</p>
<p>So I&#8217;ll show how we could do a paint program that uses flash&#8217;s own bitmap methods.<br />
<span id="more-123"></span></p>
<p>First off, create a new <strong>ActionScript 3</strong> .fla file, and save it directly as <strong>paint.fla</strong> somewhere on your computer where you can find it easily.<br />
Then, create a ActionScript file (.as).</p>
<p>Then paste this code into it:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p123code20'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p12320"><td class="code" id="p123code20"><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;">BitmapData</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Point</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> paint <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> paintStage:BitmapData=<span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">550</span>,<span style="color: #cc66cc;">400</span>,<span style="color: #000000; font-weight: bold;">false</span>,0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> paintDisplay:Bitmap=<span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>paintStage<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> drawing:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> vx:<span style="color: #0066CC;">Number</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> vy:<span style="color: #0066CC;">Number</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> len:uint=<span style="color: #000000; font-weight: bold;">new</span> uint;
		<span style="color: #000000; font-weight: bold;">var</span> i:uint=<span style="color: #000000; font-weight: bold;">new</span> uint<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> p0:Point=<span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> p1:Point=<span style="color: #000000; font-weight: bold;">new</span> Point<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> paint<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>paintDisplay<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>,md<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span>,mu<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>,mm<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">function</span> md<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			drawing=<span style="color: #000000; font-weight: bold;">true</span>;
			p0.<span style="color: #006600;">x</span>=event.<span style="color: #006600;">stageX</span>;
			p0.<span style="color: #006600;">y</span>=event.<span style="color: #006600;">stageY</span>;
			p1.<span style="color: #006600;">x</span>=p0.<span style="color: #006600;">x</span>;
			p1.<span style="color: #006600;">y</span>=p0.<span style="color: #006600;">y</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">function</span> mu<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			drawing=<span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">function</span> mm<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>drawing<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				p1.<span style="color: #006600;">x</span>=event.<span style="color: #006600;">stageX</span>;
				p1.<span style="color: #006600;">y</span>=event.<span style="color: #006600;">stageY</span>;
				paintStage.<span style="color: #006600;">setPixel</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">stageX</span>,event.<span style="color: #006600;">stageY</span>,0x000000<span style="color: #66cc66;">&#41;</span>;
				vx=p1.<span style="color: #006600;">x</span>-p0.<span style="color: #006600;">x</span>;
				vy=p1.<span style="color: #006600;">y</span>-p0.<span style="color: #006600;">y</span>;
				len=<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span>vx<span style="color: #66cc66;">*</span>vx+vy<span style="color: #66cc66;">*</span>vy<span style="color: #66cc66;">&#41;</span>;
				vx<span style="color: #66cc66;">/</span>=len;
				vy<span style="color: #66cc66;">/</span>=len;
				<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>len; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
					paintStage.<span style="color: #006600;">setPixel</span><span style="color: #66cc66;">&#40;</span>p0.<span style="color: #006600;">x</span>+<span style="color: #66cc66;">&#40;</span>vx<span style="color: #66cc66;">*</span>i<span style="color: #66cc66;">&#41;</span>,p0.<span style="color: #006600;">y</span>+<span style="color: #66cc66;">&#40;</span>vy<span style="color: #66cc66;">*</span>i<span style="color: #66cc66;">&#41;</span>,0x000000<span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
				p0.<span style="color: #006600;">x</span>=p1.<span style="color: #006600;">x</span>;
				p0.<span style="color: #006600;">y</span>=p1.<span style="color: #006600;">y</span>;
			<span style="color: #66cc66;">&#125;</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>Save it as <strong>paint.as</strong> in the same directory as the .fla is in. Then go back to the .fla, and open up its settings. The settings should be like this:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic0.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic0-300x62.png" alt="" title="pic0" width="300" height="62" class="aligncenter size-medium wp-image-125" /></a><br />
Then you can just test it out <img src='http://boxmonster.890m.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You could see how the code works yourself. I don&#8217;t think anyone actually reads the description of the code anyways.</p>
<p>It should look like this:</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="500" height="400" id="square" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="http://boxmonster.890m.com/wordpress/wp-content/uploads/paint.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#00CC00" /><embed src="http://boxmonster.890m.com/wordpress/wp-content/uploads/paint.swf" quality="high" bgcolor="#00CC00" width="500" height="400" name="square" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
</object><br />
<script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Now the movie is a bit resized and it makes the line look broken, but when its in its original size it should be ok.</p>
<p><a href='http://boxmonster.890m.com/wordpress/wp-content/uploads/bitmap-paint.zip'>If you can&#8217;t get this to work, you can download the source here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=123</wfw:commentRss>
		</item>
		<item>
		<title>Jetpack game - Part 3</title>
		<link>http://boxmonster.890m.com/wordpress/?p=86</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=86#comments</comments>
		<pubDate>Sun, 02 Nov 2008 13:35:34 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Actionscript 2 tutorials]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[2]]></category>

		<category><![CDATA[3]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[game]]></category>

		<category><![CDATA[jet]]></category>

		<category><![CDATA[pack]]></category>

		<category><![CDATA[part]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=86</guid>
		<description><![CDATA[Hello. It was some time since I wrote a tutorial, mostly because I am to lazy to write something. But now I decided to force me to write one. This tutorial will be about creating levels to the jet pack game and some other stuff. First of, you should have read the other tutorials, and [...]]]></description>
			<content:encoded><![CDATA[<p>Hello. It was some time since I wrote a tutorial, mostly because I am to lazy to write something. But now I decided to force me to write one. This tutorial will be about creating levels to the jet pack game and some other stuff. First of, you should have read the other tutorials, and they&#8217;re here:</p>
<ul>
<li><a href="http://boxmonster.890m.com/wordpress/?p=8">Part 1</a></li>
<li><a href="http://boxmonster.890m.com/wordpress/?p=30">Part 2</a></li>
</ul>
<p>But it isn&#8217;t necessary to read them, but it could be easier to follow this tutorial if you did.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<span id="more-86"></span></p>
<p>The stuff thats going to be added now is;</p>
<ul>
<li>Scores</li>
<li>Health</li>
<li>Levels</li>
</ul>
<p><strong>1. Scores</strong></p>
<p>Adding scores is pretty easy, the only thing we need to do is to create a score MovieClip, and add some code.<br />
But first of, we could create a text field that shows the score. Select the text tool, by pressing T or just  clicking on the T symbol in flash, then just draw a text field to the upper corner of the stage.  Adjust the properties of the text field so they look like this;</p>
<p><a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic1.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic1.png" alt="" title="Picture one" width="500" height="112" class="aligncenter size-full wp-image-88" /></a></p>
<p>Now we have a fancy text field there. But still it can&#8217;t do nothing by itself. We need to add some code to the game.<br />
First off, we need a variable that contains the value of the score, so add this line to the very beginning of the whole code;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code34'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8634"><td class="code" id="p86code34"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> score:<span style="color: #0066CC;">Number</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>This creates a variable named score, and it may only contain a number, thats why the <em>:Number</em> is there. By declaring variables this way, you make your games slightly faster.</p>
<p>After this, we could add a function that updates the score text field.<br />
A function is a block of code that could be run once by calling it, you&#8217;ll see how they work in this tutorial if you don&#8217;t really know what they are. </p>
<p>But, what you need to do is to add this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code35'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8635"><td class="code" id="p86code35"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> updateScore<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	scoretxt.<span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Score: &quot;</span>+score;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>To the way bottom of all of the code.</p>
<p>This is just a simple function, and you can probably see what it does. It goes to the score text field, and accesses its text property, and then changes it to that text. But, if you try to run the game, you see that nothing has changed, yet. Thats because the function hasn&#8217;t been run. </p>
<p>To run this code, you need to call it as I wrote before.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code36'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8636"><td class="code" id="p86code36"><pre class="actionscript" style="font-family:monospace;">updateScore<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>If you add that row of code to the bottom of the whole code, and then run it, the score text field magically shows how many points you have :). Simple, simple. </p>
<p>Now we&#8217;ll add some coins or something else the jetpack guy could pick up. First off, draw that thing you want the jetpack man to pick up. I drew a great looking coin.<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic3.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic3.png" alt="" title="Coin" width="66" height="66" class="alignleft size-full wp-image-96" /></a><br />
Then select the shape, right click on it, and click <strong>Convert to symbol&#8230;</strong><br />
The settings for it should look like this:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic2.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic2.png" alt="" title="SEttings" width="410" height="328" class="alignnone size-full wp-image-98" /></a></p>
<p>Lets add functionality to the coin now. If you have followed the previous tutorials, you should have a ground MC and man MC. If you don&#8217;t, you should go back to the other tutorials and follow them, or just download the sources if you&#8217;re lazy. </p>
<p>When you have those MC&#8217;s there, and the coin MC too, you should give the coin MC a instance name. Lets name it <strong>coin0</strong>, like this;<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic4.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic4-300x116.png" alt="" title="Instance name" width="300" height="116" class="alignnone size-medium wp-image-99" /></a></p>
<p>You do this by first selecting the coin movieclip, and then just look at the properties window for it.<br />
While were on this, you can add some more coins, but, remember to name them <strong>coin1</strong>, <strong>coin2</strong> and so on.<br />
Oh, and to add these other coins, you can open the library, which should be located to the right of the screen, if it isn&#8217;t there just click window>Library. Then the library is there. Search for the coin in the library, and when you see it, just drag it from the library out to the stage. </p>
<p>When you&#8217;re with this, we&#8217;ll be adding some code to this. You need to open the code window were all the other code is, and then, we could create a neat function for checking if the jet pack man is colliding with one of the coins.<br />
So, type in this after the other code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code37'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8637"><td class="code" id="p86code37"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> dX:<span style="color: #0066CC;">Number</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> dY:<span style="color: #0066CC;">Number</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">Number</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> checkForCoins<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	i = <span style="color: #cc66cc;">0</span>;
	<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;coin&quot;</span>+i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		dX = <span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;coin&quot;</span>+i<span style="color: #66cc66;">&#93;</span>._x-fly.<span style="color: #0066CC;">_x</span>;
		dY = <span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;coin&quot;</span>+i<span style="color: #66cc66;">&#93;</span>._y-<span style="color: #66cc66;">&#40;</span>fly._y-fly.<span style="color: #0066CC;">_height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
		len = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span>dX<span style="color: #66cc66;">*</span>dX+dY<span style="color: #66cc66;">*</span>dY<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>len<span style="color: #66cc66;">&lt;</span><span style="color: #66cc66;">&#40;</span>fly.<span style="color: #0066CC;">_width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>+<span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;coin&quot;</span>+i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">_width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">_root</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;coin&quot;</span>+i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">_x</span> = -<span style="color: #cc66cc;">1999</span>;
			score++;
			updateScore<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		i++;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This code actually checks for collisions with the man and coins, completely without any hitTesting. Thats neat, isn&#8217;t it? :).<br />
Oh, and to make this code work, you need to add this code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code38'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8638"><td class="code" id="p86code38"><pre class="actionscript" style="font-family:monospace;">	checkForCoins<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>After this line:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code39'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8639"><td class="code" id="p86code39"><pre class="actionscript" style="font-family:monospace;">fly.<span style="color: #0066CC;">onEnterFrame</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></pre></td></tr></table></div>

<p>Now you have some coins you can pick up. </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="500" height="400" id="square" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="http://boxmonster.890m.com/wordpress/wp-content/uploads/jetpack-game-part-3.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#00CC00" /><embed src="http://boxmonster.890m.com/wordpress/wp-content/uploads/jetpack-game-part-3.swf" quality="high" bgcolor="#00CC00" width="500" height="400" name="square" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
</object></p>
<p>But if it doesn&#8217;t work, just download the source thats located at the bottom of this page.</p>
<p><strong>2. Health</strong></p>
<p>The second thing now is to add a health system or something like that.<br />
I&#8217;m going to explain fast how to do this.<br />
Draw a health bar next to the score text field. Select it, right click and <strong>Convert to symbol&#8230;</strong><br />
Then the properties for it should be like this:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic5.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic5.png" alt="" title="props2" width="428" height="354" class="aligncenter size-full wp-image-105" /></a></p>
<p>Give it the instance name of <strong>healthbar</strong>.</p>
<p>Then, we could add spikes it could hurt itself on. Draw some spikes on the ground somewhere.<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic6.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic6.png" alt="" title="pic6" width="184" height="83" class="alignnone size-full wp-image-109" /></a></p>
<p>Select the spikes, and convert it into a MC.<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic7.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic7.png" alt="" title="adfasdfasf" width="423" height="326" class="alignnone size-full wp-image-111" /></a></p>
<p>Give it the instance name <strong>spikes</strong>.<br />
Now we have spikes. Lets add a health variable and a health function.</p>
<p>Add these lines to the beginning of all the code;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code40'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8640"><td class="code" id="p86code40"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> health:<span style="color: #0066CC;">Number</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> maxhealth:<span style="color: #0066CC;">Number</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Now we have a max health and health variable. Thats good:)</p>
<p>Well, lets add a function that updates the health bar. Add this to the end of all the code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code41'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8641"><td class="code" id="p86code41"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> updateHealth<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	healthbar.<span style="color: #0066CC;">_xscale</span>=health<span style="color: #66cc66;">/</span>maxhealth<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>We need to see if the jet pack man is colliding with the spikes, so add this code into the onEnterFrame block, after <em>checkForCoins();</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code42'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8642"><td class="code" id="p86code42"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>spikes.<span style="color: #0066CC;">hitTest</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_x</span>,<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span>,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">||</span>spikes.<span style="color: #0066CC;">hitTest</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>._x-<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #0066CC;">this</span>._y-<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">||</span>spikes.<span style="color: #0066CC;">hitTest</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_x</span>+<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #0066CC;">this</span>._y-<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_height</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		health-=<span style="color: #cc66cc;">1</span>;
		updateHealth<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This piece of code just looks if the jet pack man is colliding with the spikes, and if it is, it takes away a bit of the health, and calls <em>updateHealth();</em>.<br />
We could add a game over-screen to it too. While you are at the main stage, press F7, or click insert>Timeline>blank keyframe. Then the stage should be&#8230; blank. Whilst having the frame selected, open the properties window, and type in gameover into the frame name window:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic11.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic11.png" alt="" title="pic11" width="358" height="138" class="alignnone size-full wp-image-118" /></a><br />
After that, open the actions window there, and type in</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code43'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8643"><td class="code" id="p86code43"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
btn.<span style="color: #0066CC;">onRelease</span>=<span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;game&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>into it.<br />
Now we need a play again button. Draw one:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic8.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic8.png" alt="" title="pic8" width="309" height="173" class="aligncenter size-full wp-image-114" /></a></p>
<p>Select it, right click, and then edit the settings so its like this:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic9.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic9-300x233.png" alt="" title="pic9" width="300" height="233" class="alignnone size-medium wp-image-116" /></a><br />
Give it the instance name <strong>btn</strong>.</p>
<p>Now, on the main timeline, click on frame 1 to go back to the game. When you have the whole frame selected, open the properties window, and type in <strong>game</strong> into the instance name window:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic10.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/pic10.png" alt="" title="pic10" width="363" height="133" class="alignnone size-full wp-image-117" /></a></p>
<p>Then, open up the code window again, and type in this on to the first row</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code44'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8644"><td class="code" id="p86code44"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>And then, scroll down to the <em>updateHealth</em>-function. And into that, after</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code45'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8645"><td class="code" id="p86code45"><pre class="actionscript" style="font-family:monospace;">healthbar.<span style="color: #0066CC;">_xscale</span>=health<span style="color: #66cc66;">/</span>maxhealth<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span>;</pre></td></tr></table></div>

<p>type in this</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code46'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8646"><td class="code" id="p86code46"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>health<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;gameover&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Now it has a simple life system too. Yay.</p>
<p><strong>3. Levels</strong><br />
How could we add levels?<br />
I will fix this soon.</p>
<p><a href='http://boxmonster.890m.com/wordpress/wp-content/uploads/jetpack-game-part-3.fla'>Source for Jetpack game Part 3 - levels not working.</a><br />
There&#8217;s the source ayways.</p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=86</wfw:commentRss>
		</item>
		<item>
		<title>Tutorial requests.</title>
		<link>http://boxmonster.890m.com/wordpress/?p=77</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=77#comments</comments>
		<pubDate>Tue, 07 Oct 2008 10:33:07 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Flash stuff]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=77</guid>
		<description><![CDATA[Hello hello. I haven&#8217;t written anything on this blog for a while, mostly because I lack of inspiration or ideas for tutorials and stuff. So I&#8217;m asking the readers of this blog for tutorials requests.
If you need a tutorial for something but haven&#8217;t found one you could just send a message to me via email [...]]]></description>
			<content:encoded><![CDATA[<p>Hello hello. I haven&#8217;t written anything on this blog for a while, mostly because I lack of inspiration or ideas for tutorials and stuff. So I&#8217;m asking the readers of this blog for tutorials requests.</p>
<p>If you need a tutorial for something but haven&#8217;t found one you could just send a message to me via email or just comment on this post. </p>
<p>Email:  geekku [@] gmail.com</p>
<p>Bye <img src='http://boxmonster.890m.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=77</wfw:commentRss>
		</item>
		<item>
		<title>Tile Systems - part 2</title>
		<link>http://boxmonster.890m.com/wordpress/?p=61</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=61#comments</comments>
		<pubDate>Thu, 28 Aug 2008 21:41:14 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Actionscript 2 tutorials]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[2]]></category>

		<category><![CDATA[char]]></category>

		<category><![CDATA[control]]></category>

		<category><![CDATA[engine]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[part]]></category>

		<category><![CDATA[tile]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=61</guid>
		<description><![CDATA[Hello. In this tutorial I will show how to create user-controlled movement with the tile engine done in part 1.
Part 1 can be found here.

Anyways, now we have the tile engine. Now we need to add a character that we can control. Just draw a square that&#8217;s 20&#215;20 pixels. Press V and select the square. [...]]]></description>
			<content:encoded><![CDATA[<p>Hello. In this tutorial I will show how to create user-controlled movement with the tile engine done in part 1.</p>
<p><a href="http://boxmonster.890m.com/wordpress/?p=55">Part 1 can be found here.</a><br />
<span id="more-61"></span><br />
Anyways, now we have the tile engine. Now we need to add a character that we can control. Just draw a square that&#8217;s 20&#215;20 pixels. Press V and select the square. Then click on <em>Modify>Convert to symbol&#8230;</em> or press F8 if you&#8217;re using CS3. Then you should do it like this:<br />
<a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/bild13.png"><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/bild13-238x300.png" alt="" title="bild13" width="238" height="300" class="aligncenter size-medium wp-image-62" /></a><br />
<script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>When youre done with that, press OK. Now you can press &#8220;delete&#8221; to remove the &#8220;char&#8221; MovieClip from the stage. Now you need some code. Press F9 or click on <em>Window>Actions</em> And type in this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p61code48'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p6148"><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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code" id="p61code48"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> map:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, 
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, 
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, 
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> mapW:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">10</span>;<span style="color: #808080; font-style: italic;">//The maps width</span>
<span style="color: #000000; font-weight: bold;">var</span> mapH:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">10</span>;<span style="color: #808080; font-style: italic;">//The maps height</span>
<span style="color: #000000; font-weight: bold;">var</span> tileSize:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;<span style="color: #808080; font-style: italic;">//The size of the square tiles in pixels</span>
<span style="color: #000000; font-weight: bold;">var</span> tileCount:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<span style="color: #808080; font-style: italic;">//The tile count</span>
<span style="color: #000000; font-weight: bold;">var</span> y:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<span style="color: #808080; font-style: italic;">//y used in the loop</span>
<span style="color: #000000; font-weight: bold;">var</span> x:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<span style="color: #808080; font-style: italic;">//x used in the other loop</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>y=<span style="color: #cc66cc;">0</span>; y<span style="color: #66cc66;">&lt;</span>mapH; y++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//Creating a loop that controls &quot;y&quot;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>x=<span style="color: #cc66cc;">0</span>; x<span style="color: #66cc66;">&lt;</span>mapW; x++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#91;</span>y<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span> == <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">attachMovie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;1&quot;</span>,<span style="color: #ff0000;">&quot;tile&quot;</span>+tileCount,<span style="color: #cc66cc;">10</span>+tileCount,<span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">_x</span>:tileSize<span style="color: #66cc66;">*</span>x, <span style="color: #0066CC;">_y</span>:tileSize<span style="color: #66cc66;">*</span>y<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
			tileCount++;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #0066CC;">attachMovie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;char&quot;</span>,<span style="color: #ff0000;">&quot;char&quot;</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">_x</span>:<span style="color: #cc66cc;">50</span>, <span style="color: #0066CC;">_y</span>:<span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Attaches the Char movieclip</span>
char.<span style="color: #0066CC;">onEnterFrame</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//this executes every frame</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Key</span>.<span style="color: #0066CC;">isDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">37</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If left arrow key is pressed...</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>calcX<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If theres not a block to the left</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_x</span> -= <span style="color: #cc66cc;">20</span>;<span style="color: #808080; font-style: italic;">//Substract 20 from char._x</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Key</span>.<span style="color: #0066CC;">isDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If right arrow key is pressed...</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>calcX<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, +<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If theres not a block to the right</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_x</span> += <span style="color: #cc66cc;">20</span>;<span style="color: #808080; font-style: italic;">//add 20 to char._x</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Key</span>.<span style="color: #0066CC;">isDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">38</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If up arrow key is pressed...</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>calcY<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If theres not above</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span> -= <span style="color: #cc66cc;">20</span>;<span style="color: #808080; font-style: italic;">//Substract 20 from char._y</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Key</span>.<span style="color: #0066CC;">isDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">40</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If left arrow key is pressed...</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>calcY<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, +<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//If theres not a block to the left</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">_y</span> += <span style="color: #cc66cc;">20</span>;<span style="color: #808080; font-style: italic;">//add 20 to char._y</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> calcX<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>:<span style="color: #0066CC;">MovieClip</span>, offset:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> xPos = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">_x</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>-<span style="color: #cc66cc;">1</span>;<span style="color: #808080; font-style: italic;">//calculates it into a smaller amount that fits into the 20x20 pixel &quot;grid&quot;</span>
	<span style="color: #000000; font-weight: bold;">var</span> yPos = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">_y</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>-<span style="color: #cc66cc;">1</span>;<span style="color: #808080; font-style: italic;">//same here</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Xpos:&quot;</span>+xPos+<span style="color: #ff0000;">&quot; and Ypos:&quot;</span>+yPos<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#91;</span>yPos<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>xPos+offset<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//Checks the map array, and does not hittest anything.</span>
		<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//if theres no block there, it returns &quot;false&quot;</span>
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//else this happens</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> calcY<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>:<span style="color: #0066CC;">MovieClip</span>, offset:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> xPos = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">_x</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>-<span style="color: #cc66cc;">1</span>;<span style="color: #808080; font-style: italic;">//calculates it into a smaller amount that fits into the 20x20 pixel &quot;grid&quot;</span>
	<span style="color: #000000; font-weight: bold;">var</span> yPos = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">_y</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>-<span style="color: #cc66cc;">1</span>;<span style="color: #808080; font-style: italic;">//same here</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Xpos:&quot;</span>+xPos+<span style="color: #ff0000;">&quot; and Ypos:&quot;</span>+yPos<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#91;</span>yPos+offset<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>xPos<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//Checks the map array, and does not hittest anything.</span>
		<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//if theres no block there, it returns &quot;false&quot;</span>
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//Else this happens</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>This is the whole code for the application, and has the stuff from part 1 in it, so you know.<br />
When you&#8217;ve typed in that, you can test it out by pressing ctrl+enter. It should look like this:<br />
<embed src="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/tile1.swf" width="500" height="400"/><br />
<script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>You can steer the red square with the arrow keys. Thats pretty neat. And it doesn&#8217;t use any hitTesting, which is pretty cool. But, if you can&#8217;t get it to work, take this source: <a href='http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/tile1.fla'>Source</a>.<br />
Thats all for now. Oh, and the code is commented with some help if you don&#8217;t understand how it works, and it traces the position of the char which you could take a closer look at.</p>
<p>But, well, cya sometime again. Ill try to invent some other ways to use the tile engine with.</p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=61</wfw:commentRss>
		</item>
		<item>
		<title>About using a tile system in games</title>
		<link>http://boxmonster.890m.com/wordpress/?p=55</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=55#comments</comments>
		<pubDate>Sat, 02 Aug 2008 22:07:36 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Actionscript 2 tutorials]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[engine]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[tile]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=55</guid>
		<description><![CDATA[Hi everybody. This tutorial will be kinda short because of the lack of time I got. I&#8217;ll explain how to create a simple flash program that makes a tile world. And in later tutorials I&#8217;ll show some ways to use the tile engine. But, now I&#8217;ll just show the simplest, most basic stuff with it. [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everybody. This tutorial will be kinda short because of the lack of time I got. I&#8217;ll explain how to create a simple flash program that makes a tile world. And in later tutorials I&#8217;ll show some ways to use the tile engine. But, now I&#8217;ll just show the simplest, most basic stuff with it. </p>
<p>And only so you know, I&#8217;m not either super good at making tile stuff, but I&#8217;ll show you what I can.<br />
So lets go.<br />
<span id="more-55"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The easiest way to create a world is to make a 2-dimensional array. To create a array thats 10&#215;10 tiles big, you do like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p55code52'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5552"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p55code52"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> map:<span style="color: #0066CC;">Array</span>= <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>there&#8217;s the array. To access a specific place you need to type in the x- and y-place for the array;<br />
trace(map[0][0]);<br />
But, a vital this is that the y-pos if first and not the x-pos, when you see it that way, because the first number (map<strong>[0]</strong>[0]) accesses the line number, and the second accesses a specific item in the line. So if you type in<br />
trace(map[0]);<br />
it&#8217;ll show the full line.</p>
<p>Enough with that. Now we have a array, what you need to do next is to create the tile.<br />
You need to draw a 20&#215;20 pixel square with no outlines, when you did that, press <strong>v</strong> and select the square. Then press <strong>F8</strong> or click Modify>Convert to symbol, and type in the following stuff:<br />
<a href='http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/bild1.png'><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/bild1.png" alt="" title="bild1" width="415" height="522" class="alignleft size-full wp-image-56" /></a><br />
Make sure that its exactly as it is on the picture, else it will not work correctly.</p>
<p>Then, go to the actions panel by pressing <strong>F9</strong> or clicking Window>Actions.<br />
Enter this code after the map array:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p55code53'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5553"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p55code53"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> mapW:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">10</span>;<span style="color: #808080; font-style: italic;">//The maps width</span>
<span style="color: #000000; font-weight: bold;">var</span> mapH:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">10</span>;<span style="color: #808080; font-style: italic;">//The maps height</span>
<span style="color: #000000; font-weight: bold;">var</span> tileSize:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;<span style="color: #808080; font-style: italic;">//The size of the square tiles in pixels</span>
<span style="color: #000000; font-weight: bold;">var</span> tileCount:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<span style="color: #808080; font-style: italic;">//The tile count</span>
<span style="color: #000000; font-weight: bold;">var</span> y:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<span style="color: #808080; font-style: italic;">//y used in the loop</span>
<span style="color: #000000; font-weight: bold;">var</span> x:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<span style="color: #808080; font-style: italic;">//x used in the other loop</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>y=<span style="color: #cc66cc;">0</span>; y<span style="color: #66cc66;">&lt;</span>mapH; y++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #808080; font-style: italic;">//Creating a loop that controls &quot;y&quot;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>x=<span style="color: #cc66cc;">0</span>; x<span style="color: #66cc66;">&lt;</span>mapW; x++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#91;</span>y<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span> == <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">attachMovie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;1&quot;</span>,<span style="color: #ff0000;">&quot;tile&quot;</span>+tileCount,<span style="color: #cc66cc;">10</span>+tileCount,<span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">_x</span>:tileSize<span style="color: #66cc66;">*</span>x, <span style="color: #0066CC;">_y</span>:tileSize<span style="color: #66cc66;">*</span>y<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
			tileCount++;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Now test the movie, but nothing happens. The thing you need to do is to change some of the zeros in the array into ones. Overwrite the map array with this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p55code54'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5554"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p55code54"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> map:<span style="color: #0066CC;">Array</span>= <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>And now test your movie. If you did everything right, you should have ended up with something like this:<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="atestgame" /><param name="bgcolor" value="#73D000" /><param name="align" value="middle" /><param name="src" value="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/tile.swf" /><embed type="application/x-shockwave-flash" width="500" height="400" src="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/tile.swf" align="middle" bgcolor="#73D000" name="atestgame"></embed></object><br />
<script type="text/javascript"><!--
google_ad_client = "pub-9869731948444765";
/* I texten */
google_ad_slot = "4061170476";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
The code is pretty easy to understand and I&#8217;ve commented it with useless comments, but maybe they help. If you cant somehow get it to work, take this source and look carefully what you did wrong before posting comments. <a href="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/08/tile.fla">Here&#8217;s the source</a>.</p>
<p>Thanks for reading this tutorial. I will post more tutorials for this to show in what ways you can use the tile stuff. </p>
<p>Well, see you then:)</p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=55</wfw:commentRss>
		</item>
		<item>
		<title>Music Player V0.1</title>
		<link>http://boxmonster.890m.com/wordpress/?p=54</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=54#comments</comments>
		<pubDate>Sat, 02 Aug 2008 15:38:26 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Flash stuff]]></category>

		<category><![CDATA[action script 3]]></category>

		<category><![CDATA[cool]]></category>

		<category><![CDATA[music]]></category>

		<category><![CDATA[player]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=54</guid>
		<description><![CDATA[Today I came home from my summer place, but I&#8217;m not going to stay for so long because I&#8217;m going to Egypt tomorrow. But, well, I&#8217;ve done a simple music player. You can try it here.



   var AdBrite_Title_Color = '0000FF';
   var AdBrite_Text_Color = '000000';
   var AdBrite_Background_Color = 'FFFFFF';
  [...]]]></description>
			<content:encoded><![CDATA[<p>Today I came home from my summer place, but I&#8217;m not going to stay for so long because I&#8217;m going to Egypt tomorrow. But, well, I&#8217;ve done a simple music player. You can try it <a href="http://boxmonster.890m.com/player/sound.html">here</a>.<br />
<span id="more-54"></span><br />
<!-- Begin: AdBrite --><br />
<script type="text/javascript">
   var AdBrite_Title_Color = '0000FF';
   var AdBrite_Text_Color = '000000';
   var AdBrite_Background_Color = 'FFFFFF';
   var AdBrite_Border_Color = 'CCCCCC';
   var AdBrite_URL_Color = '008000';
</script><br />
<span style="white-space:nowrap;"><script src="http://ads.adbrite.com/mb/text_group.php?sid=702798&#038;zs=3436385f3630" type="text/javascript"></script><!--<br />
--><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=702798&#038;afsid=1"><img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /></a></span><br />
<!-- End: AdBrite --></p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=54</wfw:commentRss>
		</item>
		<item>
		<title>Cya in 2 months</title>
		<link>http://boxmonster.890m.com/wordpress/?p=52</link>
		<comments>http://boxmonster.890m.com/wordpress/?p=52#comments</comments>
		<pubDate>Fri, 06 Jun 2008 11:56:44 +0000</pubDate>
		<dc:creator>torskmunken</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://boxmonster.890m.com/wordpress/?p=52</guid>
		<description><![CDATA[Well, today I&#8217;m going to our summer house, which means that I have no internet there, so I&#8217;ll see you when I come home. Then I will write some tutorials I think.
Click on the in-text ads to support me with a small amount of money 


]]></description>
			<content:encoded><![CDATA[<p>Well, today I&#8217;m going to our summer house, which means that I have no internet there, so I&#8217;ll see you when I come home. Then I will write some tutorials I think.</p>
<p>Click on the in-text ads to support me with a small amount of money <img src='http://boxmonster.890m.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span id="more-52"></span><br />
<a href='http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/06/untitled-1.png'><img src="http://boxmonster.890m.com/wordpress/wp-content/uploads/2008/06/untitled-1.png" alt="" title="untitled-1" width="500" height="363" class="alignnone size-full wp-image-53" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://boxmonster.890m.com/wordpress/?feed=rss2&amp;p=52</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Code -->
