Hi for all again, talking back about the Actionscript Physics Engine – APE – i will talk about three simple error when working with this engine for first time:

One: Flash Player version.

apeErrors

The APE may be only exported using Flash Player 9, this engine don’t support the Flash Player 10 yet. To use X, Y and Z you will need use other engine with 3D support like Papervision 3D.

Two: Engine Object

A simple problem about the APE is the APEngine Object don’t will created into your Document Class, you will use only APEngine.init() direct with out create the APEngine object.

Three: APEngine Library import

Create a Flash document and actionscript file like document class isn’t the full work to initialize. For all your projects you need create an folder with your libraries and put theses folders in your source Path like use into Flex. Go to Edit > Preferences > Actionscript > Actionscript 3.0 Settings like show pictures:

apeLibraries

Other view is the source folder:

apeLibraries2

Like show in last image, into this folder have all the libraries and into org folder have other named cove and other name ape into cove. If you download the source library via SVN you can copy and past it here into your library folder and is less one problem.

If you have other problems using APE you can search help into APE – General Group. The link is in my last post about the APE:   APE – Actionscript Physics Engine for beginners

APE – Actionscript Physics Engine – is an Actionscript 3 library that create physics objects into Flash, using Flash CS3 and CS4, with Flash Player 9, powerfull utility for Flash games because suport physics, collisions and others.

APE (Actionscript Physics Engine) is a free AS3 open source 2D physics engine for use in Flash and Flex, released under the MIT License. APE is written and maintained by Alec Cove.

A little sample of APE usage:

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Use key A and D to move the car.

Well to begin the APE code we need download and import the class into your actionscript file. To download it you use SVN address: http://ape.googlecode.com/svn/ and to import into actionscript you need use these lines bellow:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package
{
	import flash.display.*;
	import org.cove.ape.*;
 
	public class apeSample extends MovieClip
	{
		private var apeGroup:Group;
		private var wheelr:WheelParticle;
		private var wheell:WheelParticle;
		private var wheelg:SpringConstraint;	
 
		public function apeSample():void
		{
			APEngine.init(1/4);
			APEngine.container = APEBox;
			APEngine.addForce(new VectorForce( false, 0, 2 ) );
			APEngine.damping = .98;
 
			apeGroup = new Group();
			apeGroup.collideInternal = true;
 
			APEngine.addGroup(apeGroup);
 
			APECar();
			APEState();
 
			addEventListener(Event.ENTER_FRAME, runAPE);
		}
 
		private function APECar():void
		{
			var rWheel:DisplayObject = new newBeatleWheel(); // For Custom Display
			wheelr = new WheelParticle(70,40,10,false,3);
			wheelr.setDisplay(rWheel);
			wheelr.addEventListener(CollisionEvent.COLLIDE, checkAPECollision);
 
			var lWheel:DisplayObject = new newBeatleWheel(); // For Custom Display
			wheell = new WheelParticle(144,40,10,false,3);
			wheell.setDisplay(lWheel);
 
			var carBox:DisplayObject = new carObject(); // For Custom Display
			wheelg = new SpringConstraint(wheelr,wheell,.5,true,2,1.6,true);
			wheelg.setDisplay(carBox,-1,15,180); 
 
			apeGroup.addParticle(wheelr);
			apeGroup.addParticle(wheell);
			apeGroup.addConstraint(wheelg);
		}
 
		private function APEState():void
		{
			var floor:RectangleParticle = new RectangleParticle(stage.stageWidth/2,stage.stageHeight/4,2000,20,0,true);
			apeGroup.addParticle(floor);
		}
 
		private function runAPE():void
		{
			APEngine.step();
			APEngine.paint();
		}
	}
}

A Simple sample of car running:

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Use LEFT and RIGHT arrow to move the car.
Soon more codes and samples using APE Physics and bellow some links for download ando study it.

APE Site: http://www.cove.org/ape/
APE Google Group : http://groups.google.com/group/ape-general/