PackagedragonBones.factorys
Classpublic class BaseFactory
InheritanceBaseFactory Inheritance flash.events.EventDispatcher
Subclasses StarlingFactory

A BaseFactory instance manages the set of armature resources for the tranditional Flash DisplayList. It parses the raw data (ByteArray), stores the armature resources and creates armature instances.

Create an instance of the BaseFactory class that way:

     import flash.events.Event; 
     import dragonBones.factorys.BaseFactory;
     
     [Embed(source = "../assets/Dragon1.swf", mimeType = "application/octet-stream")]  
     private static const ResourcesData:Class;
     var factory:BaseFactory = new BaseFactory(); 
     factory.addEventListener(Event.COMPLETE, textureCompleteHandler);
     factory.parseData(new ResourcesData());
     

See also

dragonBones.Armature


Public Methods
 MethodDefined By
  
Create a Basefactory instance.
BaseFactory
  
addSkeletonData(skeletonData:SkeletonData, name:String = null):void
Add a SkeletonData instance to this BaseFactory instance.
BaseFactory
  
addTextureAtlas(textureAtlas:Object, name:String = null):void
Add a textureAtlas to this BaseFactory instance.
BaseFactory
  
buildArmature(armatureName:String, animationName:String = null, skeletonName:String = null, textureAtlasName:String = null):Armature
Build and returns a new Armature instance.
BaseFactory
  
dispose(disposeData:Boolean = true):void
Cleans up resources used by this BaseFactory instance.
BaseFactory
  
Returns a SkeletonData instance.
BaseFactory
  
getTextureAtlas(name:String):Object
Return the TextureAtlas by that name.
BaseFactory
  
getTextureDisplay(textureName:String, textureAtlasName:String = null, pivotX:Number, pivotY:Number):Object
Return the TextureDisplay.
BaseFactory
  
parseData(bytes:ByteArray, skeletonName:String = null):SkeletonData
Parses the raw data and returns a SkeletonData instance.
BaseFactory
  
removeSkeletonData(name:String):void
Remove a SkeletonData instance from this BaseFactory instance.
BaseFactory
  
removeTextureAtlas(name:String):void
Remove a textureAtlas from this baseFactory instance.
BaseFactory
Protected Methods
 MethodDefined By
  
generateTextureDisplay(textureAtlas:Object, fullName:String, pivotX:Number, pivotY:Number):Object
BaseFactory
Events
 Event Summary Defined By
  Dispatched after a sucessful call to parseData().BaseFactory
Constructor Detail
BaseFactory()Constructor
public function BaseFactory()

Create a Basefactory instance.


Example
        
         import dragonBones.factorys.BaseFactory;
         var factory:BaseFactory = new BaseFactory(); 
         
Method Detail
addSkeletonData()method
public function addSkeletonData(skeletonData:SkeletonData, name:String = null):void

Add a SkeletonData instance to this BaseFactory instance.

Parameters

skeletonData:SkeletonData — skeletonData instance.
 
name:String (default = null) — A name for this SkeletonData instance.


Example
         factory.addSkeletonData(skeletondata, 'dragon');
         
addTextureAtlas()method 
public function addTextureAtlas(textureAtlas:Object, name:String = null):void

Add a textureAtlas to this BaseFactory instance.

Parameters

textureAtlas:Object — textureAtlas to add to this BaseFactory instance.
 
name:String (default = null) — A name for this TextureAtlas.


Example
         factory.addTextureAtlas(textureatlas, 'dragon');
         
buildArmature()method 
public function buildArmature(armatureName:String, animationName:String = null, skeletonName:String = null, textureAtlasName:String = null):Armature

Build and returns a new Armature instance.

Parameters

armatureName:String — name of this Armature instance.
 
animationName:String (default = null) — name of this animation.
 
skeletonName:String (default = null) — name of this skeleton.
 
textureAtlasName:String (default = null) — name of this textureAtlas.

Returns
Armature — A Armature instance.

Example
         var armature:Armature = factory.buildArmature('dragon');
         
dispose()method 
public function dispose(disposeData:Boolean = true):void

Cleans up resources used by this BaseFactory instance.

Parameters

disposeData:Boolean (default = true) — Destroy all internal references.


Example
         factory.dispose();
         
generateTextureDisplay()method 
protected function generateTextureDisplay(textureAtlas:Object, fullName:String, pivotX:Number, pivotY:Number):Object

Parameters

textureAtlas:Object
 
fullName:String
 
pivotX:Number
 
pivotY:Number

Returns
Object
getSkeletonData()method 
public function getSkeletonData(name:String):SkeletonData

Returns a SkeletonData instance.

Parameters

name:String — name of an existing SkeletonData instance.

Returns
SkeletonData — A SkeletonData instance with given name (if exist).

Example
         var skeleton:SkeletonData = factory.getSkeletonData('dragon');
         
getTextureAtlas()method 
public function getTextureAtlas(name:String):Object

Return the TextureAtlas by that name.

Parameters

name:String — name of the TextureAtlas to return.

Returns
Object — A textureAtlas.

Example
         var atlas:Object = factory.getTextureAtlas('dragon');
         
getTextureDisplay()method 
public function getTextureDisplay(textureName:String, textureAtlasName:String = null, pivotX:Number, pivotY:Number):Object

Return the TextureDisplay.

Parameters

textureName:String — name of this Texture.
 
textureAtlasName:String (default = null) — name of the TextureAtlas.
 
pivotX:Number (default = NaN) — registration pivotX position.
 
pivotY:Number (default = NaN) — registration pivotY position.

Returns
Object — An Object.

Example
         var texturedisplay:Object = factory.getTextureDisplay('dragon');
         
parseData()method 
public function parseData(bytes:ByteArray, skeletonName:String = null):SkeletonData

Parses the raw data and returns a SkeletonData instance.

Parameters

bytes:ByteArray — Represents the raw data for the whole skeleton system.
 
skeletonName:String (default = null) — (optional) The SkeletonData instance name.

Returns
SkeletonData — A SkeletonData instance.

Example
         import flash.events.Event; 
         import dragonBones.factorys.BaseFactory;
         
         [Embed(source = "../assets/Dragon1.swf", mimeType = "application/octet-stream")]  
         private static const ResourcesData:Class;
         var factory:BaseFactory = new BaseFactory(); 
         factory.addEventListener(Event.COMPLETE, textureCompleteHandler);
         factory.parseData(new ResourcesData());
         
removeSkeletonData()method 
public function removeSkeletonData(name:String):void

Remove a SkeletonData instance from this BaseFactory instance.

Parameters

name:String — name for the SkeletonData instance to remove.


Example
         factory.removeSkeletonData('dragon');
         
removeTextureAtlas()method 
public function removeTextureAtlas(name:String):void

Remove a textureAtlas from this baseFactory instance.

Parameters

name:String — name of the TextureAtlas to remove.


Example
         factory.removeTextureAtlas('dragon');
         
Event Detail
complete Event
Event Object Type: flash.events.Event

Dispatched after a sucessful call to parseData().