<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Benoit Freslon&#039;s blog &#187; ActionScript</title>
	<atom:link href="http://www.benoitfreslon.com/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benoitfreslon.com</link>
	<description>Benoit Freslon&#039;s blog - Game Design, Flash games, ActionScript tutorials ...</description>
	<lastBuildDate>Wed, 01 Sep 2010 15:14:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ActionScript: test collision between a circle and a line</title>
		<link>http://www.benoitfreslon.com/actionscript-test-collision-between-a-circle-and-a-line</link>
		<comments>http://www.benoitfreslon.com/actionscript-test-collision-between-a-circle-and-a-line#comments</comments>
		<pubDate>Thu, 19 Aug 2010 18:27:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[circle]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[collision]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.benoitfreslon.com/?p=1067</guid>
		<description><![CDATA[Preview:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_circle_line_collision_399441599"
			class="flashmovie"
			width="500"
			height="400">
	<param name="movie" value="http://www.benoitfreslon.com/wp-content/uploads/2010/08/circle_line_collision.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.benoitfreslon.com/wp-content/uploads/2010/08/circle_line_collision.swf"
			name="fm_circle_line_collision_399441599"
			width="500"
			height="400">
	<!--<![endif]-->
		   
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>


Download source code: circle_line_collision
Code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172// Test collision between a circle and a line
// coded by Benoit Freslon
//
// www.benoitfreslon.com

// Copy and paste this function into your code and don't forget to import the Point class.

import flash.geom.Point;

// pP1: (Point) the first point of the line
// pP2: (Point) the second [...]]]></description>
			<content:encoded><![CDATA[<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.benoitfreslon.com%2Factionscript-test-collision-between-a-circle-and-a-line&amp;layout=button_count&amp;show_faces=true&amp;width=80&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:80px;height:30px;margin-top:5px;text-align:right;"></iframe><p><strong>Preview:</strong><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_circle_line_collision_1033472265"
			class="flashmovie"
			width="500"
			height="400">
	<param name="movie" value="http://www.benoitfreslon.com/wp-content/uploads/2010/08/circle_line_collision.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.benoitfreslon.com/wp-content/uploads/2010/08/circle_line_collision.swf"
			name="fm_circle_line_collision_1033472265"
			width="500"
			height="400">
	<!--<![endif]-->
		  <a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a> 
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<strong><br />
</strong></p>
<p><strong>Download source code: </strong><strong><a href="http://www.benoitfreslon.com/wp-content/uploads/2010/08/circle_line_collision.zip">circle_line_collision</a></strong></p>
<p><strong>Code:</strong></p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:300px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// Test collision between a circle and a line</span><br />
<span style="color: #009900; font-style: italic;">// coded by Benoit Freslon</span><br />
<span style="color: #009900; font-style: italic;">//</span><br />
<span style="color: #009900; font-style: italic;">// www.benoitfreslon.com</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Copy and paste this function into your code and don't forget to import the Point class.</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// pP1: (Point) the first point of the line</span><br />
<span style="color: #009900; font-style: italic;">// pP2: (Point) the second point of the line</span><br />
<span style="color: #009900; font-style: italic;">// pC: (Point) the point of the circle</span><br />
<span style="color: #009900; font-style: italic;">// pRay: (Number) the ray of the circle</span><br />
<span style="color: #339966; font-weight: bold;">function</span> lineCircleCollision<span style="color: #000000;">&#40;</span>pP1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">,</span>pP2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">,</span>pC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">,</span> pRay<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> x0<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = pC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> y0<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = pC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> x1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = pP1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> y1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = pP1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> x2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = pP2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> y2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = pP2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> n<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x2<span style="color: #000066; font-weight: bold;">-</span>x1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y1<span style="color: #000066; font-weight: bold;">-</span>y0<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>x1<span style="color: #000066; font-weight: bold;">-</span>x0<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y2<span style="color: #000066; font-weight: bold;">-</span>y1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">d</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sqrt</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x2<span style="color: #000066; font-weight: bold;">-</span>x1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>x2<span style="color: #000066; font-weight: bold;">-</span>x1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>y2<span style="color: #000066; font-weight: bold;">-</span>y1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y2<span style="color: #000066; font-weight: bold;">-</span>y1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> dist<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = n<span style="color: #000066; font-weight: bold;">/</span><span style="color: #004993;">d</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>dist <span style="color: #000066; font-weight: bold;">&gt;</span> pRay<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> d1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sqrt</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x0<span style="color: #000066; font-weight: bold;">-</span>x1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>x0<span style="color: #000066; font-weight: bold;">-</span>x1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>y0<span style="color: #000066; font-weight: bold;">-</span>y1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y0<span style="color: #000066; font-weight: bold;">-</span>y1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>d1<span style="color: #000066; font-weight: bold;">-</span>pRay<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #004993;">d</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> d2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sqrt</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>x0<span style="color: #000066; font-weight: bold;">-</span>x2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>x0<span style="color: #000066; font-weight: bold;">-</span>x2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>y0<span style="color: #000066; font-weight: bold;">-</span>y2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span>y0<span style="color: #000066; font-weight: bold;">-</span>y2<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>d2<span style="color: #000066; font-weight: bold;">-</span>pRay<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #004993;">d</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Now test this function</span><br />
<br />
<span style="color: #009900; font-style: italic;">// 2 points for the line</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> pt1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> pt2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// The ray of the circle 30px</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> ray<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Draw the line</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span>pt1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>pt1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>pt2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>pt2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Drag the circle</span><br />
circle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">startDrag</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// And test the collision</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">enterFrame</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> ptC<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>circle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>circle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">enterFrame</span> <span style="color: #000000;">&#40;</span>pEvt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Update circle coordinates</span><br />
&nbsp; &nbsp; ptC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = circle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; ptC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = circle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>lineCircleCollision<span style="color: #000000;">&#40;</span>pt1<span style="color: #000066; font-weight: bold;">,</span>pt2<span style="color: #000066; font-weight: bold;">,</span> ptC<span style="color: #000066; font-weight: bold;">,</span> ray<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Collision ok</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; circle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// No collision</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; circle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benoitfreslon.com/actionscript-test-collision-between-a-circle-and-a-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Orient an object to the mouse cursor</title>
		<link>http://www.benoitfreslon.com/orient-an-object-to-the-mouse-cursor</link>
		<comments>http://www.benoitfreslon.com/orient-an-object-to-the-mouse-cursor#comments</comments>
		<pubDate>Sat, 09 Jan 2010 18:17:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[orientation]]></category>

		<guid isPermaLink="false">http://www.thisisgameplay.com/?p=725</guid>
		<description><![CDATA[How to orient an objet to an other ? Just put those lines and change the instance name myTank.  
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Orienter_un_objet_par_rapport_%C3%A0_un_autre1_1893900437"
			class="flashmovie"
			width="300"
			height="300">
	<param name="movie" value="http://www.benoitfreslon.com/wp-content/uploads/2010/01/Orienter_un_objet_par_rapport_%C3%A0_un_autre1.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.benoitfreslon.com/wp-content/uploads/2010/01/Orienter_un_objet_par_rapport_%C3%A0_un_autre1.swf"
			name="fm_Orienter_un_objet_par_rapport_%C3%A0_un_autre1_1893900437"
			width="300"
			height="300">
	<!--<![endif]-->
		   
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
12345678910111213141516// This object will always look at the mouse cursor
myTank.addEventListener&#40;Event.ENTER_FRAME, &#160;tankEnterFrame&#41;;
// This function will be launched every frame (25 times by seconds)
function tankEnterFrame&#40;pEvt&#41; &#123;
&#160; &#160; // [...]]]></description>
			<content:encoded><![CDATA[<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.benoitfreslon.com%2Forient-an-object-to-the-mouse-cursor&amp;layout=button_count&amp;show_faces=true&amp;width=80&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:80px;height:30px;margin-top:5px;text-align:right;"></iframe><p>How to orient an objet to an other ? Just put those lines and change the instance name myTank.  
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Orienter_un_objet_par_rapport_%C3%A0_un_autre1_1672295178"
			class="flashmovie"
			width="300"
			height="300">
	<param name="movie" value="http://www.benoitfreslon.com/wp-content/uploads/2010/01/Orienter_un_objet_par_rapport_%C3%A0_un_autre1.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.benoitfreslon.com/wp-content/uploads/2010/01/Orienter_un_objet_par_rapport_%C3%A0_un_autre1.swf"
			name="fm_Orienter_un_objet_par_rapport_%C3%A0_un_autre1_1672295178"
			width="300"
			height="300">
	<!--<![endif]-->
		  <a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a> 
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// This object will always look at the mouse cursor</span><br />
myTank<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> &nbsp;tankEnterFrame<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// This function will be launched every frame (25 times by seconds)</span><br />
<span style="color: #339966; font-weight: bold;">function</span> tankEnterFrame<span style="color: #000000;">&#40;</span>pEvt<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// pEvt.currentTarget : myTank</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> mc=pEvt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">currentTarget</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Get the radian angle between the tank and the cursor</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// You can also replace mouseX and mouseY by another coordinates</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> angleRadian=<span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">atan2</span><span style="color: #000000;">&#40;</span>mouseY<span style="color: #000066; font-weight: bold;">-</span>mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span>mouseX<span style="color: #000066; font-weight: bold;">-</span>mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Convert the radian angle in dedree</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> angleDegree=angleRadian<span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">180</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PI</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Set the orientation</span><br />
&nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span>=angleDegree<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Display angle of rotation in degree</span><br />
&nbsp; &nbsp; txtAngle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span>=<span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>angleDegree<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;°&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Download the source code here : <a rel="attachment wp-att-749" href="http://www.benoitfreslon.com/orient-an-object-to-the-mouse-cursor/www-thisisgameplay-com_orient_object_to_mouse_cursor/">[www.thisisgameplay.com]_Orient_object_to_mouse_cursor.fla</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.benoitfreslon.com/orient-an-object-to-the-mouse-cursor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: How to make a game like Jetman &#8211; step 1 &#8211; The Jetman</title>
		<link>http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman</link>
		<comments>http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman#comments</comments>
		<pubDate>Fri, 18 Dec 2009 17:06:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[jetman]]></category>

		<guid isPermaLink="false">http://www.thisisgameplay.com/?p=543</guid>
		<description><![CDATA[In my first tutorial I will show you how to make a flash game like Jetman.
A simple very famous casual game on facebook and very addictive.
Play Jetman

1. First of all you have to download the Adobe Flash IDE: Adobe Flash CS3 or Adobe Flash CS4

We will code the game with ActionScript 3.0 (the programming language [...]]]></description>
			<content:encoded><![CDATA[<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.benoitfreslon.com%2Fhow-to-make-a-game-like-jetman-step-1-the-jetman&amp;layout=button_count&amp;show_faces=true&amp;width=80&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:80px;height:30px;margin-top:5px;text-align:right;"></iframe><p>In my first tutorial I will show you how to make a flash game like Jetman.<img class="alignleft" title="Jetman" src="http://photos-g.ak.fbcdn.net/photos-ak-sf2p/v43/106/4243149646/app_1_4243149646_252.gif" alt="" width="53" height="53" /><br />
A simple very famous casual game on facebook and very addictive.</p>
<p><a href="http://apps.facebook.com/playjetman/challenges.php?landing=true" target="_blank">Play Jetman</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/ZWvvJc09jzs&amp;hl=fr_FR&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/ZWvvJc09jzs&amp;hl=fr_FR&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>1. First of all you have to download the Adobe Flash IDE: Adobe Flash CS3 or Adobe Flash CS4<br />
</strong></p>
<p>We will code the game with ActionScript 3.0 (the programming language of Flash) so you need Adobe Flash CS3 at least.<br />
You can download the free trial version of Adobe Flash here (Mac or Windows) : <a href="https://www.adobe.com/cfusion/tdrc/index.cfm?loc=en&amp;product=flash" target="_blank">https://www.adobe.com/cfusion/tdrc/index.cfm?loc=en&amp;product=flash</a></p>
<p><strong>2. Create your document<br />
</strong></p>
<ul>
<li>Open Flash.</li>
<li>Create a new ActionScript 3.0 document.</li>
<li>On the properties set the<strong> framerate to</strong> <strong>25fps.</strong></li>
<li>And set the <strong>background color </strong>to <strong>black.<br />
</strong></li>
</ul>
<p><strong>3. Create Jetman MovieClip</strong></p>
<p>Flash uses graphic objects called MovieClip. So we have to create the Jetman&#8217;s MovieClip.</p>
<ul>
<li>Click on the <strong>Rectangle tool</strong> on the tools bar. (on the left)</li>
</ul>
<p style="padding-left: 60px;"><a rel="attachment wp-att-552" href="http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman/create_box-2/"><img class="size-full wp-image-552 alignnone" title="create_box" src="http://www.thisisgameplay.com/wp-content/uploads/2009/11/create_box1.jpg" alt="create_box" width="29" height="32" /></a></p>
<ul>
<li>Then drag and drop on the stage to <strong>create a rectangle</strong> about <strong>width:50px</strong> and <strong>height:15px</strong> (you can modify your shape dimentions later).</li>
<li>Select<strong> all your shape including the border</strong>. You can also use a<strong> double click.</strong></li>
<li>Do a right click on your selected shape and click on <strong>Convert to Symbol</strong>.</li>
<li>Write this symbol&#8217;s<strong> name</strong> : <strong>Jetman</strong> (not jetman or JETMAN).</li>
<li>Then click <strong>OK.</strong></li>
</ul>
<p>Now you can see your Symbol <strong>Jetman </strong>into your Library  (on the right). If you don&#8217;t see the Library Press F11 key.<br />
You have 1 instance of the Jetman symbol on your stage. Good. <strong>We just created a MovieClip</strong>.</p>
<p>In order to interact with the jetman MovieClip with ActionScript, we have the rename the instance&#8217;s name on the stage.</p>
<ul>
<li>Click on the Jetman&#8217;s instance on the stage.</li>
</ul>
<p style="padding-left: 60px;"><a rel="attachment wp-att-554" href="http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman/instance/"><img class="alignnone size-full wp-image-554" title="instance" src="http://www.thisisgameplay.com/wp-content/uploads/2009/11/instance.jpg" alt="instance" width="82" height="53" /></a></p>
<ul>
<li>Then go to the properties on the bottom and set the instance&#8217;s name to <strong>jetman </strong>(not Jetman or JETMAN) it&#8217;s very important.</li>
</ul>
<p><a rel="attachment wp-att-555" href="http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman/instance_name/"><img class="alignnone size-full wp-image-555" title="instance_name" src="http://www.thisisgameplay.com/wp-content/uploads/2009/11/instance_name.jpg" alt="instance_name" width="346" height="128" /></a></p>
<p>It&#8217;s done! Now we can move the instance with ActionScript.</p>
<p><strong>4. Starting to code</strong></p>
<p>You have differents ways to code with ActionScript. We will use the easier. (Coding into layers)</p>
<ul>
<li><strong>Create a new layer</strong> on the timeline (Click on the button on the left bottom corner).</li>
<li><strong>Put the layer on the top:</strong> drag and drop the layer.</li>
<li>You can <strong>rename</strong> the layer with a double click or Right Click then rename.</li>
<li>Then select the<strong> first frame</strong> (here in black).</li>
</ul>
<p><a rel="attachment wp-att-556" href="http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman/layer/"><img class="alignnone size-full wp-image-556" title="layer" src="http://www.thisisgameplay.com/wp-content/uploads/2009/11/layer.jpg" alt="layer" width="188" height="94" /></a></p>
<ul>
<li>Finally go to the windows menu &gt; Actions or press the F9 key.</li>
</ul>
<p>A new windows is opening : The Actions window. We will to write all our code here.</p>
<ul>
<li>Copy and paste this Actionscript 3 code (After codinf into your layer you should see a little <strong>a</strong> into this frame):</li>
</ul>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:300px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// Please don't remove this comment.</span><br />
<span style="color: #009900; font-style: italic;">// Code by Benoit Freslon.</span><br />
<span style="color: #009900; font-style: italic;">// Tutorials, Flash games:</span><br />
<span style="color: #009900; font-style: italic;">// http://www.thisisgameplay.com</span><br />
<span style="color: #009900; font-style: italic;">//</span><br />
<br />
<span style="color: #009900; font-style: italic;">////// Game balance</span><br />
<span style="color: #009900; font-style: italic;">// Jetpack's boost speed</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> speedBoost = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// Gravity</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> gravity = <span style="color: #000066; font-weight: bold;">.</span>8<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// Speed limit</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> speedMax = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">////// Global variables don't touch those one</span><br />
<span style="color: #009900; font-style: italic;">// Jetman is using his jetpack ?</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> boost = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// Jetman's current speed</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> speed = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// 25 times by seconds this function will be launched</span><br />
<span style="color: #339966; font-weight: bold;">function</span> jetmanEnterFrame<span style="color: #000000;">&#40;</span>pEvt<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// If boost == true</span><br />
&nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>boost<span style="color: #000000;">&#41;</span><br />
&nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// The speed changes</span><br />
&nbsp;speed = speedBoost<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp;<span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// Else the gravity decrease jetman's speed</span><br />
&nbsp;speed <span style="color: #000066; font-weight: bold;">+</span>= gravity<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// If the current speed is to hi</span><br />
&nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>speed <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> speedMax<span style="color: #000000;">&#41;</span><br />
&nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// Limit the speed</span><br />
&nbsp;speed = speedMax<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// If the current speed is to low</span><br />
&nbsp;<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>speed <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">-</span>speedMax<span style="color: #000000;">&#41;</span><br />
&nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// Limit the speed</span><br />
&nbsp;speed = <span style="color: #000066; font-weight: bold;">-</span>speedMax<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// Every frame jetman will move vertically. (y axis)</span><br />
&nbsp;jetman<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span>= speed<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp;<span style="color: #009900; font-style: italic;">// If jetman is out of the screen</span><br />
&nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>jetman<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">450</span><span style="color: #000000;">&#41;</span><br />
&nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp;jetman<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp;<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #009900; font-style: italic;">// Add a event listener to launch the jetmanEnterFrame function every frames</span><br />
jetman<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> jetmanEnterFrame<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// If the mouse is pressed</span><br />
<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">mouseDown</span><span style="color: #000000;">&#40;</span>pEvt<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// Set boost to true</span><br />
&nbsp;boost = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #009900; font-style: italic;">// Id the mouse is released</span><br />
<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">mouseUp</span><span style="color: #000000;">&#40;</span>pEvt<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp;<span style="color: #009900; font-style: italic;">// Set boost to false</span><br />
&nbsp;boost = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #009900; font-style: italic;">// Detecting the mouse inputs (MOUSE_DOWN and MOUSE_UP) on the entire &quot;stage&quot;</span><br />
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_DOWN</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">mouseDown</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_UP</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">mouseUp</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<ul>
<li>Finally test your game. (hit CTRL+ENTER)</li>
</ul>
<p>You should see that:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_www.thisisgameplay.com_Jetman_step1_1092008725"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="./wp-content/uploads/2009/12/www.thisisgameplay.com_Jetman_step1.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="./wp-content/uploads/2009/12/www.thisisgameplay.com_Jetman_step1.swf"
			name="fm_www.thisisgameplay.com_Jetman_step1_1092008725"
			width="550"
			height="400">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Download the source file here:</p>
<p><a rel="attachment wp-att-694" href="http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman/www-thisisgameplay-com_jetman_step1/">[www.thisisgameplay.com]_Jetman_step1.fla</a></p>
<p>Download the compiled file here:</p>
<p><a rel="attachment wp-att-703" href="http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman/www-thisisgameplay-com_jetman_step1-2/">[www.thisisgameplay.com]_Jetman_step1.swf</a></p>
<p>Next step the level design&#8230; ;)</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">http://photos-g.ak.fbcdn.net/photos-ak-sf2p/v43/106/4243149646/app_1_4243149646_252.gif</div>
]]></content:encoded>
			<wfw:commentRss>http://www.benoitfreslon.com/how-to-make-a-game-like-jetman-step-1-the-jetman/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash CS5 builds Iphone applications</title>
		<link>http://www.benoitfreslon.com/flash-cs5-builds-iphone-applications</link>
		<comments>http://www.benoitfreslon.com/flash-cs5-builds-iphone-applications#comments</comments>
		<pubDate>Tue, 06 Oct 2009 09:58:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.thisisgameplay.com/?p=523</guid>
		<description><![CDATA[Flash Professional CS5 will enable you to build applications for iPhone and iPod touch using ActionScript 3. These applications can be delivered to iPhone and iPod touch users through the Apple App Store.*
A public beta of Flash Professional CS5 with prerelease support for building applications for iPhone is planned for later this year. Sign up [...]]]></description>
			<content:encoded><![CDATA[<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.benoitfreslon.com%2Fflash-cs5-builds-iphone-applications&amp;layout=button_count&amp;show_faces=true&amp;width=80&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:80px;height:30px;margin-top:5px;text-align:right;"></iframe><p>Flash Professional CS5 will enable you to build applications for iPhone and iPod touch using ActionScript 3. These applications can be delivered to iPhone and iPod touch users through the Apple App Store.*</p>
<p>A public beta of Flash Professional CS5 with prerelease support for building applications for iPhone is planned for later this year. <a href="http://www.adobe.com/go/flashprobetanotify">Sign up to be notified when the beta starts</a>.</p>
<p>At MAX 2009, Adobe showed a number of applications and games for iPhone that have been built using a prerelease version of Flash Professional CS5. These applications are available now for you to download from the Apple App Store.</p>
<p>Go to the official article on labs.adobe.com: <a href="http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/#divider" target="_blank">http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/#divider</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.benoitfreslon.com/flash-cs5-builds-iphone-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roll And Jump released</title>
		<link>http://www.benoitfreslon.com/roll-and-jump-released</link>
		<comments>http://www.benoitfreslon.com/roll-and-jump-released#comments</comments>
		<pubDate>Sun, 27 Sep 2009 01:50:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.thisisgameplay.com/?p=482</guid>
		<description><![CDATA[I&#8217;m proud to present you my last game: Roll And Jump. The game was designer for Iphone and IPod Touch.
If you are interrested in to play this game on your Iphone please contact me.
You can play here for free on your web browzer here:
PLAY ROLL AND JUMP
Have fun!
]]></description>
			<content:encoded><![CDATA[<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.benoitfreslon.com%2Froll-and-jump-released&amp;layout=button_count&amp;show_faces=true&amp;width=80&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:80px;height:30px;margin-top:5px;text-align:right;"></iframe><p><a href="http://www.thisisgameplay.com/my-games/roll-and-jump"><img class="size-full wp-image-483 alignleft" title="Roll And Jump Iphone" src="http://www.thisisgameplay.com/wp-content/uploads/2009/09/roll_and_jump_iphone_.jpg" alt="Roll And Jump Iphone" width="89" height="158" /></a>I&#8217;m proud to present you my last game: <strong>Roll And Jump</strong>. The game was designer for <strong>Iphone</strong> and <strong>IPod Touch</strong>.<br />
If you are interrested in to play this game on your Iphone please contact me.<br />
You can play here for free on your web browzer here:</p>
<p><strong><a title="Play Roll And Jump" href="http://www.thisisgameplay.com/my-games/roll-and-jump" target="_self">PLAY ROLL AND JUMP</a></strong></p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.benoitfreslon.com/roll-and-jump-released/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Win 80% performance on Flash ActionScript 2 project</title>
		<link>http://www.benoitfreslon.com/win-80-performance-on-flash-actionscript-2-project</link>
		<comments>http://www.benoitfreslon.com/win-80-performance-on-flash-actionscript-2-project#comments</comments>
		<pubDate>Wed, 18 Mar 2009 12:17:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[optimisation]]></category>

		<guid isPermaLink="false">http://www.thisisgameplay.com/?p=90</guid>
		<description><![CDATA[If you have lot of AS 2.0 projets like me you should be happy to know that you could win 80% performance on your projets with 4 lines of ActionScript. But this tip works only on web based projets.]]></description>
			<content:encoded><![CDATA[<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.benoitfreslon.com%2Fwin-80-performance-on-flash-actionscript-2-project&amp;layout=button_count&amp;show_faces=true&amp;width=80&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:80px;height:30px;margin-top:5px;text-align:right;"></iframe><p>If you have lot of AS 2.0 projets like me you should be happy to know that you could win 80% performance on your projets with 4 lines of ActionScript<strong>.<br />
</strong></p>
<h3>First compile your AS 2.0 project with Flash.</h3>
<p>Export your swf file in AS 2.0. (eg: your_as2_project.swf)</p>
<h3>Then create <strong>an AS 3.0 loader</strong> with Flash CS3 or better.</h3>
<p>Keep the <strong>same framerate </strong>on your loader. The <strong>same dimentions</strong> and the <strong>same background color</strong>. Put those lines into your AS 3.0 loader and replace the swf file with your file name.</p>
<pre lang="ACTIONSCRIPT3">var request:URLRequest = new URLRequest("your_as2_project.swf");
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);</pre>
<h3>Finnaly compile your AS 3 loader.</h3>
<p>It&#8217;s magic it works perfectly. It&#8217;s more smoothly and more faster. Thanks AVM2 ;).</p>
<h3>Very important notes :</h3>
<ul>
<li><strong>Delete all your TextField variables on you AS 2.0 file</strong> and use instance name. In AS 3.0 AVM2 doesn&#8217;t support TextField variables.</li>
<li><strong>You couldn&#8217;t send HTML parameters to swf</strong> direclty to your AS 2.0 swf. You have to use a LocalConnection in order to send and receive informations between your 2 swf.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.benoitfreslon.com/win-80-performance-on-flash-actionscript-2-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
