| Package | dragonBones.animation |
| Class | public final class WorldClock |
| Inheritance | WorldClock Object |
| Implements | IAnimatable |
See also
| Property | Defined By | ||
|---|---|---|---|
| clock : WorldClock [static]
A global static WorldClock instance ready to use. | WorldClock | ||
| timeScale : Number
The time scale to apply to the number of second passed to the advanceTime() method. | WorldClock | ||
| Method | Defined By | ||
|---|---|---|---|
Creates a new WorldClock instance. | WorldClock | ||
add(animatable:IAnimatable):void
Add a IAnimatable instance (Armature or custom) to this WorldClock instance. | WorldClock | ||
advanceTime(passedTime:Number):void
Update all registered IAnimatable instance animations using this method typically in an ENTERFRAME Event or with a Timer. | WorldClock | ||
clear():void
Remove all IAnimatable instance (Armature or custom) from this WorldClock instance. | WorldClock | ||
contains(animatable:IAnimatable):Boolean
Returns true if the IAnimatable instance is contained by WorldClock instance. | WorldClock | ||
remove(animatable:IAnimatable):void
Remove a IAnimatable instance (Armature or custom) from this WorldClock instance. | WorldClock | ||
| clock | property |
public static var clock:WorldClockA global static WorldClock instance ready to use.
| timeScale | property |
timeScale:NumberThe time scale to apply to the number of second passed to the advanceTime() method.
public function get timeScale():Number public function set timeScale(value:Number):void| WorldClock | () | Constructor |
public function WorldClock()Creates a new WorldClock instance. (use the static var WorldClock.clock instead).
| add | () | method |
public function add(animatable:IAnimatable):voidAdd a IAnimatable instance (Armature or custom) to this WorldClock instance.
Parameters
animatable:IAnimatable — IAnimatable instance (Armature, WorldClock or custom)
|
| advanceTime | () | method |
public function advanceTime(passedTime:Number):voidUpdate all registered IAnimatable instance animations using this method typically in an ENTERFRAME Event or with a Timer.
Parameters
passedTime:Number — amount of second to move the playhead ahead.
|
| clear | () | method |
public function clear():voidRemove all IAnimatable instance (Armature or custom) from this WorldClock instance.
| contains | () | method |
public function contains(animatable:IAnimatable):BooleanReturns true if the IAnimatable instance is contained by WorldClock instance.
Parameters
animatable:IAnimatable — IAnimatable instance (Armature or custom)
|
Boolean — true if the IAnimatable instance is contained by WorldClock instance.
|
| remove | () | method |
public function remove(animatable:IAnimatable):voidRemove a IAnimatable instance (Armature or custom) from this WorldClock instance.
Parameters
animatable:IAnimatable — IAnimatable instance (Armature or custom)
|
Download the example files here:
package
{
import dragonBones.Armature;
import dragonBones.factorys.BaseFactory;
import flash.display.Sprite;
import flash.events.Event;
import dragonBones.animation.WorldClock;
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();
WorldClock.clock.add(armature);
addEventListener(Event.ENTER_FRAME, updateAnimation);
}
private function updateAnimation(e:Event):void
{
WorldClock.clock.advanceTime(1 / stage.frameRate);
}
}
}