Packageorg.goasap.items
Classpublic class GoItem
InheritanceGoItem Inheritance PlayableBase Inheritance flash.events.EventDispatcher
ImplementsIUpdatable
SubclassesLinearGo, PhysicsGo

Abstract base animation class for other base classes like LinearGo and PhysicsGo.

This class extends PlayableBase to add features common to any animation item, either linear or physics (LinearGo and PhysicsGo both extend this class). Animation items add themselves to GoEngine to run on a pulse, so the IUpdatable interface is implemented here, although update() needs to be subclassed.

Animation items should individually implement the standard useRounding and useRelative options. User-accessible class default settings are also provided for those properties and pulseInterval.



Public Properties
 PropertyDefined by
  defaultPulseInterval : Number
[static] Class default for the instance property pulseInterval.
GoItem
  defaultUseRelative : Boolean = false
[static] Class default for the instance property useRelative.
GoItem
  defaultUseRounding : Boolean = false
[static] Class default for the instance property useRounding.
GoItem
 InheritedplayableID : *
An arbitrary id value for the convenient identification of any instance, automatically set to an instance count by this class.
PlayableBase
  pulseInterval : int
Required by IUpdatable: Defines the pulse on which update is called.
GoItem
 Inheritedstate : String
Returns a PlayStates constant.
PlayableBase
  timeMultiplier : Number = 1
[static] Alters the play speed for instances of any subclass that factors this value into its calculations, such as LinearGo.
GoItem
  useRelative : Boolean
CONVENTION ALERT: This property is considered a Go convention, and subclasses must implement it individually. Indicates that values should be treated as relative instead of absolute.
GoItem
  useRounding : Boolean
CONVENTION ALERT: This property is considered a Go convention, and subclasses must implement it individually by calling the correctValue() method on all calculated values before applying them to targets.

The correctValue method fixes NaN's as 0 and applies Math.round if useRounding is active.

GoItem
Protected Properties
 PropertyDefined by
 Inherited_playRetainer : Dictionary
[static] Memory-management: playable items that do not add themselves to GoEngine should use this property to store references to themselves during play.
PlayableBase
Public Methods
 MethodDefined by
  
Constructor.
GoItem
  
correctValue(value:Number):Number
IMPORTANT: Subclasses need to implement this functionality individually.
GoItem
 Inherited
toString():String
Appends the regular toString value with the instance's playableID.
PlayableBase
  
update(currentTime:Number):void
Required by IUpdatable: Perform updates on a pulse.
GoItem
Property detail
defaultPulseIntervalproperty
public static var defaultPulseInterval:Number

Class default for the instance property pulseInterval.

GoEngine.ENTER_FRAME seems to run the smoothest in real-world contexts. The open-source TweenBencher utility shows that timer-based framerates like 33 milliseconds can perform best for thousands of simultaneous animations, but in practical contexts timer-based animations tend to stutter.

The default value is GoEngine.ENTER_FRAME.

See also

defaultUseRelativeproperty 
public static var defaultUseRelative:Boolean = false

Class default for the instance property useRelative.

The default value is false.

See also

defaultUseRoundingproperty 
public static var defaultUseRounding:Boolean = false

Class default for the instance property useRounding.

The default value is false.

See also

pulseIntervalproperty 
pulseInterval:int  [read-write]

Required by IUpdatable: Defines the pulse on which update is called.

Can be a number of milliseconds for Timer-based updates or GoEngine.ENTER_FRAME (-1) for updates synced to the Flash Player's framerate. If not set manually, the class default defaultPulseInterval is adopted.

Implementation
    public function get pulseInterval():int
    public function set pulseInterval(value:int):void

See also

timeMultiplierproperty 
public static var timeMultiplier:Number = 1

Alters the play speed for instances of any subclass that factors this value into its calculations, such as LinearGo.

A setting of 2 should result in half-speed animations, while a setting of .5 should double animation speed. Note that changing this property at runtime does not usually affect already-playing items.

This property is a Go convention, and all subclasses of GoItem (on the LinearGo base class level, but not on the item level extending LinearGo) need to implement it individually.

The default value is 1.

useRelativeproperty 
public var useRelative:Boolean

CONVENTION ALERT: This property is considered a Go convention, and subclasses must implement it individually. Indicates that values should be treated as relative instead of absolute.

When true, user-set values should be calculated as relative to their existing value ("from" vs. "to"), when possible. See an example in the documentation for LinearGo.start.

Items that handle more than one property at once, such as a bezier curve, might want to implement a useRelative option for each property instead of using this overall item property, which is included here to define a convention for standard single-property items.

See also

useRoundingproperty 
public var useRounding:Boolean

CONVENTION ALERT: This property is considered a Go convention, and subclasses must implement it individually by calling the correctValue() method on all calculated values before applying them to targets.

The correctValue method fixes NaN's as 0 and applies Math.round if useRounding is active.

See also

correctValue()
LinearGo.onUpdate()
Constructor detail
GoItem()constructor
public function GoItem()

Constructor.

Method detail
correctValue()method
public function correctValue(value:Number):Number

IMPORTANT: Subclasses need to implement this functionality individually. When updating animation targets, always call correctValue on results first. This corrects any NaN's to 0 and applies Math.round if useRounding is active.

For example, a LinearGo onUpdate method might contain:

   target[ prop ] = correctValue(start + (change _position));
   
Parameters
value:Number

Returns
Number

See also

update()method 
public function update(currentTime:Number):void

Required by IUpdatable: Perform updates on a pulse.

The currentTime parameter enables tight visual syncing of groups of items. To ensure the tightest possible synchronization, do not set any internal start-time vars in the item until the first update() call is received, then set to the currentTime provided by GoEngine. This ensures that groups of items added in a for-loop all have the exact same start times, which may otherwise differ by a few milliseconds.

Parameters
currentTime:Number — A clock time that should be used instead of getTimer to store any start-time vars on the first update call and for performing update calculations. The value is usually no more than a few milliseconds different than getTimer, but using it tightly syncs item groups visually.