<?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>manewc &#187; APE &#8211; Actionscript Physics Engine</title>
	<atom:link href="http://manewc.com/category/ape-actionscript-physics-engine/feed/" rel="self" type="application/rss+xml" />
	<link>http://manewc.com</link>
	<description>iPhone, Flash, Flex, AIR, &#38; Web Development</description>
	<lastBuildDate>Sat, 31 Oct 2009 16:47:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>APE &#8211; Collision Within A Circle</title>
		<link>http://manewc.com/2008/12/12/ape-collision-within-a-circle/</link>
		<comments>http://manewc.com/2008/12/12/ape-collision-within-a-circle/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 18:18:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=248</guid>
		<description><![CDATA[A slight modification that adds a CircleParticle with constant motion inside of the circle.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CollisionInsideCircle_475287427"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf"
			name="fm_CollisionInsideCircle_475287427"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
The Main.as Document Class:

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.*;

	public class Main extends Sprite
	{
		private var follow:Ball;

		private var c:Circle;
		private var vr:Number = .4;
		private var _maxpts:Number = 15; // number of drawn points, this is dependent on vr variable.
		private var cos:Number = Math.cos [...]]]></description>
			<content:encoded><![CDATA[<p>A slight modification that adds a CircleParticle with constant motion inside of the circle.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CollisionInsideCircle_1119119608"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf"
			name="fm_CollisionInsideCircle_1119119608"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The Main.as Document Class:</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.*;

	public class Main extends Sprite
	{
		private var follow:Ball;

		private var c:Circle;
		private var vr:Number = .4;
		private var _maxpts:Number = 15; // number of drawn points, this is dependent on vr variable.
		private var cos:Number = Math.cos ( vr );
		private var sin:Number = Math.sin ( vr );

		private var _ct:Number = 0; // counter

		private var _ptarr:Array = new Array();
		private var defaultGroup:Group;
		private var _scarr:Array = new Array();

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

			// Initialize the engine. The argument here is the time step value.
			// Higher values scale the forces in the sim, making it appear to run
			// faster or slower. Lower values result in more accurate simulations.
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;

			//APEngine.addMasslessForce(new Vector(0,6));
			APEngine.addMasslessForce(new Vector(0,0));

			defaultGroup = new Group();

			defaultGroup.collideInternal = true;

			APEngine.addGroup(defaultGroup);
			addEventListener(Event.ENTER_FRAME, run);

			follow = new Ball();
			addChild ( follow );
			follow.x = 130;
			follow.y = 130;
			follow.addEventListener ( Event.ENTER_FRAME, drawCircleBounds );
		}

		private function drawCircleBounds (e:Event):void
		{
			var x1:Number = follow.x - stage.stageWidth / 2;
			var y1:Number = follow.y - stage.stageHeight / 2;
			var x2:Number = cos * x1 - sin * y1;
			var y2:Number = cos * y1 + sin * x1;

			follow.x = stage.stageWidth / 2 + x2;
			follow.y = stage.stageHeight / 2 + y2;

			/* CIRCLE PROPERTIES
				x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/

			/* Points of Circle
			------------------
			*/
			_ptarr[_ct] = new CircleParticle(follow.x, follow.y, 2, true, 1, 0);
           	_ptarr[_ct].setStyle(0, 0, 0, 0xffffff);
			defaultGroup.addParticle(_ptarr[_ct]);

			/* Connectors
			------------------
			*/

			if ( _ct > 0 )
			{
				_scarr[_ct] = new SpringConstraint(_ptarr[_ct-1], _ptarr[_ct], 4, true);
				defaultGroup.addConstraint( _scarr[_ct] );

				if ( _ct >= _maxpts )
				{
					_scarr[_ct+1] = new SpringConstraint(_ptarr[_ct], _ptarr[0], 4, true);
					defaultGroup.addConstraint( _scarr[_ct+1] );

					dropBall();
				}
			}

			/* Update
			------------------
			*/
			_ct++;

			/* Check end
			------------------
			*/
			if ( _ct > _maxpts ) follow.removeEventListener ( Event.ENTER_FRAME, drawCircleBounds );

		}

		private function dropBall():void
		{
			c = new Circle ( stage.stageWidth / 2, stage.stageHeight / 2, 30 );
			APEngine.addGroup(c);
			c.addCollidable ( defaultGroup );

			// make the ball move
			c.cp.velocity = (new Vector(10, 10));
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}

	}
}
</pre>
<p>The Circle.as class</p>
<pre name="code" class="c-sharp">
package
{
	import org.cove.ape.Group;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Vector;

	public class Circle extends Group
	{
		public var cp:CircleParticle;

		/*
		x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
		*/

		public function Circle(x:uint, y:uint, r:Number=5, c:uint = 0xffffff)
		{
			cp = new CircleParticle(x, y, r, false, 1, 1);
			cp.setStyle(0, 0, 0, c);
			addParticle(cp);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/12/ape-collision-within-a-circle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>APE &#8211; Animation within Circular Bounds</title>
		<link>http://manewc.com/2008/12/10/ape-animation-within-circular-bounds/</link>
		<comments>http://manewc.com/2008/12/10/ape-animation-within-circular-bounds/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 18:47:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=242</guid>
		<description><![CDATA[Here is a little movie that will generate a circle and then place a dragable circle particle contained within it&#8217;s circular bounds. I unfortunately have run out of time for today to clean up this file, so I will consider this as part 1. Note, if you interact with this movie, the key is to [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a little movie that will generate a circle and then place a dragable circle particle contained within it&#8217;s circular bounds. I unfortunately have run out of time for today to clean up this file, so I will consider this as part 1. Note, if you interact with this movie, the key is to &#8216;gently&#8217; toss the circle against the walls, else the circle will fly off of the screen <img src='http://manewc.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CollisionInsideCircle_209177397"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APECollisionInsideCircle/CollisionInsideCircle.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APECollisionInsideCircle/CollisionInsideCircle.swf"
			name="fm_CollisionInsideCircle_209177397"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is the Main.as file:</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.*;

	public class Main extends Sprite
	{
		private var follow:Ball;
		private var db:DragableCircleParticle;
		private var vr:Number = .4;
		private var _maxpts:Number = 15; // number of drawn points, this is dependent on vr variable.
		private var cos:Number = Math.cos ( vr );
		private var sin:Number = Math.sin ( vr );

		private var _ct:Number = 0; // counter

		private var _ptarr:Array = new Array();
		private var defaultGroup:Group;
		private var _scarr:Array = new Array();

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

			// Initialize the engine. The argument here is the time step value.
			// Higher values scale the forces in the sim, making it appear to run
			// faster or slower. Lower values result in more accurate simulations.
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;

			APEngine.addMasslessForce(new Vector(0,6));

			defaultGroup = new Group();

			defaultGroup.collideInternal = true;

			APEngine.addGroup(defaultGroup);
			addEventListener(Event.ENTER_FRAME, run);

			follow = new Ball();
			addChild ( follow );
			follow.x = 130;
			follow.y = 130;
			follow.addEventListener ( Event.ENTER_FRAME, drawCircleBounds );
		}

		private function drawCircleBounds (e:Event):void
		{
			var x1:Number = follow.x - stage.stageWidth / 2;
			var y1:Number = follow.y - stage.stageHeight / 2;
			var x2:Number = cos * x1 - sin * y1;
			var y2:Number = cos * y1 + sin * x1;

			follow.x = stage.stageWidth / 2 + x2;
			follow.y = stage.stageHeight / 2 + y2;

			/* CIRCLE PROPERTIES
				x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/

			/* Points of Circle
			------------------
			*/
			_ptarr[_ct] = new CircleParticle(follow.x, follow.y, 2, true, 1, 0);
           	_ptarr[_ct].setStyle(0, 0, 0, 0xffffff);
			defaultGroup.addParticle(_ptarr[_ct]);

			/* Connectors
			------------------
			*/

			if ( _ct > 0 )
			{
				_scarr[_ct] = new SpringConstraint(_ptarr[_ct-1], _ptarr[_ct], 4, true);
				defaultGroup.addConstraint( _scarr[_ct] );

				if ( _ct >= _maxpts )
				{
					_scarr[_ct+1] = new SpringConstraint(_ptarr[_ct], _ptarr[0], 4, true);
					defaultGroup.addConstraint( _scarr[_ct+1] );

					dropBall();
				}
			}

			/* Update
			------------------
			*/
			_ct++;

			/* Check end
			------------------
			*/
			if ( _ct > _maxpts ) follow.removeEventListener ( Event.ENTER_FRAME, drawCircleBounds );

		}

		private function dropBall():void
		{
			db = new DragableCircleParticle(160, 150, 30, false, 10, .3);
			db.setStyle(0, 0, 0, 0x993300);
			defaultGroup.addParticle(db);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}

	}
}
</pre>
<p>and the Ball.as file ( this is used as the red ball )</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;

	public class Ball extends Sprite {
		public var radius:Number;
		private var color:uint;
		public var xpos:Number = 0;
		public var ypos:Number = 0;
		public var zpos:Number = 0;
		public var vx:Number = 0;
		public var vy:Number = 0;
		public var vz:Number = 0;
		public var mass:Number = 1;

		public function Ball(radius:Number=10, color:uint=0xff0000) {
			this.radius = radius;
			this.color = color;
			init();
		}
		public function init():void {
			graphics.lineStyle(0);
			graphics.beginFill(color);
			graphics.drawCircle(0, 0, radius);
			graphics.endFill();
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/10/ape-animation-within-circular-bounds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APE &#8211; Basketball</title>
		<link>http://manewc.com/2008/12/04/ape-basketball/</link>
		<comments>http://manewc.com/2008/12/04/ape-basketball/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 17:42:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=236</guid>
		<description><![CDATA[To play around a little more from the find of the draggable objects in APE I made a little demo of a basketball game.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEBasketballPost_1438174084"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEBasketball/APEBasketballPost.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEBasketball/APEBasketballPost.swf"
			name="fm_APEBasketballPost_1438174084"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
Here is the code:

package {
    import flash.display.Sprite;
    import flash.events.Event;
	import flash.events.MouseEvent;

    import org.cove.ape.*;

	public class Main extends Sprite {

		private var circle:DragableCircleParticle;
		private [...]]]></description>
			<content:encoded><![CDATA[<p>To play around a little more from the find of the <a href="/2008/12/03/ape-multiple-draggable-particles/">draggable objects in APE</a> I made a little demo of a basketball game.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEBasketballPost_1887266744"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEBasketball/APEBasketballPost.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEBasketball/APEBasketballPost.swf"
			name="fm_APEBasketballPost_1887266744"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is the code:</p>
<pre name="code" class="c-sharp">
package {
    import flash.display.Sprite;
    import flash.events.Event;
	import flash.events.MouseEvent;

    import org.cove.ape.*;

	public class Main extends Sprite {

		private var circle:DragableCircleParticle;
		private var circle2:DragableCircleParticle;

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

			// Initialize the engine. The argument here is the time step value.
			// Higher values scale the forces in the sim, making it appear to run
			// faster or slower. Lower values result in more accurate simulations.
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;

			APEngine.addMasslessForce(new Vector(0,5));

			var defaultGroup:Group = new Group();

			defaultGroup.collideInternal = true;

			/* RECTANGLE PROPERTIES
				x:Number,
				y:Number,
				width:Number,
				height:Number,
				rotation:Number = 0,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/
            var floor:RectangleParticle = new RectangleParticle(stage.stageWidth/2, stage.stageHeight + 48, stage.stageWidth, 100, 0, true, 10);
            defaultGroup.addParticle(floor);

			var ceil:RectangleParticle = new RectangleParticle(stage.stageWidth/2, -50, stage.stageWidth, 100, 0, true, 10);
            defaultGroup.addParticle(ceil);

			var left:RectangleParticle = new RectangleParticle(-25, stage.stageHeight/2, 50, stage.stageHeight, 0, true, 10);
            defaultGroup.addParticle(left);

			var right:RectangleParticle = new RectangleParticle(stage.stageWidth+25, stage.stageHeight/2, 50, stage.stageHeight, 0, true, 10);
            defaultGroup.addParticle(right);

			/* CIRCLE PROPERTIES
				x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/

			/* BASKETBALL
			------------------
			*/
           	circle = new DragableCircleParticle(350, 150, 30, false, 20, .5);
			circle.setStyle(0, 0, 0, 0x993300);
			defaultGroup.addParticle(circle);

			/* HOOP &#038; NET
			------------------
			*/
			var hl:CircleParticle = new CircleParticle( stage.stageWidth - 180, 300, 5, true );
			defaultGroup.addParticle ( hl ); // hoop top left

			var hl2:CircleParticle = new CircleParticle( stage.stageWidth - 170, 350, 5, false );
			defaultGroup.addParticle ( hl2 ); // hoop top left

			var hl3:CircleParticle = new CircleParticle( stage.stageWidth - 145, 430, 5, false );
			defaultGroup.addParticle ( hl3 ); // hoop top left

			var hlConnector:SpringConstraint = new SpringConstraint(hl, hl2, 0.5, true, 8);
			hlConnector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hlConnector);  

			var hl2Connector:SpringConstraint = new SpringConstraint(hl2, hl3, 0.5, true, 8);
			hl2Connector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hl2Connector);  

			var hr:CircleParticle = new CircleParticle( stage.stageWidth - 50, 300, 5, true );
			defaultGroup.addParticle ( hr ); // hoop top right

			var hr2:CircleParticle = new CircleParticle( stage.stageWidth - 60, 350, 5, false );
			defaultGroup.addParticle ( hr2 ); // hoop top left

			var hr3:CircleParticle = new CircleParticle( stage.stageWidth - 85, 430, 5, false );
			defaultGroup.addParticle ( hr3 ); // hoop top left

			var hrConnector:SpringConstraint = new SpringConstraint(hr, hr2, 0.5, true, 8);
			hrConnector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hrConnector);

			var hr2Connector:SpringConstraint = new SpringConstraint(hr2, hr3, 0.5, true, 8);
			hr2Connector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hr2Connector);

			// top of hoop connector
			var thoop:SpringConstraint = new SpringConstraint(hl, hr, 4, false, 8);
			thoop.setStyle(4, 0xffffff, 4, 0xffffff);
			defaultGroup.addConstraint(thoop);

			// bottom of hoop
			var bhoop:SpringConstraint = new SpringConstraint(hl2, hr2, 0.5, false, 8);
			bhoop.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(bhoop);

			var bhoop2:SpringConstraint = new SpringConstraint(hl3, hr3, 0.5, false, 8);
			bhoop2.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(bhoop2);

			// backboard
			var bb:RectangleParticle = new RectangleParticle(stage.stageWidth - 20, 220, 5, 200, 0, true, 1,.01);
			defaultGroup.addParticle ( bb ); // backboard

			APEngine.addGroup(defaultGroup);
			addEventListener(Event.ENTER_FRAME, run);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/04/ape-basketball/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>APE &#8211; Multiple Draggable Particles</title>
		<link>http://manewc.com/2008/12/03/ape-multiple-draggable-particles/</link>
		<comments>http://manewc.com/2008/12/03/ape-multiple-draggable-particles/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 19:05:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=233</guid>
		<description><![CDATA[I was trying to figure out a way to improve my initial movie that stop and starts the APE engine to allow for the user to drag an object. After mucking around with the original APE classes, I found in Google Groups that there are 2 new classes to allow the use to drag either [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to figure out a way to improve my <a href="http://manewc.com/2008/04/22/dragging-a-particle-with-ape-part-ii/">initial movie</a> that stop and starts the APE engine to allow for the user to drag an object. After mucking around with the original APE classes, I found in Google Groups that there are 2 new classes to allow the use to drag either a CircleParticle or a RectangleParticle.</p>
<p>You can grab the zip file here: <a href="http://ape-general.googlegroups.com/web/dragable_particles.zip">http://ape-general.googlegroups.com/web/dragable_particles.zip</a> and here is what can be produced:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEObjectDrag_1240337778"
			class="flashmovie"
			width="700"
			height="350">
	<param name="movie" value="/projects/flash/APEObjectDragMultiple/APEObjectDrag.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEObjectDragMultiple/APEObjectDrag.swf"
			name="fm_APEObjectDrag_1240337778"
			width="700"
			height="350">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre name="code" class="c-sharp">
package {
    import flash.display.Sprite;
    import flash.events.Event;
	import flash.events.MouseEvent;

    import org.cove.ape.*;

	public class Main extends Sprite {

		private var circle:DragableCircleParticle;
		private var circle2:DragableCircleParticle;

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

			// Initialize the engine. The argument here is the time step value.
			// Higher values scale the forces in the sim, making it appear to run
			// faster or slower. Lower values result in more accurate simulations.
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;

			APEngine.addMasslessForce(new Vector(0,8));

			var defaultGroup:Group = new Group();

			defaultGroup.collideInternal = true;

            var rect:RectangleParticle = new RectangleParticle(350, 348, 700, 20, 0, true);
            defaultGroup.addParticle(rect);

           	circle = new DragableCircleParticle(350, 150, 25);
			defaultGroup.addParticle(circle);

			circle2 = new DragableCircleParticle(300, 150, 25);
			defaultGroup.addParticle(circle2);

			APEngine.addGroup(defaultGroup);

			addEventListener(Event.ENTER_FRAME, run);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}
	}
}
</pre>
<p>Here is the new class file located in org/cove/ape/DragableCircleParticle.as (relative to my Main.as file)</p>
<pre name="code" class="c-sharp">
package org.cove.ape{
	import flash.events.MouseEvent;
	import org.cove.ape.*;
	public class DragableCircleParticle extends CircleParticle{
		private var mouseIsDown:Boolean;
		public function DragableCircleParticle(
				x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0){
			super(x, y, radius, fixed, mass, elasticity, friction);
			alwaysRepaint = fixed;
			mouseIsDown = false;
			sprite.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
			sprite.stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
			sprite.stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
		}
		private function mouseDownHandler(evt:MouseEvent):void{
			mouseIsDown = true;					// on mouse down set mouseIsDown to true
			curr.setTo(evt.stageX,evt.stageY);	// set the current position of the particle to the position of the mouse
			prev.setTo(evt.stageX,evt.stageY);	// set the previous position of the particle to the position of the mouse
		}
		private function mouseUpHandler(evt:MouseEvent):void{
			mouseIsDown = false;			// on mouse up set mouseIsDown to false
		}
		private function mouseMoveHandler(evt:MouseEvent):void{
			if(mouseIsDown){				// On mouse move if the mouse is down
				prev.copy(curr);			// set the previous position to the curent position of the particle
				curr.setTo(evt.stageX,evt.stageY);	// set the current position to the position of the mouse
			}
		}
		public override function update(dt2:Number):void {
			if(!mouseIsDown){		// Don't update if the mouse is down
				super.update(dt2);
			}
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/03/ape-multiple-draggable-particles/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>APE Vectors, Built-In Collision Detection, User Control</title>
		<link>http://manewc.com/2008/08/20/ape-vectors-built-in-collision-detection-user-control/</link>
		<comments>http://manewc.com/2008/08/20/ape-vectors-built-in-collision-detection-user-control/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 17:24:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=175</guid>
		<description><![CDATA[This movie demonstrates the ability to move one object that collides with another object. You have control over the white ball by simply using your arrow keys. I modified the classes slightly and added some more configuration to the circle classes.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEVectors_133218740"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEVectorsCollision/APEVectors.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEVectorsCollision/APEVectors.swf"
			name="fm_APEVectors_133218740"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.APEngine;
	import org.cove.ape.Vector;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Group;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.text.TextField;

	public [...]]]></description>
			<content:encoded><![CDATA[<p>This movie demonstrates the ability to move one object that collides with another object. You have control over the white ball by simply using your arrow keys. I modified the classes slightly and added some more configuration to the circle classes.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEVectors_539880072"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEVectorsCollision/APEVectors.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEVectorsCollision/APEVectors.swf"
			name="fm_APEVectors_539880072"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.APEngine;
	import org.cove.ape.Vector;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Group;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.text.TextField;

	public class Main extends Sprite
	{
		private	var cp:Circle = new Circle( stage.stageWidth / 2, stage.stageHeight / 2, 30 );
		private var walls:Walls = new Walls( stage.stageWidth, stage.stageHeight );
		private var ball:Circle = new Circle( stage.stageWidth / 2, stage.stageHeight / 2, 50, 0xb84777 );

		public function Main()
		{
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;
			APEngine.addMasslessForce(new Vector(0,0));

			APEngine.addGroup(cp);
			APEngine.addGroup(ball);
			APEngine.addGroup(walls);

			cp.addCollidable ( ball );
			cp.addCollidable ( walls );
			ball.addCollidable ( walls );

			// make the ball move
			ball.cp.velocity = (new Vector(Math.random() * 5, Math.random() * 5));

			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
            addEventListener(Event.ENTER_FRAME, run);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}

		private function keyDownHandler(k:KeyboardEvent):void
		{
			if (k.keyCode == Keyboard.UP) {
				cp.cp.velocity = (new Vector(0, -10));
			} else if (k.keyCode == Keyboard.DOWN) {
				cp.cp.velocity = (new Vector(0, 10));
			} else if (k.keyCode == Keyboard.RIGHT) {
				cp.cp.velocity = (new Vector(10, 0));
			} else if (k.keyCode == Keyboard.LEFT) {
				cp.cp.velocity = (new Vector(-10, 0));
			}
		}
	}
}
</pre>
<p>The Walls class</p>
<pre name="code" class="c-sharp">
package
{
	import org.cove.ape.Group;
	import org.cove.ape.RectangleParticle;  

	public class Walls extends Group
	{

		public function Walls(bw:Number, bh:Number)
		{
			// top
			var t:RectangleParticle = new RectangleParticle(bw/2, -50, bw, 100, 0, true);
			addParticle(t);

			// this is the bottom
			var b:RectangleParticle = new RectangleParticle(bw/2, bh + 50, bw, 100, 0, true);
			addParticle(b);

			// left
			var l:RectangleParticle = new RectangleParticle(-50, bh / 2, 100, bh, 0, true);
			addParticle(l);  

			// right
			var r:RectangleParticle = new RectangleParticle(bw + 50, bh / 2, 100, bh, 0, true);
			addParticle(r);
		}
	}
}
</pre>
<p>The Circle Class</p>
<pre name="code" class="c-sharp">
package
{
	import org.cove.ape.Group;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Vector;

	public class Circle extends Group
	{
		public var cp:CircleParticle;

		public function Circle(x:uint, y:uint, r:Number=5, c:uint = 0xffffff)
		{
			cp = new CircleParticle(x, y, r, false, 3, .8);
			cp.setStyle(0, 0, 0, c);
			addParticle(cp);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/08/20/ape-vectors-built-in-collision-detection-user-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APE Vectors and Collidable Walls</title>
		<link>http://manewc.com/2008/08/19/ape-vectors-and-collidable-walls/</link>
		<comments>http://manewc.com/2008/08/19/ape-vectors-and-collidable-walls/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 16:57:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[manewc.com]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=174</guid>
		<description><![CDATA[So I just added some walls to my little movie here and took out the KEY_UP handler to allow the circle to continuously move around the stage. To activate, simply hit an arrow key.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEVectors_1025773756"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEVectors2/APEVectors.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEVectors2/APEVectors.swf"
			name="fm_APEVectors_1025773756"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.APEngine;
	import org.cove.ape.Vector;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Group;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.text.TextField;

	public class Main extends Sprite
	{
		private	var cp:Circle = new [...]]]></description>
			<content:encoded><![CDATA[<p>So I just added some walls to my little movie here and took out the KEY_UP handler to allow the circle to continuously move around the stage. To activate, simply hit an arrow key.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEVectors_1485373452"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEVectors2/APEVectors.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEVectors2/APEVectors.swf"
			name="fm_APEVectors_1485373452"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.APEngine;
	import org.cove.ape.Vector;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Group;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.text.TextField;

	public class Main extends Sprite
	{
		private	var cp:Circle = new Circle( stage.stageWidth / 2, stage.stageHeight / 2 );
		private var walls:Walls = new Walls( stage.stageWidth, stage.stageHeight );

		public function Main()
		{
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;
			APEngine.addMasslessForce(new Vector(0,0));

			APEngine.addGroup(cp);
			APEngine.addGroup(walls);

			cp.addCollidable ( walls );

			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
            addEventListener(Event.ENTER_FRAME, run);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}

		private function keyDownHandler(k:KeyboardEvent):void
		{
			if (k.keyCode == Keyboard.UP) {
				cp.cp.velocity = (new Vector(0, -5));
			} else if (k.keyCode == Keyboard.DOWN) {
				cp.cp.velocity = (new Vector(0, 5));
			} else if (k.keyCode == Keyboard.RIGHT) {
				cp.cp.velocity = (new Vector(5, 0));
			} else if (k.keyCode == Keyboard.LEFT) {
				cp.cp.velocity = (new Vector(-5, 0));
			}
		}
	}
}
</pre>
<p>The Circle class:</p>
<pre name="code" class="c-sharp">
package
{
	import org.cove.ape.Group;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Vector;

	public class Circle extends Group
	{
		public var cp:CircleParticle;

		public function Circle(x:uint, y:uint)
		{
			cp = new CircleParticle(x, y, 5, false, 3, .8);
			cp.setStyle(0, 0, 0, Math.random() * 0xffffff);
			addParticle(cp);
		}
	}
}
</pre>
<p>The Wall class:</p>
<pre name="code" class="c-sharp">
package
{
	import org.cove.ape.Group;
	import org.cove.ape.RectangleParticle;  

	public class Walls extends Group
	{

		public function Walls(bw:Number, bh:Number)
		{
			// top
			var t:RectangleParticle = new RectangleParticle(bw/2, 0, bw, 10, 0, true);
			addParticle(t);

			// this is the bottom
			var b:RectangleParticle = new RectangleParticle(bw/2, bh, bw, 100, 0, true);
			addParticle(b);

			// left
			var l:RectangleParticle = new RectangleParticle(0, bh / 2, 10, bh, 0, true);
			addParticle(l);  

			// right
			var r:RectangleParticle = new RectangleParticle(bw, bh / 2, 10, bh, 0, true);
			addParticle(r);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/08/19/ape-vectors-and-collidable-walls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript Physics Engine Vectors</title>
		<link>http://manewc.com/2008/08/18/actionscript-physics-engine-vectors/</link>
		<comments>http://manewc.com/2008/08/18/actionscript-physics-engine-vectors/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 17:22:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=173</guid>
		<description><![CDATA[So I was deconstructing a game the other day that was using the APE Actionscript Engine and wanted to note how movement of an object can be created. By creating a new Vector an object can be moved accordingly. To interact with the movie, simply press the arrow keys on your keyboard.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEVectors_1770595614"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEVectors/APEVectors.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEVectors/APEVectors.swf"
			name="fm_APEVectors_1770595614"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>]]></description>
			<content:encoded><![CDATA[<p>So I was deconstructing a game the other day that was using the APE Actionscript Engine and wanted to note how movement of an object can be created. By creating a new Vector an object can be moved accordingly. To interact with the movie, simply press the arrow keys on your keyboard.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEVectors_525371747"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEVectors/APEVectors.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEVectors/APEVectors.swf"
			name="fm_APEVectors_525371747"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>A simple circle class:</p>
<pre name="code" class="c-sharp">
package
{
	import org.cove.ape.Group;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Vector;

	public class Circle extends Group
	{
		public var cp:CircleParticle;

		public function Circle(x:uint, y:uint)
		{
			cp = new CircleParticle(x, y, 5, false, 3, .8);
			cp.setStyle(0, 0, 0, Math.random() * 0xffffff);
			addParticle(cp);
		}
	}
}
</pre>
<p>and the Main Document class:</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.APEngine;
	import org.cove.ape.Vector;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Group;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.text.TextField;

	public class Main extends Sprite
	{
		private	var cp:Circle = new Circle(stage.stageWidth / 2, stage.stageHeight / 2);

		public function Main()
		{
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;
			APEngine.addGroup(cp);

			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
            stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
			addEventListener(Event.ENTER_FRAME, run);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}

		private function keyDownHandler(k:KeyboardEvent):void
		{
			if (k.keyCode == Keyboard.UP) {
				cp.cp.velocity = (new Vector(0, -5));
			} else if (k.keyCode == Keyboard.DOWN) {
				cp.cp.velocity = (new Vector(0, 5));
			} else if (k.keyCode == Keyboard.RIGHT) {
				cp.cp.velocity = (new Vector(5, 0));
			} else if (k.keyCode == Keyboard.LEFT) {
				cp.cp.velocity = (new Vector(-5, 0));
			}
		}

		private function keyUpHandler(k:KeyboardEvent):void {
			cp.cp.velocity = (new Vector(0, 0));
		}

	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/08/18/actionscript-physics-engine-vectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APE Project &#8211; Step 8 &#8211; Adding a Fixed Bridge</title>
		<link>http://manewc.com/2008/08/15/ape-project-step-8-adding-a-fixed-bridge/</link>
		<comments>http://manewc.com/2008/08/15/ape-project-step-8-adding-a-fixed-bridge/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 18:14:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=172</guid>
		<description><![CDATA[From a few past experiments [1 &#124; 2 ] I wanted to add a bridge to my movie here. For now:

Hold down the Shift key to and drag your mouse across the stage to draw a rectangle
Hold down the Command (or Ctrl key) key and click an area on the stage to build a bridge

You [...]]]></description>
			<content:encoded><![CDATA[<p>From a few past experiments [<a href="http://manewc.com/2008/03/28/as-3-as-physics-engine-ape-car-demo/">1</a> | <a href="http://manewc.com/2008/03/26/as-3-as-physics-engine-ape-bridge-demo/">2</a> ] I wanted to add a bridge to my movie here. For now:</p>
<ul>
<li>Hold down the Shift key to and drag your mouse across the stage to draw a rectangle</li>
<li>Hold down the Command (or Ctrl key) key and click an area on the stage to build a bridge</li>
</ul>
<p>You can download the files for this project here:</p>
<p><a href="http://www.manewc.com/projects/flash/APEProject8/manewc.zip">http://www.manewc.com/projects/flash/APEProject8/manewc.zip</a></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEProject_1861185607"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEProject8/APEProject.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEProject8/APEProject.swf"
			name="fm_APEProject_1861185607"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is the updated Main.as file</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.display.Shape;
	import flash.ui.Keyboard;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	import flash.events.Event;
	import flash.geom.Rectangle;
	import fl.controls.Button;
	import org.cove.ape.*;

	public class Main extends Sprite {

		private var beginX:Number; // top left x position
		private var beginY:Number; // top left y position
       	private var endX:Number; // bottom right x position
       	private var endY:Number; // bottom right y position  

		private var dynRect:RectangleParticle;
		private var canDraw:Boolean = false; // this allows the drawing of rectangles
		private var circle:CircleParticle;
		private var circleGroup:Group;
        private var defaultGroup:Group;
		private var canDrawBridge:Boolean = false; // this allows the drawing of bridges
		private var bridge:Bridge;
		private var car:Car;
		private var btnCar:Button;

		// rectangle particle dimensions
		private var _xpos:Number;
		private var _ypos:Number;
		private var _rwidth:Number;
		private var _rheight:Number;
		private var _rrotation:Number = 0;

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

            // Initialize the engine. The argument here is the time step value.
            // Higher values scale the forces in the sim, making it appear to run
            // faster or slower. Lower values result in more accurate simulations.
            APEngine.init(1/4);  

            // set up the default diplay container
            APEngine.container = this;  

            APEngine.addMasslessForce(new Vector(0,8));  

            defaultGroup = new Group();  

            defaultGroup.collideInternal = true;

			circleGroup = new Group();
			circleGroup.collideInternal = true;

			// this is the bottom
			var rect:RectangleParticle = new RectangleParticle(345, 680, 710, 40, 0, true);
            defaultGroup.addParticle(rect);  

			var l:RectangleParticle = new RectangleParticle(0, stage.stageHeight / 2 - 20, 10, stage.stageHeight-40, 0, true);
            defaultGroup.addParticle(l);

			var r:RectangleParticle = new RectangleParticle(stage.stageWidth, stage.stageHeight / 2 - 20, 10, stage.stageHeight-40, 0, true);
            defaultGroup.addParticle(r);

            APEngine.addGroup(defaultGroup);
			APEngine.addGroup(circleGroup);

			// make the groups collidable
			defaultGroup.addCollidable(circleGroup);

			addEventListener(Event.ENTER_FRAME, run);

			stage.addEventListener(KeyboardEvent.KEY_DOWN, allowDraw);
			stage.addEventListener(KeyboardEvent.KEY_UP, disallowDraw);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, dragDraw);
			stage.addEventListener(MouseEvent.MOUSE_UP, dragDrawStop);

			// build the UI
			buildUI();
		}

		private function allowDraw(event:KeyboardEvent):void
		{
			if ( event.keyCode == 16 )
			{
            	canDraw = true;
			}
			else if ( event.keyCode == 17 ) // 'command'
			{
				canDrawBridge = true;
			}
		}

		private function disallowDraw(event:KeyboardEvent):void {
            if ( canDraw ) canDraw = false;
			if ( canDrawBridge ) canDrawBridge = false;
        }

		private function dragDraw (m:MouseEvent):void
		{
			if ( canDraw )
			{
				beginRectDraw();
			}
			else if ( canDrawBridge )
			{
				beginDrawBridge();
			}
		}

		private function dragDrawStop (m:MouseEvent):void
		{
			if ( canDraw )
			{
				stopRectDraw();
			}
			else if ( canDrawBridge )
			{

			}
		}

		private function beginDrawBridge():void
		{
			// if exists.. delete it for now
			if ( bridge ) APEngine.removeGroup(bridge);

			// add the bridge
			bridge = new Bridge(mouseX, mouseY, 11.9, 55, 5);
			APEngine.addGroup ( bridge );

			// add the collidables
			defaultGroup.addCollidable(bridge);
			circleGroup.addCollidable(bridge);
			if ( car ) car.addCollidable(bridge);
		}

		private function beginRectDraw():void
       	{
			beginX = mouseX;
			beginY = mouseY;
       	}

		private function stopRectDraw():void
       	{
			// set the end points
           	endX = mouseX;
		   	endY = mouseY;

			// now draw the rectangle
			if ( canDraw ) drawRectangle();
		}

		private function drawRectangle():void
		{
			if ( beginY < 660 &#038;&#038; endY < 660 )
			{
				// store the data
				_xpos = beginX + ((endX - beginX)/2);
				_ypos = beginY + ((endY - beginY)/2);
				_rwidth = endX - beginX;
				_rheight = endY - beginY;
				_rrotation = 0;

				dynRect = new RectangleParticle(_xpos, _ypos, _rwidth, _rheight, _rrotation, true);
            	defaultGroup.addParticle(dynRect);

				dynRect.sprite.addEventListener ( MouseEvent.MOUSE_DOWN, rotateRectangle );
			}
		}

		private function rotateRectangle( m:MouseEvent ):void
		{
			if ( !canDraw )
			{
				// increment the angle
				_rrotation += .05;

				// rid of the particle
				defaultGroup.removeParticle(dynRect);

				// redraw the particle
				dynRect = new RectangleParticle(_xpos, _ypos, _rwidth, _rheight, _rrotation, true);
            	defaultGroup.addParticle(dynRect);

				dynRect.sprite.addEventListener ( MouseEvent.MOUSE_DOWN, rotateRectangle );
			}
		}

		private function addBall( m:MouseEvent ):void
        {
            circle = new CircleParticle(Math.random() * stage.stageWidth, Math.random() * 100, Math.random() * 25 + 5);
            circleGroup.addParticle(circle);
        }

		private function addCar ( m:MouseEvent ):void
		{
			btnCar.removeEventListener(MouseEvent.CLICK, addCar);

			car = new Car(Math.random() * 0xffffff,Math.random() * 0xffffff);
			APEngine.addGroup(car);

			defaultGroup.addCollidable(car);
			circleGroup.addCollidable(car);
			if ( bridge ) bridge.addCollidable(car);

			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);

			// change the type of the button
			btnCar.label = "Remove Car";

			btnCar.addEventListener(MouseEvent.CLICK, removeCar);
		}

		private function removeCar ( m:MouseEvent ):void
		{
			btnCar.removeEventListener(MouseEvent.CLICK, removeCar);

			// remove the car
			APEngine.removeGroup(car);

			// change the label
			btnCar.label = "Add Car";

			// change the button action
			btnCar.addEventListener(MouseEvent.CLICK, addCar);
		}

		private function run(e:Event):void
        {
            APEngine.step();
            APEngine.paint();
        }

		private function removeLastBall( m:MouseEvent ):void
		{
			if ( circle ) circle.cleanup();
		}

		private function clearBoard( m:MouseEvent ):void
		{
			APEngine.removeGroup(defaultGroup);
			APEngine.removeGroup(circleGroup);
			if ( bridge ) APEngine.removeGroup(bridge);
			if ( car ) APEngine.removeGroup(car);
			init();

		}

		function keyPressed(event:KeyboardEvent):void {
            var keySpeed:Number = 0.8;  

            if (event.keyCode == Keyboard.UP || event.keyCode == Keyboard.RIGHT)
            {
                car.speed = keySpeed;
            }  

            if (event.keyCode == Keyboard.DOWN || event.keyCode == Keyboard.LEFT)
            {
                car.speed = -keySpeed;
            }
        }  

        function keyReleased(event:KeyboardEvent):void
        {
            car.speed = 0;
        }  

		private function buildUI():void
		{

			// NEW BUTTONS
            var btnAddBall:Button = new Button();
            btnAddBall.width = 65;
            btnAddBall.height = 25;
            btnAddBall.move ( 5, stage.stageHeight - 20 - btnAddBall.height / 2 );
            btnAddBall.label = "Add Ball";      

            addChild(btnAddBall);      

            btnAddBall.addEventListener(MouseEvent.CLICK, addBall);  

			var btnRemoveBall:Button = new Button();
            btnRemoveBall.width = 120;
            btnRemoveBall.height = 25;
            btnRemoveBall.move ( 75, stage.stageHeight - 20 - btnRemoveBall.height / 2 );
            btnRemoveBall.label = "Remove Last Ball";      

            addChild(btnRemoveBall);

            btnRemoveBall.addEventListener(MouseEvent.CLICK, removeLastBall);

			btnCar = new Button();
            btnCar.width = 100;
            btnCar.height = 25;
            btnCar.move ( 200, stage.stageHeight - 20 - btnCar.height / 2 );
            btnCar.label = "Add Car";      

            addChild(btnCar);

            btnCar.addEventListener(MouseEvent.CLICK, addCar);

			var btnClearBoard:Button = new Button();
            btnClearBoard.width = 120;
            btnClearBoard.height = 25;
            btnClearBoard.move ( 575, stage.stageHeight - 20 - btnClearBoard.height / 2 );
            btnClearBoard.label = "Clear Board";      

            addChild(btnClearBoard);

            btnClearBoard.addEventListener(MouseEvent.CLICK, clearBoard);
		}
	}
}
</pre>
<p>The new Car class</p>
<pre name="code" class="c-sharp">
package {

	import org.cove.ape.*;

	public class Car extends Group {

		private var wheelParticleA:WheelParticle;
		private var wheelParticleB:WheelParticle;

		public function Car(colC:uint, colE:uint) {

			wheelParticleA = new WheelParticle(140,10,14,false,2);
			wheelParticleA.setStyle(0, colC, 1, colE);
			addParticle(wheelParticleA);
			wheelParticleA.sprite.cacheAsBitmap = true;

			wheelParticleB = new WheelParticle(200,10,14,false,2);
			wheelParticleB.setStyle(0, colC, 1, colE);
			addParticle(wheelParticleB);
			wheelParticleB.sprite.cacheAsBitmap = true;

			var wheelConnector:SpringConstraint = new SpringConstraint(wheelParticleA, wheelParticleB, 0.5, true, 8);
			wheelConnector.setStyle(0, colC, 1, colE);
			addConstraint(wheelConnector);
		}

		public function set speed(s:Number):void {
			wheelParticleA.angularVelocity = s;
			wheelParticleB.angularVelocity = s;
		}
	}
}
</pre>
<p>The new Bridge class</p>
<pre name="code" class="c-sharp">
package {

	import org.cove.ape.*;

	public class Bridge extends Group {

		public function Bridge(bx:Number, by:Number, yslope:Number, bsize:Number, particleSize:Number=20, colB:uint=0x000000, colC:uint=0x000000, colD:uint=0x000000) {	

			var bridgePAA:CircleParticle = new CircleParticle(bx,by,particleSize,true);
			bridgePAA.setStyle(1, colC, 1, colB);
			addParticle(bridgePAA);

			bx += bsize;
			by += yslope;
			var bridgePA:CircleParticle = new CircleParticle(bx,by,particleSize);
			bridgePA.setStyle(1, colC, 1, colB);
			addParticle(bridgePA);

			bx += bsize;
			by += yslope;
			var bridgePB:CircleParticle = new CircleParticle(bx,by,particleSize);
			bridgePB.setStyle(1, colC, 1, colB);
			addParticle(bridgePB);

			bx += bsize;
			by += yslope;
			var bridgePC:CircleParticle = new CircleParticle(bx,by,particleSize);
			bridgePC.setStyle(1, colC, 1, colB);
			addParticle(bridgePC);

			bx += bsize;
			by += yslope;
			var bridgePD:CircleParticle = new CircleParticle(bx,by,particleSize);
			bridgePD.setStyle(1, colC, 1, colB);
			addParticle(bridgePD);

			bx += bsize;
			by += yslope;
			var bridgePDD:CircleParticle = new CircleParticle(bx,by,particleSize,true);
			bridgePDD.setStyle(1, colC, 1, colB);
			addParticle(bridgePDD);

			var bridgeConnA:SpringConstraint = new SpringConstraint(bridgePAA, bridgePA, 0.9, true, 10, 0.8);

			// collision response on the bridgeConnA will be ignored on
			// on the first 1/4 of the constraint. this avoids blow ups
			// particular to springcontraints that have 1 fixed particle.

			bridgeConnA.fixedEndLimit = 0.25;
			bridgeConnA.setStyle(1, colC, 1, colB);
			addConstraint(bridgeConnA);

			var bridgeConnB:SpringConstraint = new SpringConstraint(bridgePA, bridgePB, 0.9, true, 10, 0.8);
			bridgeConnB.setStyle(1, colC, 1, colB);
			addConstraint(bridgeConnB);

			var bridgeConnC:SpringConstraint = new SpringConstraint(bridgePB, bridgePC, 0.9, true, 10, 0.8);
			bridgeConnC.setStyle(1, colC, 1, colB);
			addConstraint(bridgeConnC);

			var bridgeConnD:SpringConstraint = new SpringConstraint(bridgePC, bridgePD, 0.9, true, 10, 0.8);
			bridgeConnD.setStyle(1, colC, 1, colB);
			addConstraint(bridgeConnD);

			var bridgeConnE:SpringConstraint = new SpringConstraint(bridgePD, bridgePDD, 0.9, true, 10, 0.8);
			bridgeConnE.fixedEndLimit = 0.25;
			bridgeConnE.setStyle(1, colC, 1, colB);
			addConstraint(bridgeConnE);

		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/08/15/ape-project-step-8-adding-a-fixed-bridge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APE Project &#8211; Step 7 &#8211; Rotating Rectangle Particles &#8211; Fix</title>
		<link>http://manewc.com/2008/08/14/ape-project-step-7-rotating-rectangle-particles-fix/</link>
		<comments>http://manewc.com/2008/08/14/ape-project-step-7-rotating-rectangle-particles-fix/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 17:35:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=171</guid>
		<description><![CDATA[Well, I always knew that the best debugging practice is to walk away and revisit the issue at a later time &#8211; and with the extra spare time it is best to get some rest, drink some beer, or just watch my girlfriend decorate our house with her designer handmade crafts. Anyways, I have found [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I always knew that the best debugging practice is to walk away and revisit the issue at a later time &#8211; and with the extra spare time it is best to get some rest, drink some beer, or just watch my girlfriend decorate our house with her <a href="http://www.filminthefridge.com/">designer handmade crafts</a>. Anyways, I have found my issue which was my lack of control of event listeners &#8211; when the user clicked the rectangle to rotate it the movie was also thinking that another rectangle would like to be drawn.</p>
<p>The <strong>fix for this</strong> is that I added a variable called &#8216;canDraw&#8217; which is enabled when you hold down the shift and drag your mouse across the stage to create a rectangle. To rotate the rectangle you simply click the rectangle that you drew and it will rotate by .5 radians. For now you can only rotate the latest created rectangle.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEProject_1779655575"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEProject7/APEProject.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEProject7/APEProject.swf"
			name="fm_APEProject_1779655575"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is just the new Main document class:</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.display.Shape;
	import flash.ui.Keyboard;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	import flash.events.Event;
	import flash.geom.Rectangle;
	import fl.controls.Button;
	import org.cove.ape.*;

	public class Main extends Sprite {

		private var beginX:Number; // top left x position
		private var beginY:Number; // top left y position
       	private var endX:Number; // bottom right x position
       	private var endY:Number; // bottom right y position  

		private var dynRect:RectangleParticle;
		private var canDraw:Boolean = false; // this allows the drawing of rectangles
		private var circle:CircleParticle;
		private var circleGroup:Group;
        private var defaultGroup:Group;

		private var car:Car;
		private var btnCar:Button;

		// rectangle particle dimensions
		private var _xpos:Number;
		private var _ypos:Number;
		private var _rwidth:Number;
		private var _rheight:Number;
		private var _rrotation:Number = 0;

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

            // Initialize the engine. The argument here is the time step value.
            // Higher values scale the forces in the sim, making it appear to run
            // faster or slower. Lower values result in more accurate simulations.
            APEngine.init(1/4);  

            // set up the default diplay container
            APEngine.container = this;  

            APEngine.addMasslessForce(new Vector(0,8));  

            defaultGroup = new Group();  

            defaultGroup.collideInternal = true;

			circleGroup = new Group();
			circleGroup.collideInternal = true;

			// this is the bottom
			var rect:RectangleParticle = new RectangleParticle(345, 680, 710, 40, 0, true);
            defaultGroup.addParticle(rect);  

			var l:RectangleParticle = new RectangleParticle(0, stage.stageHeight / 2 - 20, 10, stage.stageHeight-40, 0, true);
            defaultGroup.addParticle(l);

			var r:RectangleParticle = new RectangleParticle(stage.stageWidth, stage.stageHeight / 2 - 20, 10, stage.stageHeight-40, 0, true);
            defaultGroup.addParticle(r);

            APEngine.addGroup(defaultGroup);
			APEngine.addGroup(circleGroup);

			// make the groups collidable
			defaultGroup.addCollidable(circleGroup);

			addEventListener(Event.ENTER_FRAME, run);

			stage.addEventListener(KeyboardEvent.KEY_DOWN, allowDraw);
			stage.addEventListener(KeyboardEvent.KEY_UP, disallowDraw);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, beginRectDraw);
			stage.addEventListener(MouseEvent.MOUSE_UP, stopRectDraw);

			// build the UI
			buildUI();
		}

		function allowDraw(event:KeyboardEvent):void
		{
			if ( event.keyCode == 16 )
			{
            	canDraw = true;
			}
        }

		function disallowDraw(event:KeyboardEvent):void {
            if ( canDraw ) canDraw = false;
        }

		private function beginRectDraw(m:MouseEvent):void
       	{
			beginX = mouseX;
			beginY = mouseY;
       	}

		private function stopRectDraw(m:MouseEvent):void
       	{
			// set the end points
           	endX = mouseX;
		   	endY = mouseY;

			// now draw the rectangle
			if ( canDraw ) drawRectangle();
		}

		private function drawRectangle():void
		{
			if ( beginY < 660 &#038;&#038; endY < 660 )
			{
				// store the data
				_xpos = beginX + ((endX - beginX)/2);
				_ypos = beginY + ((endY - beginY)/2);
				_rwidth = endX - beginX;
				_rheight = endY - beginY;
				_rrotation = 0;

				dynRect = new RectangleParticle(_xpos, _ypos, _rwidth, _rheight, _rrotation, true);
            	defaultGroup.addParticle(dynRect);

				dynRect.sprite.addEventListener ( MouseEvent.MOUSE_DOWN, rotateRectangle );
			}
		}

		private function rotateRectangle( m:MouseEvent ):void
		{
			if ( !canDraw )
			{
				// increment the angle
				_rrotation += .05;

				// rid of the particle
				defaultGroup.removeParticle(dynRect);

				// redraw the particle
				dynRect = new RectangleParticle(_xpos, _ypos, _rwidth, _rheight, _rrotation, true);
            	defaultGroup.addParticle(dynRect);

				dynRect.sprite.addEventListener ( MouseEvent.MOUSE_DOWN, rotateRectangle );
			}
		}

		private function addBall( m:MouseEvent ):void
        {
            circle = new CircleParticle(Math.random() * stage.stageWidth, Math.random() * 100, Math.random() * 25 + 5);
            circleGroup.addParticle(circle);
        }

		private function addCar ( m:MouseEvent ):void
		{
			btnCar.removeEventListener(MouseEvent.CLICK, addCar);

			car = new Car(Math.random() * 0xffffff,Math.random() * 0xffffff);
            APEngine.addGroup(car);
			defaultGroup.addCollidable(car);
			circleGroup.addCollidable(car);

			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);

			// change the type of the button
			btnCar.label = "Remove Car";

			btnCar.addEventListener(MouseEvent.CLICK, removeCar);
		}

		private function removeCar ( m:MouseEvent ):void
		{
			btnCar.removeEventListener(MouseEvent.CLICK, removeCar);

			// remove the car
			APEngine.removeGroup(car);

			// change the label
			btnCar.label = "Add Car";

			// change the button action
			btnCar.addEventListener(MouseEvent.CLICK, addCar);
		}

		private function run(e:Event):void
        {
            APEngine.step();
            APEngine.paint();
        }

		private function removeLastBall( m:MouseEvent ):void
		{
			if ( circle ) circle.cleanup();
		}

		private function clearBoard( m:MouseEvent ):void
		{
			APEngine.removeGroup(defaultGroup);
			APEngine.removeGroup(circleGroup);
			APEngine.removeGroup(car);
			init();

		}

		function keyPressed(event:KeyboardEvent):void {
            var keySpeed:Number = 0.8;  

            if (event.keyCode == Keyboard.UP || event.keyCode == Keyboard.RIGHT)
            {
                car.speed = keySpeed;
            }  

            if (event.keyCode == Keyboard.DOWN || event.keyCode == Keyboard.LEFT)
            {
                car.speed = -keySpeed;
            }
        }  

        function keyReleased(event:KeyboardEvent):void
        {
            car.speed = 0;
        }  

		private function buildUI():void
		{

			// NEW BUTTONS
            var btnAddBall:Button = new Button();
            btnAddBall.width = 65;
            btnAddBall.height = 25;
            btnAddBall.move ( 5, stage.stageHeight - 20 - btnAddBall.height / 2 );
            btnAddBall.label = "Add Ball";      

            addChild(btnAddBall);      

            btnAddBall.addEventListener(MouseEvent.CLICK, addBall);  

			var btnRemoveBall:Button = new Button();
            btnRemoveBall.width = 120;
            btnRemoveBall.height = 25;
            btnRemoveBall.move ( 75, stage.stageHeight - 20 - btnRemoveBall.height / 2 );
            btnRemoveBall.label = "Remove Last Ball";      

            addChild(btnRemoveBall);

            btnRemoveBall.addEventListener(MouseEvent.CLICK, removeLastBall);

			btnCar = new Button();
            btnCar.width = 100;
            btnCar.height = 25;
            btnCar.move ( 200, stage.stageHeight - 20 - btnCar.height / 2 );
            btnCar.label = "Add Car";      

            addChild(btnCar);

            btnCar.addEventListener(MouseEvent.CLICK, addCar);

			var btnClearBoard:Button = new Button();
            btnClearBoard.width = 120;
            btnClearBoard.height = 25;
            btnClearBoard.move ( 575, stage.stageHeight - 20 - btnClearBoard.height / 2 );
            btnClearBoard.label = "Clear Board";      

            addChild(btnClearBoard);

            btnClearBoard.addEventListener(MouseEvent.CLICK, clearBoard);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/08/14/ape-project-step-7-rotating-rectangle-particles-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APE Project &#8211; Step 6 &#8211; Rotating Rectangle Particles</title>
		<link>http://manewc.com/2008/08/13/ape-project-step-6-rotating-rectangle-particles/</link>
		<comments>http://manewc.com/2008/08/13/ape-project-step-6-rotating-rectangle-particles/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 18:14:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=170</guid>
		<description><![CDATA[I&#8217;ll have to finish this little piece up tomorrow, as it is not working properly at the moment. Ideally I want the user the ability to rotate the dynamically drawn rectangle by simply clicking the rectangle. I have found that the Rectangle Particle needs to be redrawn in order to edit the angle &#8211; you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll have to finish this little piece up tomorrow, as it is not working properly at the moment. Ideally I want the user the ability to rotate the dynamically drawn rectangle by simply clicking the rectangle. I have found that the Rectangle Particle needs to be redrawn in order to edit the angle &#8211; you can actually rotate the object, but the collision detection with other objects does not stand true. So we will continue on until tomorrow.. for now, if you drag your mouse to draw the rectangle and then immediately click the rectangle, the object will rotate.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEProject_1158786051"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEProject6/APEProject.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEProject6/APEProject.swf"
			name="fm_APEProject_1158786051"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>I just made some edits and additions to Main.as:</p>
<pre name="code" class="c-sharp">
private function drawRectangle():void
		{
			if ( beginY < 660 &#038;&#038; endY < 660 )
			{
				// store the data
				_xpos = beginX + ( (endX - beginX)/2 );
				_ypos = beginY + ((endY - beginY)/2);
				_rwidth = endX - beginX;
				_rheight = endY - beginY;
				_rrotation = 0;

				dynRect = new RectangleParticle(_xpos, _ypos, _rwidth, _rheight, _rrotation, true);
            	defaultGroup.addParticle(dynRect);

				dynRect.sprite.addEventListener ( MouseEvent.MOUSE_DOWN, rotateRectangle );
			}
		}

		private function rotateRectangle( m:MouseEvent ):void
		{
			// increment the angle
			_rrotation += 5;

			// rid of the particle
			defaultGroup.removeParticle(dynRect);

			// redraw the particle
			dynRect = new RectangleParticle(_xpos, _ypos, _rwidth, _rheight, _rrotation, true);
            defaultGroup.addParticle(dynRect);

			dynRect.sprite.addEventListener ( MouseEvent.MOUSE_DOWN, rotateRectangle );
		}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/08/13/ape-project-step-6-rotating-rectangle-particles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
