<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Detect collision between two objects</title>
	<atom:link href="http://www.riacodes.com/flash/detect-collision-between-two-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.riacodes.com/flash/detect-collision-between-two-objects/</link>
	<description>Resources, tutorials , tips &#38; tricks for RIA : Flex, Flash, Air, AS3</description>
	<lastBuildDate>Thu, 29 Jul 2010 05:04:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: Cole Mizzi</title>
		<link>http://www.riacodes.com/flash/detect-collision-between-two-objects/comment-page-1/#comment-1047</link>
		<dc:creator>Cole Mizzi</dc:creator>
		<pubDate>Wed, 07 Apr 2010 22:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.riacodes.com/?p=407#comment-1047</guid>
		<description>I am a novice &quot; actionscripter&quot; and experimented around with the code provided to come up perhaps with a better code. The following allows you to move the car all around and to use the key after collision with the object, while stopping car_mc. Can you tell me if this is effective code, or is there a more efficient way?


Copy and paste below
V V V V V V



stage.addEventListener(KeyboardEvent.KEY_DOWN,moveCar);

function moveCar(evt:KeyboardEvent) {
	if (evt.keyCode == Keyboard.LEFT)  {
		car_mc.x -=8;
		if (car_mc.hitTestObject(line_mc)) {
			car_mc.x +=8;
		}
	}
	
	if (evt.keyCode == Keyboard.RIGHT)  {
		car_mc.x +=8;
		if (car_mc.hitTestObject(line_mc)) {
			car_mc.x -=8;
		}
	}
	if (evt.keyCode == Keyboard.UP)  {
		car_mc.y -=8;
		if (car_mc.hitTestObject(line_mc)) {
			car_mc.y +=8;
		}
	}
	if (evt.keyCode == Keyboard.DOWN)  {
		car_mc.y +=8;
		if (car_mc.hitTestObject(line_mc)) {
			car_mc.y -=8;
		}
	}
}


^^ ^ ^^ ^ ^^
Copy and paste above</description>
		<content:encoded><![CDATA[<p>I am a novice &#8221; actionscripter&#8221; and experimented around with the code provided to come up perhaps with a better code. The following allows you to move the car all around and to use the key after collision with the object, while stopping car_mc. Can you tell me if this is effective code, or is there a more efficient way?</p>
<p>Copy and paste below<br />
V V V V V V</p>
<p>stage.addEventListener(KeyboardEvent.KEY_DOWN,moveCar);</p>
<p>function moveCar(evt:KeyboardEvent) {<br />
	if (evt.keyCode == Keyboard.LEFT)  {<br />
		car_mc.x -=8;<br />
		if (car_mc.hitTestObject(line_mc)) {<br />
			car_mc.x +=8;<br />
		}<br />
	}</p>
<p>	if (evt.keyCode == Keyboard.RIGHT)  {<br />
		car_mc.x +=8;<br />
		if (car_mc.hitTestObject(line_mc)) {<br />
			car_mc.x -=8;<br />
		}<br />
	}<br />
	if (evt.keyCode == Keyboard.UP)  {<br />
		car_mc.y -=8;<br />
		if (car_mc.hitTestObject(line_mc)) {<br />
			car_mc.y +=8;<br />
		}<br />
	}<br />
	if (evt.keyCode == Keyboard.DOWN)  {<br />
		car_mc.y +=8;<br />
		if (car_mc.hitTestObject(line_mc)) {<br />
			car_mc.y -=8;<br />
		}<br />
	}<br />
}</p>
<p>^^ ^ ^^ ^ ^^<br />
Copy and paste above</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shirley B</title>
		<link>http://www.riacodes.com/flash/detect-collision-between-two-objects/comment-page-1/#comment-989</link>
		<dc:creator>shirley B</dc:creator>
		<pubDate>Sat, 20 Mar 2010 05:38:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.riacodes.com/?p=407#comment-989</guid>
		<description>Thanks for the tutorial. I was trying to create a similar situation between a ball and a person. this was useful.</description>
		<content:encoded><![CDATA[<p>Thanks for the tutorial. I was trying to create a similar situation between a ball and a person. this was useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subash</title>
		<link>http://www.riacodes.com/flash/detect-collision-between-two-objects/comment-page-1/#comment-757</link>
		<dc:creator>Subash</dc:creator>
		<pubDate>Mon, 11 Jan 2010 13:34:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.riacodes.com/?p=407#comment-757</guid>
		<description>the tutorial is really great, i was wondering as the finish line for the car is one object, what if i need to make the car smashing to a tree for a game which am developing, i have a tree movieclip on stage as you have &quot;line_mc&quot; and instance name as tree_mc, wheni set the same tree by manually duplicating and placing where i want and  use the hittestobject it works only for one tree not for multiple trees, could you suggest on this

thx</description>
		<content:encoded><![CDATA[<p>the tutorial is really great, i was wondering as the finish line for the car is one object, what if i need to make the car smashing to a tree for a game which am developing, i have a tree movieclip on stage as you have &#8220;line_mc&#8221; and instance name as tree_mc, wheni set the same tree by manually duplicating and placing where i want and  use the hittestobject it works only for one tree not for multiple trees, could you suggest on this</p>
<p>thx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Collision Detection in AS3 &#124; FREE flash tutorials &#124; The Dude</title>
		<link>http://www.riacodes.com/flash/detect-collision-between-two-objects/comment-page-1/#comment-218</link>
		<dc:creator>Collision Detection in AS3 &#124; FREE flash tutorials &#124; The Dude</dc:creator>
		<pubDate>Thu, 20 Aug 2009 15:51:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.riacodes.com/?p=407#comment-218</guid>
		<description>[...] View tutorial   // [...]</description>
		<content:encoded><![CDATA[<p>[...] View tutorial   // [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
