
Click image to view demo
Click around above and you will see an example using the ElasticForce, Force, and PhysicsParticle classes from
the Chapter 11 Penner AS2 post
To replicate this example, add a circle MovieClip to the stage with an instance name of “ball”.
Then on the root timeline add the following code:
import com.robertpenner.physics.PhysicsParticle;
import com.robertpenner.physics.forces.ElasticForce;
var p:PhysicsParticle = new PhysicsParticle(ball, ball._x, ball._y);
p.setFriction(.1);
var eForce:ElasticForce = new ElasticForce(130, 70, .2);
p.addForce("elastic", eForce);
this.onMouseDown = function() {
eForce.setAnchor(this._xmouse, this._ymouse);
}
stop();
This entry was posted in Flash. Bookmark the
permalink. Trackbacks are closed, but you can .
Penner AS2 ProFMX: PhysicsParticle Example
Click image to view demo
Click around above and you will see an example using the ElasticForce, Force, and PhysicsParticle classes from the Chapter 11 Penner AS2 post
To replicate this example, add a circle MovieClip to the stage with an instance name of “ball”.
Then on the root timeline add the following code:
import com.robertpenner.physics.PhysicsParticle; import com.robertpenner.physics.forces.ElasticForce; var p:PhysicsParticle = new PhysicsParticle(ball, ball._x, ball._y); p.setFriction(.1); var eForce:ElasticForce = new ElasticForce(130, 70, .2); p.addForce("elastic", eForce); this.onMouseDown = function() { eForce.setAnchor(this._xmouse, this._ymouse); } stop();