Packagecom.fileitup.fisixengine.constraints
Classpublic class SpringConstraint
InheritanceSpringConstraint Inheritance Constraint
SubclassesStickConstraint

Connects two objects to eachother.

The spring constraint is the most basic type of constraint, and is used to build both rigid and soft bodies. The StickConstraint is a derivative of the SpringConstraint who's stiffness value is always 1.

See also

StickConstraint
com.fileitup.fisixengine.primitives.constraint


Public Properties
 PropertyDefined by
 InheritedbreakPoint : Number
The point at which a constraint should be broken.
Constraint
 Inheritedbroken : Boolean
Tells you whether or not a constraint is currently broken.
Constraint
  max : Number
[write-only]The upper range of the constraint.
SpringConstraint
  min : Number
[write-only]The lower range of the constraint.
SpringConstraint
 Inheritedparent : FisixObject
Constraint
  particleA : Particle
SpringConstraint
  particleB : Particle
SpringConstraint
  restLength : Number
The length that the constraint will attempt to maintain.
SpringConstraint
 Inheritedstiffness : Number
A value between 0 - 1 representing the stiffness of the constraint.
Constraint
 InheritedunloadOnBreak : Boolean = true
When true, the constraint is removed from the simulation when broken.
Constraint
Protected Properties
 PropertyDefined by
  restLengthSquared : Number
SpringConstraint
  restMinSquared : Number
SpringConstraint
Public Methods
 MethodDefined by
  
SpringConstraint(pA:Particle, pB:Particle, tStiff:Number = 0.5, rLen:Number = -1)
Creates a SpringConstraint object.
SpringConstraint
  
constraintAll(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
[static]A static method for quickly constraining a list of objects to eachother.
SpringConstraint
  
constraintChain(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
[static]A static method for quickly constraining a list of objects in a chain.
SpringConstraint
  
constraintTwoLists(fis:FisixObject, arrA:Array, arrB:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
[static]A static method for quickly constraining two lists of of objects to eachother.
SpringConstraint
  
dispose():void
SpringConstraint
  
getAngle():Number
SpringConstraint
  
render(g:Graphics):void
SpringConstraint
 Inherited
setMinMax(minimum:Number, maximum:Number):void
Sets both min and max values in one line
Constraint
  
solve():void
SpringConstraint
 Inherited
unload():void
Constraint
Protected Methods
 MethodDefined by
 Inherited
Constraint
 Inherited
onBreak():void
Constraint
 Inherited
onUnload():void
Constraint
  
solveConstraint(len:Number, len2:Number):void
SpringConstraint
Property detail
maxproperty
max:Number  [write-only]

The upper range of the constraint.

By setting this value, you are disabling the use of the restLength property, so it's good practice to set both the min and max values at the same time.
Note that valid values are always positive values.
In order to disable the maximum bound, set this property to a negative value.

Implementation
    public function set max(value:Number):void
minproperty 
min:Number  [write-only]

The lower range of the constraint.

By setting this value, you are disabling the use of the restLength property, so it's good practice to set both the min and max values at the same time.
Note that valid values are always positive values.
In order to disable the minimum bound, set this property to a negative value.

Implementation
    public function set min(value:Number):void
particleAproperty 
public var particleA:Particle
particleBproperty 
public var particleB:Particle
restLengthproperty 
restLength:Number  [read-write]

The length that the constraint will attempt to maintain.

For spring and stick constraints, this represents a pixel distance
For angular constraints, this represents a degree value between 0 and 360.
For more information about angle measures in angular constraints, see the documentation for the AngularConstraint class

Note that by setting this value you disable the use of min/max values (in other words, the constraint is no longer bound to a range, but only one value)

Implementation
    public function get restLength():Number
    public function set restLength(value:Number):void

restLengthSquaredproperty 
protected var restLengthSquared:Number
restMinSquaredproperty 
protected var restMinSquared:Number
Constructor detail
SpringConstraint()constructor
public function SpringConstraint(pA:Particle, pB:Particle, tStiff:Number = 0.5, rLen:Number = -1)

Creates a SpringConstraint object.

Parameters
pA:Particle — the first object to constraint
 
pB:Particle — the second object to constraint
 
tStiff:Number (default = 0.5) — the stiffness of the constraint - a value between 0 and 1
 
rLen:Number (default = -1) — the rest length of the constraint. leave this at -1 to use the current distance between pA and pB
Method detail
constraintAll()method
public static function constraintAll(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void

A static method for quickly constraining a list of objects to eachother.

Parameters
fis:FisixObject — The FisixObject in which the constraints will be created.
 
arr:Array — An array of Particles to be constrained to eachother.
 
stiffness:Number (default = 0.5) — The stiffness of the created springs
 
breakPoint:Number (default = 0) — The breakPoint of the created springs. leave at 0 for unbreakable springs.

Example
The following code constraints 4 particles to eachother to form a box:
   var box:FisixObject = new FisixObject()
   var p1:CircleParticle = box.newCircleParticle(0,0,20)
   var p2:CircleParticle = box.newCircleParticle(20,0,20)
   var p3:CircleParticle = box.newCircleParticle(20,20,20)
   var p4:CircleParticle = box.newCircleParticle(0,20,20)
   
   //you can constraint all these particles like so:
   SpringConstraint.constraintAll(box.particles)
   //or like so
   //SpringConstraint.constraintAll([p1,p2,p3,p4])
   

constraintChain()method 
public static function constraintChain(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void

A static method for quickly constraining a list of objects in a chain. The first particle will be constrained to the second particle, which will be constrained to the third particle, and so on...

Parameters
fis:FisixObject — The FisixObject in which the constraints will be created.
 
arr:Array — An array of Particles to be constrained into a chain.
 
stiffness:Number (default = 0.5) — The stiffness of the created springs
 
breakPoint:Number (default = 0) — The breakPoint of the created springs. leave at 0 for unbreakable springs.

Example
The following code constraints 4 particles to eachother to form a chain:
   var box:FisixObject = new FisixObject()
   var p1:CircleParticle = box.newCircleParticle(0,0,20)
   var p2:CircleParticle = box.newCircleParticle(20,0,20)
   var p3:CircleParticle = box.newCircleParticle(20,20,20)
   var p4:CircleParticle = box.newCircleParticle(0,20,20)
   
   //you can constraint all these particles like so:
   SpringConstraint.constraintChain(box.particles)
   //or like so
   //SpringConstraint.constraintChain([p1,p2,p3,p4])
   

constraintTwoLists()method 
public static function constraintTwoLists(fis:FisixObject, arrA:Array, arrB:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void

A static method for quickly constraining two lists of of objects to eachother. All the objects in the first list will be constrained to all the objects in the second list.

Parameters
fis:FisixObject — The FisixObject in which the constraints will be created.
 
arrA:Array — The first array of Particles to be constrained.
 
arrB:Array — The other array of Particles to be constrained.
 
stiffness:Number (default = 0.5) — The stiffness of the created springs
 
breakPoint:Number (default = 0) — The breakPoint of the created springs. leave at 0 for unbreakable springs.

Example
The following code constraints 2 lists of particles to eachother:
   var box:FisixObject = new FisixObject()
   var p1:CircleParticle = box.newCircleParticle(0,0,20)
   var p2:CircleParticle = box.newCircleParticle(20,0,20)
   var p3:CircleParticle = box.newCircleParticle(20,20,20)
   var p4:CircleParticle = box.newCircleParticle(0,20,20)
   
   SpringConstraint.constraintTwoLists([p1,p2],[p3,p4])
   //note that p1 and p2 will be constrained to p3 and p4
   //but p1 won't be constrained to p2, and neither will p3 be to p4
   

dispose()method 
public override function dispose():void
getAngle()method 
public function getAngle():Number

Returns
Number
render()method 
public override function render(g:Graphics):voidParameters
g:Graphics
solve()method 
public override function solve():void
solveConstraint()method 
protected override function solveConstraint(len:Number, len2:Number):voidParameters
len:Number
 
len2:Number