<?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: AS3 Character Movement: Asteroids Style 360 Degree Movement</title>
	<atom:link href="http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/feed" rel="self" type="application/rss+xml" />
	<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement</link>
	<description>Learn to Make Flash Games, Applications, and Websites</description>
	<lastBuildDate>Fri, 16 Dec 2011 19:32:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: ken</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-6226</link>
		<dc:creator>ken</dc:creator>
		<pubDate>Sun, 20 Nov 2011 13:16:38 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-6226</guid>
		<description>hi, when i try to move my object up it move right, my object starting position is facing up the screen.the player is a snow border and he has to avoid trees. my code is below:

package src 

{
	
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.utils.Timer;
	import flash.events.TimerEvent; 
	import flash.text.TextField; 

	
	public class DocumentClass extends MovieClip 
	{
		public var mutiple:Array;
		public var tree:Tree;
		public var gameTimer:Timer;

		// Assign 4 booleans for the 4 arrow keys
		public var keypressUp = false;
		public var keypressDown = false;
 		public var keypressLeft = false;
 		public var keypressRight = false
		
		public var speed:Number = 0.3;
		public var rotateSpeed:Number = 5;
		public var vx:Number = 0;
		public var vy:Number = 0;
		public var friction:Number = 0.95;

		
		
		public function DocumentClass() 
		
		{
			mutiple = new Array();
			var newTree = new Tree( 100, -15 );
			mutiple.push( newTree );
			addChild( newTree );

			addEventListener(Event.ADDED_TO_STAGE,
init); 
			addEventListener(Event.ENTER_FRAME, loop, false, 0, true);

			gameTimer = new Timer( 25 );
			gameTimer.addEventListener( TimerEvent.TIMER, update );
			gameTimer.start();

		}
		
		public function init(event:Event):void
		{
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
 			stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
			
		}
		
		public function onKeyDown(e:KeyboardEvent):void
		{
			
			if (e.keyCode == 38)
 			{
 				keypressUp = true;
 			}
 			else if (e.keyCode == 40)
 			{
 				keypressDown = true;
 			}
 			else if (e.keyCode == 37)
 			{
 				keypressLeft = true;
 			}
 			else if (e.keyCode == 39)
 			{
 				keypressRight = true;
 			}
 
		}
		
		public function onKeyUp(e:KeyboardEvent)
 		{
 			
			if (e.keyCode == 38)
			{
				keypressUp = false;
			}
			else if (e.keyCode == 40)
			{
				keypressDown = false;
			}
			else if (e.keyCode == 37)
			{
				keypressLeft = false;
			}
			else if (e.keyCode == 39)
			{
				keypressRight = false;
			}
		
 		}
 
		public function loop(e:Event) : void
		{
			 
			 if (keypressUp)
			 {
				vy += Math.sin(degreesToRadians(rotation)) * speed;
				vx += Math.cos(degreesToRadians(rotation)) * speed;

			 }
			 else 
			 {
				vy *= friction;
				vx *= friction;
			 }

			 if (keypressDown)
			 {
			 	
			 }
			 if (keypressLeft)
			 {
			 	// rotate the object
			 	player.rotation -= rotateSpeed;
			 }
			 if (keypressRight)
			 {
			 	// rotate the object
			 	player.rotation += rotateSpeed;

			 }
			 
			player.y += vy;
			player.x += vx;
 			
			
			if (player.x &gt; stage.stageWidth)
				player.x = 0;
			else if (player.x  stage.stageHeight)
				player.y = 0;
			else if (player.y &lt; 0)
				player.y = stage.stageHeight;
			 
 
		}
		
		public function update( timerEvent:TimerEvent ):void 
		{
			if ( Math.random() &lt; 0.1 )
			{
				var randomX:Number = Math.random() * 800;
				var newTree = new Tree( randomX, -15 );
				mutiple.push( newTree );
				addChild( newTree ); 
			}
			
		
			
			for each ( var tree:Tree in mutiple ) 
			{
				tree.moveDownEverySecond();
				
				if ( player.hitTestObject( tree ) ) 
				{
						gameTimer.stop();
						

				}
				
			}

		}
		
		public function degreesToRadians(degrees:Number) : Number
		{
			return degrees * Math.PI / 180;
		}

	
	}
	
	
}

any help will be appreciated</description>
		<content:encoded><![CDATA[<p>hi, when i try to move my object up it move right, my object starting position is facing up the screen.the player is a snow border and he has to avoid trees. my code is below:</p>
<p>package src </p>
<p>{</p>
<p>	import flash.display.MovieClip;<br />
	import flash.events.*;<br />
	import flash.utils.Timer;<br />
	import flash.events.TimerEvent;<br />
	import flash.text.TextField; </p>
<p>	public class DocumentClass extends MovieClip<br />
	{<br />
		public var mutiple:Array;<br />
		public var tree:Tree;<br />
		public var gameTimer:Timer;</p>
<p>		// Assign 4 booleans for the 4 arrow keys<br />
		public var keypressUp = false;<br />
		public var keypressDown = false;<br />
 		public var keypressLeft = false;<br />
 		public var keypressRight = false</p>
<p>		public var speed:Number = 0.3;<br />
		public var rotateSpeed:Number = 5;<br />
		public var vx:Number = 0;<br />
		public var vy:Number = 0;<br />
		public var friction:Number = 0.95;</p>
<p>		public function DocumentClass() </p>
<p>		{<br />
			mutiple = new Array();<br />
			var newTree = new Tree( 100, -15 );<br />
			mutiple.push( newTree );<br />
			addChild( newTree );</p>
<p>			addEventListener(Event.ADDED_TO_STAGE,<br />
init);<br />
			addEventListener(Event.ENTER_FRAME, loop, false, 0, true);</p>
<p>			gameTimer = new Timer( 25 );<br />
			gameTimer.addEventListener( TimerEvent.TIMER, update );<br />
			gameTimer.start();</p>
<p>		}</p>
<p>		public function init(event:Event):void<br />
		{<br />
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);<br />
 			stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);</p>
<p>		}</p>
<p>		public function onKeyDown(e:KeyboardEvent):void<br />
		{</p>
<p>			if (e.keyCode == 38)<br />
 			{<br />
 				keypressUp = true;<br />
 			}<br />
 			else if (e.keyCode == 40)<br />
 			{<br />
 				keypressDown = true;<br />
 			}<br />
 			else if (e.keyCode == 37)<br />
 			{<br />
 				keypressLeft = true;<br />
 			}<br />
 			else if (e.keyCode == 39)<br />
 			{<br />
 				keypressRight = true;<br />
 			}</p>
<p>		}</p>
<p>		public function onKeyUp(e:KeyboardEvent)<br />
 		{</p>
<p>			if (e.keyCode == 38)<br />
			{<br />
				keypressUp = false;<br />
			}<br />
			else if (e.keyCode == 40)<br />
			{<br />
				keypressDown = false;<br />
			}<br />
			else if (e.keyCode == 37)<br />
			{<br />
				keypressLeft = false;<br />
			}<br />
			else if (e.keyCode == 39)<br />
			{<br />
				keypressRight = false;<br />
			}</p>
<p> 		}</p>
<p>		public function loop(e:Event) : void<br />
		{</p>
<p>			 if (keypressUp)<br />
			 {<br />
				vy += Math.sin(degreesToRadians(rotation)) * speed;<br />
				vx += Math.cos(degreesToRadians(rotation)) * speed;</p>
<p>			 }<br />
			 else<br />
			 {<br />
				vy *= friction;<br />
				vx *= friction;<br />
			 }</p>
<p>			 if (keypressDown)<br />
			 {</p>
<p>			 }<br />
			 if (keypressLeft)<br />
			 {<br />
			 	// rotate the object<br />
			 	player.rotation -= rotateSpeed;<br />
			 }<br />
			 if (keypressRight)<br />
			 {<br />
			 	// rotate the object<br />
			 	player.rotation += rotateSpeed;</p>
<p>			 }</p>
<p>			player.y += vy;<br />
			player.x += vx;</p>
<p>			if (player.x &gt; stage.stageWidth)<br />
				player.x = 0;<br />
			else if (player.x  stage.stageHeight)<br />
				player.y = 0;<br />
			else if (player.y &lt; 0)<br />
				player.y = stage.stageHeight;</p>
<p>		}</p>
<p>		public function update( timerEvent:TimerEvent ):void<br />
		{<br />
			if ( Math.random() &lt; 0.1 )<br />
			{<br />
				var randomX:Number = Math.random() * 800;<br />
				var newTree = new Tree( randomX, -15 );<br />
				mutiple.push( newTree );<br />
				addChild( newTree );<br />
			}</p>
<p>			for each ( var tree:Tree in mutiple )<br />
			{<br />
				tree.moveDownEverySecond();</p>
<p>				if ( player.hitTestObject( tree ) )<br />
				{<br />
						gameTimer.stop();</p>
<p>				}</p>
<p>			}</p>
<p>		}</p>
<p>		public function degreesToRadians(degrees:Number) : Number<br />
		{<br />
			return degrees * Math.PI / 180;<br />
		}</p>
<p>	}</p>
<p>}</p>
<p>any help will be appreciated</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Slay</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-5547</link>
		<dc:creator>Slay</dc:creator>
		<pubDate>Mon, 28 Feb 2011 07:33:15 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-5547</guid>
		<description>Hi

I really like this tutorial – And I’m trying to make a simple game with it, but the catch is that I want to build the game with Flashbuilder 4 and not Flash Cs5.
*******************************************
Now I have made a “Main class” that will import and Add the class “Player” to the stage. 
The class “Player” is basically a (Ship) that imports a MovieClip from flash with linkage.
*******************************************
package
{
	import flash.display.Sprite;
	
	import fla10.colosseumGame.Units.Player;
	
	public class ColosseumGame extends Sprite
	{
		private var _Ship:Player;
		
		public function ColosseumGame()
		{
			_Ship = new Player();
			addChild(_Ship);
			_Ship.x = 200;
			_Ship.y = 100;
			
		}
	}
}

*******************************************

package fla10.colosseumGame.Units
{
	import com.senocular.utils.KeyObject;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.ui.Keyboard;
	import flash.display.Stage;
	
	public class Player extends Sprite
	{
		private var _player:Expo_PlayerUnit;
		
		private var _key:KeyObject;
		
		private var _speed:Number = 0.3;
		private var _rotateSpeed:Number = 5;
		private var _vx:Number = 0;
		private var _vy:Number = 0;
		private var _friction:Number = 0.95;
		
		public function Player()
		{
			_player = new Expo_PlayerUnit();
			this.addChild(_player);
			
			_key = new KeyObject(stage);
			
			_player.addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
			
		}
		
		public function loop(evt:Event):void
		{
			if(_key.isDown(Keyboard.UP))
			{
				_vx += Math.sin(degreesToRadians(rotation)) * _speed;
				_vy += Math.sin(degreesToRadians(rotation)) * _speed;
			}
			else
			{
				_vx *= _friction;
				_vy *= _friction;
			}
			

			if(_key.isDown(Keyboard.RIGHT))
				rotation += _rotateSpeed;
			
			else if(_key.isDown(Keyboard.LEFT))
				rotation -= _rotateSpeed;
			

			x += _vx;
			y += _vy;
			
			if(x &gt; stage.stageWidth)
				x = 0;
			else if(x  stage.stageHeight)
				y = 0;
			else if(y &lt; 0)
				y = stage.stageHeight;
		}
		
		public function degreesToRadians(degrees:Number):Number
		{
			return degrees * Math.PI / 180;
		}
	}
	
}

*******************************************

Now I don’t get any errors but nothing appears on the stage…

Please help me with this.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I really like this tutorial – And I’m trying to make a simple game with it, but the catch is that I want to build the game with Flashbuilder 4 and not Flash Cs5.<br />
*******************************************<br />
Now I have made a “Main class” that will import and Add the class “Player” to the stage.<br />
The class “Player” is basically a (Ship) that imports a MovieClip from flash with linkage.<br />
*******************************************<br />
package<br />
{<br />
	import flash.display.Sprite;</p>
<p>	import fla10.colosseumGame.Units.Player;</p>
<p>	public class ColosseumGame extends Sprite<br />
	{<br />
		private var _Ship:Player;</p>
<p>		public function ColosseumGame()<br />
		{<br />
			_Ship = new Player();<br />
			addChild(_Ship);<br />
			_Ship.x = 200;<br />
			_Ship.y = 100;</p>
<p>		}<br />
	}<br />
}</p>
<p>*******************************************</p>
<p>package fla10.colosseumGame.Units<br />
{<br />
	import com.senocular.utils.KeyObject;</p>
<p>	import flash.display.Sprite;<br />
	import flash.events.Event;<br />
	import flash.ui.Keyboard;<br />
	import flash.display.Stage;</p>
<p>	public class Player extends Sprite<br />
	{<br />
		private var _player:Expo_PlayerUnit;</p>
<p>		private var _key:KeyObject;</p>
<p>		private var _speed:Number = 0.3;<br />
		private var _rotateSpeed:Number = 5;<br />
		private var _vx:Number = 0;<br />
		private var _vy:Number = 0;<br />
		private var _friction:Number = 0.95;</p>
<p>		public function Player()<br />
		{<br />
			_player = new Expo_PlayerUnit();<br />
			this.addChild(_player);</p>
<p>			_key = new KeyObject(stage);</p>
<p>			_player.addEventListener(Event.ENTER_FRAME, loop, false, 0, true);</p>
<p>		}</p>
<p>		public function loop(evt:Event):void<br />
		{<br />
			if(_key.isDown(Keyboard.UP))<br />
			{<br />
				_vx += Math.sin(degreesToRadians(rotation)) * _speed;<br />
				_vy += Math.sin(degreesToRadians(rotation)) * _speed;<br />
			}<br />
			else<br />
			{<br />
				_vx *= _friction;<br />
				_vy *= _friction;<br />
			}</p>
<p>			if(_key.isDown(Keyboard.RIGHT))<br />
				rotation += _rotateSpeed;</p>
<p>			else if(_key.isDown(Keyboard.LEFT))<br />
				rotation -= _rotateSpeed;</p>
<p>			x += _vx;<br />
			y += _vy;</p>
<p>			if(x &gt; stage.stageWidth)<br />
				x = 0;<br />
			else if(x  stage.stageHeight)<br />
				y = 0;<br />
			else if(y &lt; 0)<br />
				y = stage.stageHeight;<br />
		}</p>
<p>		public function degreesToRadians(degrees:Number):Number<br />
		{<br />
			return degrees * Math.PI / 180;<br />
		}<br />
	}</p>
<p>}</p>
<p>*******************************************</p>
<p>Now I don’t get any errors but nothing appears on the stage…</p>
<p>Please help me with this.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: luuk</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-5429</link>
		<dc:creator>luuk</dc:creator>
		<pubDate>Fri, 11 Feb 2011 18:03:07 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-5429</guid>
		<description>hey great tutorial

you should create a section about updating the earlier character movement series to use the 360 degree movement</description>
		<content:encoded><![CDATA[<p>hey great tutorial</p>
<p>you should create a section about updating the earlier character movement series to use the 360 degree movement</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Malcolm</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-5204</link>
		<dc:creator>Malcolm</dc:creator>
		<pubDate>Sun, 15 Aug 2010 20:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-5204</guid>
		<description>So I tried this tutorial, and was having the toughest time getting my version to work (Flash CS5 Pro). I kept getting an null object error (stage was set to null).  Then I noticed your tutorial file had the Flash Player set to FP 9, not 10.  So I changed the player in MY .fla file to use FP9 and it worked.

I&#039;m wondering if you have any knowledge of some error with regards to accessing stage from the document class in FP10?</description>
		<content:encoded><![CDATA[<p>So I tried this tutorial, and was having the toughest time getting my version to work (Flash CS5 Pro). I kept getting an null object error (stage was set to null).  Then I noticed your tutorial file had the Flash Player set to FP 9, not 10.  So I changed the player in MY .fla file to use FP9 and it worked.</p>
<p>I&#8217;m wondering if you have any knowledge of some error with regards to accessing stage from the document class in FP10?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bradnon Capecci</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-4574</link>
		<dc:creator>Bradnon Capecci</dc:creator>
		<pubDate>Thu, 12 Nov 2009 23:54:17 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-4574</guid>
		<description>Use that to get the player to rotate with the mouse:
xd = this.x-stage.mouseX;
yd = this.y-stage.mouseY;
radAngle = Math.atan2(yd, xd);
this.rotation = int(radAngle*360/(Math.PI*2)-90);

Use this for creating the shots:
var shot:Shot = new Shot(stageRef);
stageRef.addChild(shot);            
shot.x = this.x;
shot.y = this.y;
shot.rotation = this.rotation;

This for moving them:
x += shotSpeed*Math.sin(rotation*(Math.PI/180));
y -= shotSpeed*Math.cos(rotation*(Math.PI/180));</description>
		<content:encoded><![CDATA[<p>Use that to get the player to rotate with the mouse:<br />
xd = this.x-stage.mouseX;<br />
yd = this.y-stage.mouseY;<br />
radAngle = Math.atan2(yd, xd);<br />
this.rotation = int(radAngle*360/(Math.PI*2)-90);</p>
<p>Use this for creating the shots:<br />
var shot:Shot = new Shot(stageRef);<br />
stageRef.addChild(shot);<br />
shot.x = this.x;<br />
shot.y = this.y;<br />
shot.rotation = this.rotation;</p>
<p>This for moving them:<br />
x += shotSpeed*Math.sin(rotation*(Math.PI/180));<br />
y -= shotSpeed*Math.cos(rotation*(Math.PI/180));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Serax</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-4565</link>
		<dc:creator>Serax</dc:creator>
		<pubDate>Sat, 07 Nov 2009 02:49:35 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-4565</guid>
		<description>Mc :

I see what you&#039;re doing there, and I&#039;m no expert. But I&#039;ve gotten to work with mine and here&#039;s the relevant parts of my BlueLaser.as :

public function Laser (stageRef:Stage, x:Number, y:Number, rotation:Number) : void
		{
			this.stageRef = stageRef;
			this.x = x;
			this.y = y;
			this.rotation = rotation;
			
			addEventListener (Event.ENTER_FRAME, loop, false, 0, true);
		}
		
		private function loop(e:Event) : void
		{
			this.x += Math.cos(this.rotation*Math.PI/180)*speed;
			this.y += Math.sin(this.rotation*Math.PI/180)*speed;
			
			if (this.x &gt; stageRef.stageWidth)
				removeSelf();
			if (this.y &gt; stageRef.stageHeight-15)
				removeSelf();
		}</description>
		<content:encoded><![CDATA[<p>Mc :</p>
<p>I see what you&#8217;re doing there, and I&#8217;m no expert. But I&#8217;ve gotten to work with mine and here&#8217;s the relevant parts of my BlueLaser.as :</p>
<p>public function Laser (stageRef:Stage, x:Number, y:Number, rotation:Number) : void<br />
		{<br />
			this.stageRef = stageRef;<br />
			this.x = x;<br />
			this.y = y;<br />
			this.rotation = rotation;</p>
<p>			addEventListener (Event.ENTER_FRAME, loop, false, 0, true);<br />
		}</p>
<p>		private function loop(e:Event) : void<br />
		{<br />
			this.x += Math.cos(this.rotation*Math.PI/180)*speed;<br />
			this.y += Math.sin(this.rotation*Math.PI/180)*speed;</p>
<p>			if (this.x &gt; stageRef.stageWidth)<br />
				removeSelf();<br />
			if (this.y &gt; stageRef.stageHeight-15)<br />
				removeSelf();<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mc</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-4563</link>
		<dc:creator>Mc</dc:creator>
		<pubDate>Fri, 30 Oct 2009 00:27:34 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-4563</guid>
		<description>Par..
Still trying to figure out how to face the laser to where the ship is facing. here is the code I am working on, please point me to the right direction...
for the laser:
public class LaserBlue extends MovieClip
	{
		
		private var stageRef:Stage;
		private var bulletSpeed:Number = 16;
		private var xSpeed:Number;
		private var ySpeed:Number;
		
		public function LaserBlue (stageRef:Stage, pX:Number, pY:Number, pRotation:Number)
		{
			this.stageRef = stageRef;
			x = pX;
			y = pY;
			ySpeed= Math.sin(pRotation * Math.PI / 180);
			xSpeed= Math.cos(pRotation * Math.PI / 180);
			addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
		}
		
		private function loop(e:Event) : void
		{
			//move bullet up
			x+= xSpeed;
			y+= ySpeed;
			
			if (y  stage.stageWidth)
				x = 0;
			else if (x  stage.stageHeight)
				y = 0;
			else if (y &lt; 0)
				y = stage.stageHeight;
		}
 
		public function degreesToRadians(degrees:Number) : Number
		{
			return degrees * Math.PI / 180;
			
		}
		private function fireBullet() : void
		{
			//if canFire is true, fire a bullet
			//set canFire to false and start our timer
			//else do nothing.
			if (canFire)
			{
				stageRef.addChild(new LaserBlue(stageRef, x - 40, y + vy, rotation + vx &amp;&amp;vy));
				canFire = false;
				fireTimer.start();
			}
			
		}
		
		//HANDLERS
		
		private function fireTimerHandler(e:TimerEvent) : void
		{
			//timer ran, we can fire again.
			canFire = true;
		}

	}

}
Thank you soo soo much for your help. Thank you</description>
		<content:encoded><![CDATA[<p>Par..<br />
Still trying to figure out how to face the laser to where the ship is facing. here is the code I am working on, please point me to the right direction&#8230;<br />
for the laser:<br />
public class LaserBlue extends MovieClip<br />
	{</p>
<p>		private var stageRef:Stage;<br />
		private var bulletSpeed:Number = 16;<br />
		private var xSpeed:Number;<br />
		private var ySpeed:Number;</p>
<p>		public function LaserBlue (stageRef:Stage, pX:Number, pY:Number, pRotation:Number)<br />
		{<br />
			this.stageRef = stageRef;<br />
			x = pX;<br />
			y = pY;<br />
			ySpeed= Math.sin(pRotation * Math.PI / 180);<br />
			xSpeed= Math.cos(pRotation * Math.PI / 180);<br />
			addEventListener(Event.ENTER_FRAME, loop, false, 0, true);<br />
		}</p>
<p>		private function loop(e:Event) : void<br />
		{<br />
			//move bullet up<br />
			x+= xSpeed;<br />
			y+= ySpeed;</p>
<p>			if (y  stage.stageWidth)<br />
				x = 0;<br />
			else if (x  stage.stageHeight)<br />
				y = 0;<br />
			else if (y &lt; 0)<br />
				y = stage.stageHeight;<br />
		}</p>
<p>		public function degreesToRadians(degrees:Number) : Number<br />
		{<br />
			return degrees * Math.PI / 180;</p>
<p>		}<br />
		private function fireBullet() : void<br />
		{<br />
			//if canFire is true, fire a bullet<br />
			//set canFire to false and start our timer<br />
			//else do nothing.<br />
			if (canFire)<br />
			{<br />
				stageRef.addChild(new LaserBlue(stageRef, x &#8211; 40, y + vy, rotation + vx &amp;&amp;vy));<br />
				canFire = false;<br />
				fireTimer.start();<br />
			}</p>
<p>		}</p>
<p>		//HANDLERS</p>
<p>		private function fireTimerHandler(e:TimerEvent) : void<br />
		{<br />
			//timer ran, we can fire again.<br />
			canFire = true;<br />
		}</p>
<p>	}</p>
<p>}<br />
Thank you soo soo much for your help. Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mc</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-4560</link>
		<dc:creator>Mc</dc:creator>
		<pubDate>Mon, 26 Oct 2009 21:56:52 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-4560</guid>
		<description>Thank you so much for the tutorial, I am very new to AS and is trying to build a asteroid game. You are my life saver to be so kind to post these tutorials.
I have been trying to add the laser to rotate with the ship as well. Should I add the same code to the laser file as well? Right now the laser just shoot straight up and doesn&#039;t rotate. Please give me some advice. Thank you soo much. thank you.</description>
		<content:encoded><![CDATA[<p>Thank you so much for the tutorial, I am very new to AS and is trying to build a asteroid game. You are my life saver to be so kind to post these tutorials.<br />
I have been trying to add the laser to rotate with the ship as well. Should I add the same code to the laser file as well? Right now the laser just shoot straight up and doesn&#8217;t rotate. Please give me some advice. Thank you soo much. thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Par</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-4546</link>
		<dc:creator>Par</dc:creator>
		<pubDate>Wed, 07 Oct 2009 13:07:11 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-4546</guid>
		<description>@jaybdemented.
Yes that will work but it will also completely alter the way the ship moves. The sliding effect will no longer work the same way.</description>
		<content:encoded><![CDATA[<p>@jaybdemented.<br />
Yes that will work but it will also completely alter the way the ship moves. The sliding effect will no longer work the same way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jaybdemented</title>
		<link>http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement/comment-page-1#comment-4540</link>
		<dc:creator>jaybdemented</dc:creator>
		<pubDate>Sat, 03 Oct 2009 12:12:18 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=293#comment-4540</guid>
		<description>a easier way to set the max speed.

private var speed:Number = 10;

and change
vy += Math.sin(degreesToRadians(rotation)) * speed;
vx += Math.cos(degreesToRadians(rotation)) * speed;
to this
vy = Math.sin(degreesToRadians(rotation)) * speed;
vx = Math.cos(degreesToRadians(rotation)) * speed;</description>
		<content:encoded><![CDATA[<p>a easier way to set the max speed.</p>
<p>private var speed:Number = 10;</p>
<p>and change<br />
vy += Math.sin(degreesToRadians(rotation)) * speed;<br />
vx += Math.cos(degreesToRadians(rotation)) * speed;<br />
to this<br />
vy = Math.sin(degreesToRadians(rotation)) * speed;<br />
vx = Math.cos(degreesToRadians(rotation)) * speed;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

