PackagedragonBones
Classpublic class Armature
InheritanceArmature Inheritance flash.events.EventDispatcher
Implements IAnimatable

A Armature instance is the core of the skeleton animation system. It contains the object to display, all sub-bones and the object animation(s).

View the examples

See also

dragonBones.Bone
dragonBones.animation.Animation


Public Properties
 PropertyDefined By
  animation : Animation
[read-only] An Animation instance
Armature
  colorTransform : ColorTransform
The ColorTransform instance assiociated with this instance.
Armature
  display : Object
[read-only] Instance type of this object varies from flash.display.DisplayObject to startling.display.DisplayObject and subclasses.
Armature
  name : String
The name of the Armature.
Armature
  userData : Object
An object containing user data.
Armature
Public Methods
 MethodDefined By
  
Armature(display:Object)
Creates a Armature blank instance.
Armature
  
addBone(bone:Bone, parentName:String = null):void
Add a Bone instance to this Armature instance.
Armature
  
advanceTime(passedTime:Number):void
Update the animation using this method typically in an ENTERFRAME Event or with a Timer.
Armature
  
dispose():void
Cleans up resources used by this Armature instance.
Armature
  
getBone(name:String):Bone
Retreives a Bone by name
Armature
  
getBoneByDisplay(display:Object):Bone
Gets the Bone assiociated with this DisplayObject.
Armature
  
getBones():Vector.<Bone>
Get all Bone instance assiociated with this armature.
Armature
  
removeBone(bone:Bone):void
Remove a Bone instance from this Armature instance.
Armature
  
removeBoneByName(boneName:String):void
Remove a Bone instance from this Armature instance.
Armature
  
Update the z-order of the display.
Armature
Events
 Event Summary Defined By
  Dispatched when a bone of the armature enters a frame.Armature
  Dispatched when the playback of a animation stops.Armature
  Dispatched when the playback of a animation completes a loop.Armature
  Dispatched when the movement of animation is changed.Armature
  Dispatched when the animation of the armature enter a frame.Armature
  Dispatched when the playback of a animation starts.Armature
Property Detail
animationproperty
animation:Animation  [read-only]

An Animation instance


Implementation
    public function get animation():Animation

See also

colorTransformproperty 
colorTransform:ColorTransform

The ColorTransform instance assiociated with this instance.


Implementation
    public function get colorTransform():ColorTransform
    public function set colorTransform(value:ColorTransform):void
displayproperty 
display:Object  [read-only]

Instance type of this object varies from flash.display.DisplayObject to startling.display.DisplayObject and subclasses.


Implementation
    public function get display():Object
nameproperty 
public var name:String

The name of the Armature.

userDataproperty 
public var userData:Object

An object containing user data.

Constructor Detail
Armature()Constructor
public function Armature(display:Object)

Creates a Armature blank instance.

Parameters
display:Object — type of this object varies from flash.display.DisplayObject to startling.display.DisplayObject and subclasses.
Method Detail
addBone()method
public function addBone(bone:Bone, parentName:String = null):void

Add a Bone instance to this Armature instance.

Parameters

bone:Bone — Bone instance
 
parentName:String (default = null) — The parent's name of this Bone instance.

See also

advanceTime()method 
public function advanceTime(passedTime:Number):void

Update the animation using this method typically in an ENTERFRAME Event or with a Timer.

Parameters

passedTime:Number — amount of second to move the playhead ahead.

dispose()method 
public function dispose():void

Cleans up resources used by this Armature instance.

getBone()method 
public function getBone(name:String):Bone

Retreives a Bone by name

Parameters

name:String — name of the Bone to retreive.

Returns
Bone — A Bone instance or null if no Bone with that name exist.

See also

getBoneByDisplay()method 
public function getBoneByDisplay(display:Object):Bone

Gets the Bone assiociated with this DisplayObject.

Parameters

display:Object — type of this object varies from flash.display.DisplayObject to startling.display.DisplayObject and subclasses.

Returns
Bone — A bone instance.

See also

getBones()method 
public function getBones():Vector.<Bone>

Get all Bone instance assiociated with this armature.

Returns
Vector.<Bone> — A Vector.<Bone> instance.

See also

removeBone()method 
public function removeBone(bone:Bone):void

Remove a Bone instance from this Armature instance.

Parameters

bone:Bone — Bone instance

See also

removeBoneByName()method 
public function removeBoneByName(boneName:String):void

Remove a Bone instance from this Armature instance.

Parameters

boneName:String — name of the Bone instance to remove.

See also

updateBonesZ()method 
public function updateBonesZ():void

Update the z-order of the display.

Event Detail
boneFrameEvent Event
Event Object Type: dragonBones.events.FrameEvent

Dispatched when a bone of the armature enters a frame.

complete Event  
Event Object Type: dragonBones.events.AnimationEvent

Dispatched when the playback of a animation stops.

loopComplete Event  
Event Object Type: dragonBones.events.AnimationEvent

Dispatched when the playback of a animation completes a loop.

movementChange Event  
Event Object Type: dragonBones.events.AnimationEvent

Dispatched when the movement of animation is changed.

movementFrameEvent Event  
Event Object Type: dragonBones.events.FrameEvent

Dispatched when the animation of the armature enter a frame.

start Event  
Event Object Type: dragonBones.events.AnimationEvent

Dispatched when the playback of a animation starts.

Examples

Download the example files here:

This example builds an Armature instance called "dragon" and stores it into the member varaible called 'armature'.

    
     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);
             }        
         }
     }