I'm playing with a Physics Engine for AS3 and the code below is basically the hello world example. However, I made a slight change by declaring the property "ball" as a WheelParticle at the beginning of the class definition. (forgive my terminology if it's wrong). Before, it was declared inside the constructor as
var ball:WheelParticle = new WheelParticle(...);
and that worked fine. But now, trying it my way I get the error
Implicit Coercion of a value of type org.cove.ape.WheelParticle to an unrelated type Class | ball:WheelParticle = new... etc etc
"illegal assignment to class WheelParticle"
So I'm thinking my declaration public var ball:WheelParticle
should be something else. But what?
Anyway, here's the code. It's quite short. I would refer to the documentation, but there is none. None that I can find anyway.
package{
import org.cove.ape.*;
import flash.events.*;
import flash.display.Sprite;
public class Bounce extends Sprite {
public var ball:WheelParticle;
public function Bounce() {
stage.focus = this;
stage.frameRate = 100;
addEventListener(Event.ENTER_FRAME, run);
stage.addEventListener(KeyboardEvent.KEY_DOWN, moveLeft);
APEngine.init(0.3);
APEngine.container = this;
APEngine.addMasslessForce(new Vector(0,2));
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
var ball:WheelParticle = new WheelParticle(250,10,40, false, 1, 0.7, 0.1);
defaultGroup.addParticle(ball);
var rp:RectangleParticle = new RectangleParticle(250,300,300,50,0,true);
defaultGroup.addParticle(rp);
APEngine.addGroup(defaultGroup);
}
private function moveLeft(e:Event):void{
ball.speed += 1;
}
private function run(evt:Event):void {
APEngine.step();
APEngine.paint();
}
}
}