The PhysicsParticle class controls a MovieClip, turning it into a particle driven by physics forces. Designed to collaborate with the Force class (and subclasses).
ActionScript 2.0; Flash Player 6
Property summary
Property | Description |
---|---|
position:Vector |
The position property of the PhysicsParticle. |
velocity:Vector |
The velocity property of the PhysicsParticle. |
friction:Vector |
The friction property of the PhysicsParticle. |
xProp:String |
The xProp property of the PhysicsParticle. |
yProp:String |
The yProp property of the PhysicsParticle. |
Method summary
Method | Description |
---|---|
addForce(id:String, force:Force) : Void |
Adds a force to a PhysicsParticle instance. |
removeForce(id:String) : Void |
Removes a force from a PhysicsParticle instance. |
getPosition() : Vector |
Gets the position of a PhysicsParticle instance. |
setPosition(x:Number, y:Number) : Void |
Sets the position of a PhysicsParticle instance. |
getVelocity() : Vector |
Gets the velocity of a PhysicsParticle instance. |
setVelocity(vx:Number, vy:Number) : Void |
Sets the velocity of a PhysicsParticle instance. |
getFriction() : Vector |
Gets the friction of a PhysicsParticle instance. |
setFriction(fx:Number, fy:Number) : Void |
Sets the friction of a PhysicsParticle instance. |
setXYProps(xp:String, yp:String) : Void |
Sets both xProp and yProp of the PhysicsParticle. |
var p:PhysicsParticle = new PhysicsParticle(this, 0, 0, "_x", "_yscale");
target:MovieClip
- The MovieClip that represents the particle visually.
x:Number
- The initial x position of the particle.
y:Number
- The initial y position of the particle.
xProp:String
- The name of the property to link to the x component of the position; this defaults to "_x" if the parameter is omitted.
yProp:String
- The name of the property to link to the y component of the position; this defaults to "_y" if the parameter is omitted.
Creates an instance of the PhysicsParticle class.
var p:PhysicsParticle = new PhysicsParticle(this, 0, 0, "_x", "_yscale");
var gravityForce:Force = new Force(0, .5);
p.addForce("gravity", gravityForce);
id:String
- A string that gives the force a unique identifier.
force:Force
- An instance of the Force class that will be applied to the particle.
Nothing.
Adds a force to a PhysicsParticle instance.
var p:PhysicsParticle = new PhysicsParticle(this, 0, 0, "_x", "_yscale");
var gravityForce:Force = new Force(0, .5);
p.addForce("gravity", gravityForce);
p.removeForce("gravity");
id:String
- The string identifier of the force to remove.
Nothing.
Removes a force from a PhysicsParticle instance.
trace (p.getPosition());
Nothing.
Gets the position of a PhysicsParticle instance.
var p:PhysicsParticle = new PhysicsParticle(this, 0, 0, "_x", "_yscale");
p.setPosition(10, 10);
x:Number
- The x position of the PhysicsParticle.
y:Number
- The y position of the PhysicsParticle.
Nothing.
Sets the position of a PhysicsParticle instance.
trace (p.getVelocity());
Nothing.
Gets the velocity of a PhysicsParticle instance.
var p:PhysicsParticle = new PhysicsParticle(this, 0, 0, "_x", "_yscale");
p.setVelocity(2, 0);
vx:Number
- The x velocity of the PhysicsParticle.
vy:Number
- The y velocity of the PhysicsParticle.
Nothing.
Sets the velocity of a PhysicsParticle instance.
trace (p.getFriction());
Nothing.
Gets the friction of a PhysicsParticle instance.
var p:PhysicsParticle = new PhysicsParticle(this, 0, 0, "_x", "_yscale");
p.setFriction(.03, .001);
fx:Number
- The amount of friction to apply to the xProp of the PhysicsParticle.
fy:Number
- The amount of friction to apply to the yProp of the PhysicsParticle.
Nothing.
Sets the friction of a PhysicsParticle instance.
p.setXYProps("_xscale", "_yscale");
Nothing.
Sets both xProp and yProp of the PhysicsParticle.
trace (p.position);
The position property of the PhysicsParticle.
trace (p.velocity);
The velocity property of the PhysicsParticle.
trace (p.position);
The friction property of the PhysicsParticle.
trace (p.xProp);
The xProp property of the PhysicsParticle.
trace (p.yProp);
The yProp property of the PhysicsParticle.