PackagedragonBones.animation
Classpublic final class Animation
InheritanceAnimation Inheritance Object

An Animation instance is used to control the animation state of an Armature.

View the examples

See also

dragonBones.Bone
dragonBones.Armature


Public Properties
 PropertyDefined By
  animationData : AnimationData
The AnimationData assiociated with this Animation instance.
Animation
  currentTime : Number
[read-only] Get the current playhead time in seconds.
Animation
  isComplete : Boolean
[read-only] Indicates whether the animation has completed or not.
Animation
  isPause : Boolean
[read-only] Indicates whether the animation is paused or not.
Animation
  isPlaying : Boolean
[read-only] Indicates whether the animation is playing or not.
Animation
  movementID : String
[read-only] The name ID of the current MovementData.
Animation
  movementList : Vector.<String>
[read-only] An vector containing all MovementData names the animation can play.
Animation
  timeScale : Number
The amount by which passed time should be scaled.
Animation
  totalTime : Number
[read-only] Get the total elapsed time in second.
Animation
  tweenEnabled : Boolean = true
Whether animation tweening is enabled or not.
Animation
Public Methods
 MethodDefined By
  
Creates a new Animation instance and attaches it to the passed Arnature.
Animation
  
dispose():void
Qualifies all resources used by this Animation instance for garbage collection.
Animation
  
gotoAndPlay(movementID:String, tweenTime:Number = -1, duration:Number = -1, loop:* = null):void
Move the playhead to that MovementData id
Animation
  
play():void
Play the animation from the current position.
Animation
  
stop():void
Stop the playhead.
Animation
Property Detail
animationDataproperty
animationData:AnimationData

The AnimationData assiociated with this Animation instance.


Implementation
    public function get animationData():AnimationData
    public function set animationData(value:AnimationData):void

See also

dragonBones.objects.AnimationData.
currentTimeproperty 
currentTime:Number  [read-only]

Get the current playhead time in seconds.


Implementation
    public function get currentTime():Number
isCompleteproperty 
isComplete:Boolean  [read-only]

Indicates whether the animation has completed or not.


Implementation
    public function get isComplete():Boolean
isPauseproperty 
isPause:Boolean  [read-only]

Indicates whether the animation is paused or not.


Implementation
    public function get isPause():Boolean
isPlayingproperty 
isPlaying:Boolean  [read-only]

Indicates whether the animation is playing or not.


Implementation
    public function get isPlaying():Boolean
movementIDproperty 
movementID:String  [read-only]

The name ID of the current MovementData.


Implementation
    public function get movementID():String

See also

dragonBones.objects.MovementData.
movementListproperty 
movementList:Vector.<String>  [read-only]

An vector containing all MovementData names the animation can play.


Implementation
    public function get movementList():Vector.<String>

See also

dragonBones.objects.MovementData.
timeScaleproperty 
timeScale:Number

The amount by which passed time should be scaled. Used to slow down or speed up animations. Defaults to 1.


Implementation
    public function get timeScale():Number
    public function set timeScale(value:Number):void
totalTimeproperty 
totalTime:Number  [read-only]

Get the total elapsed time in second.


Implementation
    public function get totalTime():Number
tweenEnabledproperty 
public var tweenEnabled:Boolean = true

Whether animation tweening is enabled or not.

Constructor Detail
Animation()Constructor
public function Animation(armature:Armature)

Creates a new Animation instance and attaches it to the passed Arnature.

Parameters
armature:Armature — Armature to attach this Animation instance to.
Method Detail
dispose()method
public function dispose():void

Qualifies all resources used by this Animation instance for garbage collection.

gotoAndPlay()method 
public function gotoAndPlay(movementID:String, tweenTime:Number = -1, duration:Number = -1, loop:* = null):void

Move the playhead to that MovementData id

Parameters

movementID:String — id of the MovementData to play.
 
tweenTime:Number (default = -1) — tween time to apply (> 0)
 
duration:Number (default = -1) — duration in seconds of that MovementData.
 
loop:* (default = null) — that MovementData should loop or play only once (true/false).

See also

dragonBones.objects.MovementData.
play()method 
public function play():void

Play the animation from the current position.

stop()method 
public function stop():void

Stop the playhead.

Examples

Download the example files here:

    
     package  
     {
         import dragonBones.Armature;
         import dragonBones.factorys.BaseFactory;
          import flash.display.Sprite;
         import flash.events.Event;    
     
         public class DragonAnimation extends Sprite 
         {        
             [Embed(source = "Dragon1.swf", mimeType = "application/octet-stream")]  
             private static const ResourcesData:Class;
             
             private var factory:BaseFactory;
             private var armature:Armature;        
             
             public function DragonAnimation() 
             {                
                 factory = new BaseFactory();
                 factory.addEventListener(Event.COMPLETE, handleParseData);
                 factory.parseData(new ResourcesData(), 'Dragon');
             }
             
             private function handleParseData(e:Event):void 
             {            
                 armature = factory.buildArmature('Dragon');
                 addChild(armature.display as Sprite);             
                 armature.animation.play();
                 addEventListener(Event.ENTER_FRAME, updateAnimation);            
             }
             
             private function updateAnimation(e:Event):void 
             {
                 armature.advanceTime(1 / stage.frameRate);
             }        
         }
     }