Packagecom.desuade.motion.physics
Classpublic class BasicPhysics
InheritanceBasicPhysics Inheritance BaseBasic Inheritance flash.events.EventDispatcher

Language Version : ActionScript 3
Since : 27.04.2009
Runtime Versions : AIR 1.0, Flash Player 9.0.0

This class simulates very basic physics, using basic motion equations to change the value of a property. This can be used like a 'tween' to change any property's value, not just positional properties like x and y.



Public Properties
 PropertyDefined By
  acceleration : Number
Sets/gets the acceleration of the config and PrimitivePhysics object
BasicPhysics
 Inheritedactive : Boolean
[read-only] If the primitive is currently active and running.
BaseBasic
 Inheritedconfig : Object
[read-only] Gets the config object that was passed in the constructor.
BaseBasic
  friction : Number
Sets/gets the friction of the config and PrimitivePhysics object
BasicPhysics
 Inheritedpid : int
[read-only] The primitive's id
BaseBasic
 Inheritedtarget : Object
The target object
BaseBasic
  velocity : Number
Sets/gets the velocity of the config and PrimitivePhysics object
BasicPhysics
Public Methods
 MethodDefined By
  
BasicPhysics(target:Object, configObject:Object = null)
This creates a BasicPhysics object. Each BasicPhysics object controls a single property on a given target object, and applies basic physics equations to calculate a change in value. Unlike tweens, there is no end value, and the BasicPhysics' update will continue to run until it is stopped, or it reaches the specified duration. Paramaters for the configObject: property:String – The property to apply the physics to. velocity:Number – The velocity of the property.
BasicPhysics
 Inherited
fromXML(xml:XML):*
Configures the object based on the values provided by the XML. Most properties can assigned in the attributes using the same names. The values of the attributes will be converted to Numbers if they're not NaN.
BaseBasic
  
getVelocityWithAngle(velocity:Number, angle:Number, flip:Boolean):Number
[static] Gets the velocity that's calculated with a given angle.
BasicPhysics
 Inherited
start(delay:Number = -1, position:Number = -1):*
This starts and creates the primitive.
BaseBasic
  
startAtTime(time:Number = 0, rate:Number = 0):BasicPhysics
This will start the physics as if it's already been running for the given amount of time.
BasicPhysics
 Inherited
stop():Boolean
This stops and removes the primitive.
BaseBasic
 Inherited
toXML():XML
This creates an XML object that represents the object, based on it's config object.
BaseBasic
Property Detail
accelerationproperty
acceleration:Number

Sets/gets the acceleration of the config and PrimitivePhysics object


Implementation
    public function get acceleration():Number
    public function set acceleration(value:Number):void
frictionproperty 
friction:Number

Sets/gets the friction of the config and PrimitivePhysics object


Implementation
    public function get friction():Number
    public function set friction(value:Number):void
velocityproperty 
velocity:Number

Sets/gets the velocity of the config and PrimitivePhysics object


Implementation
    public function get velocity():Number
    public function set velocity(value:Number):void
Constructor Detail
BasicPhysics()Constructor
public function BasicPhysics(target:Object, configObject:Object = null)

This creates a BasicPhysics object.

Each BasicPhysics object controls a single property on a given target object, and applies basic physics equations to calculate a change in value.

Unlike tweens, there is no end value, and the BasicPhysics' update will continue to run until it is stopped, or it reaches the specified duration.

Paramaters for the configObject:

Parameters
target:Object — The target object.
 
configObject:Object (default = null) — The object containing the physics configuration values.

See also

Method Detail
getVelocityWithAngle()method
public static function getVelocityWithAngle(velocity:Number, angle:Number, flip:Boolean):Number

Gets the velocity that's calculated with a given angle.

Parameters

velocity:Number — The velocity to use
 
angle:Number — The angle used to determine the new velocity
 
flip:Boolean — Negate (or flip) the velocity.

Returns
Number — Number representing the new angle-velocity
startAtTime()method 
public function startAtTime(time:Number = 0, rate:Number = 0):BasicPhysics

This will start the physics as if it's already been running for the given amount of time.

Parameters

time:Number (default = 0) — How long in seconds to emulate
 
rate:Number (default = 0) — If the target isn't a DisplayObject, you need to set the fps manually here, or BaseTicker.physicsRate.

Returns
BasicPhysics — The BasicPhysics object.