Packageflare.physics
Classpublic class Spring

Represents a Spring in a physics simulation. A spring connects two particles and is defined by the springs rest length, spring tension, and damping (friction) co-efficient.



Public Properties
 PropertyDefined by
  damping : Number
The damping (friction) co-efficient of the spring.
Spring
  die : Boolean
Flag indicating that the spring is scheduled for removal.
Spring
  p1 : Particle
The first particle attached to the spring.
Spring
  p2 : Particle
The second particle attached to the spring.
Spring
  restLength : Number
The rest length of the spring.
Spring
  tag : uint
Tag property for storing an arbitrary value.
Spring
  tension : Number
The tension of the spring.
Spring
Public Methods
 MethodDefined by
  
Spring(p1:Particle, p2:Particle, restLength:Number = 10, tension:Number = 0.1, damping:Number = 0.1)
Creates a new Spring with given parameters.
Spring
  
init(p1:Particle, p2:Particle, restLength:Number = 10, tension:Number = 0.1, damping:Number = 0.1):void
Initializes an existing spring instance.
Spring
  
kill():void
"Kills" this spring, scheduling it for removal in the next simulation cycle.
Spring
Property detail
dampingproperty
public var damping:Number

The damping (friction) co-efficient of the spring.

dieproperty 
public var die:Boolean

Flag indicating that the spring is scheduled for removal.

p1property 
public var p1:Particle

The first particle attached to the spring.

p2property 
public var p2:Particle

The second particle attached to the spring.

restLengthproperty 
public var restLength:Number

The rest length of the spring.

tagproperty 
public var tag:uint

Tag property for storing an arbitrary value.

tensionproperty 
public var tension:Number

The tension of the spring.

Constructor detail
Spring()constructor
public function Spring(p1:Particle, p2:Particle, restLength:Number = 10, tension:Number = 0.1, damping:Number = 0.1)

Creates a new Spring with given parameters.

Parameters
p1:Particle — the first particle attached to the spring
 
p2:Particle — the second particle attached to the spring
 
restLength:Number (default = 10) — the rest length of the spring
 
tension:Number (default = 0.1) — the tension of the spring
 
damping:Number (default = 0.1) — the damping (friction) co-efficient of the spring
Method detail
init()method
public function init(p1:Particle, p2:Particle, restLength:Number = 10, tension:Number = 0.1, damping:Number = 0.1):void

Initializes an existing spring instance.

Parameters
p1:Particle — the first particle attached to the spring
 
p2:Particle — the second particle attached to the spring
 
restLength:Number (default = 10) — the rest length of the spring
 
tension:Number (default = 0.1) — the tension of the spring
 
damping:Number (default = 0.1) — the damping (friction) co-efficient of the spring
kill()method 
public function kill():void

"Kills" this spring, scheduling it for removal in the next simulation cycle.