Hilo/build/dragonbones/dragonbones.js
2022-06-29 10:45:02 +08:00

8288 lines
358 KiB
JavaScript

/**
* hilojs 2.0.3 for dragonbones
* Copyright 2016 alibaba.com
* Licensed under the MIT License
*/
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-2015, Egret Technology Inc.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
/**
* Hilo
* Copyright 2015 alibaba.com
* Licensed under the MIT License
*/
if (!window.egret) {
var egret_strings = {
4001: "Abstract class can not be instantiated!",
4002: "Unnamed data!",
4003: "Nonsupport version!"
};
var Event = function(type, bubbles, cancelable, data) {
this.type = type;
this.bubbles = bubbles || false;
this.cancelable = cancelable || false;
this.data = data;
};
var EventDispatcher = function(target) {
this._listenerDict = {};
};
EventDispatcher.prototype = {
constructor: EventDispatcher,
addEventListener: function(type, listener, thisObject, useCapture, priority, dispatchOnce) {
if (!this._listenerDict[type]) {
this._listenerDict[type] = [];
}
this._listenerDict[type].push({
listener: listener,
thisObject: thisObject,
useCapture: useCapture,
priority: priority,
dispatchOnce: dispatchOnce
});
},
once: function(type, listener, thisObject, useCapture, priority) {
this.addEventListener(type, listener, thisObject, useCapture, priority, true);
},
removeEventListener: function(type, listener, thisObject, useCapture) {
if (!type) {
this._listenerDict = {};
} else if (!listener) {
if (this._listenerDict[type]) {
this._listenerDict[type].length = 0;
}
} else {
var listeners = this._listenerDict[type];
var index = listeners.indexOf(listener);
if (index > -1) {
listeners.splice(index, 1);
}
}
},
hasEventListener: function(type) {
return this._listenerDict[type];
},
dispatchEvent: function(event) {
if (event && event.type && this._listenerDict[event.type]) {
var listeners = this._listenerDict[event.type];
var copyListeners = listeners.slice();
for (var i = 0; i < copyListeners.length; i++) {
var listenerObj = copyListeners[i];
if (listenerObj.dispatchOnce) {
var index = listeners.indexOf(listenerObj);
if (index > -1) {
listeners.splice(index, 1);
}
}
if (listenerObj.listener) {
listenerObj.listener.call(listenerObj.thisObject || this, event);
}
}
}
},
willTrigger: function(type) {
return this.hasEventListener(type);
}
};
window.egret = {
getString: function(code) {
return egret_strings[code] || 'no string code';
},
Event: Event,
EventDispatcher: EventDispatcher,
registerClass: function(classDefinition, className, interfaceNames) {
var prototype = classDefinition.prototype;
prototype.__class__ = className;
var types = [className];
if (interfaceNames) {
types = types.concat(interfaceNames);
}
var superTypes = prototype.__types__;
if (prototype.__types__) {
var length = superTypes.length;
for (var i = 0; i < length; i++) {
var name = superTypes[i];
if (types.indexOf(name) == -1) {
types.push(name);
}
}
}
prototype.__types__ = types;
}
};
}
window.__extends = window.__extends || function __extends(d, b, mixin) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() {
this.constructor = d;
}
__.prototype = b.prototype;
d.prototype = new __();
if(mixin){
for(var key in mixin){
d.prototype[key] = mixin[key];
}
}
};
window.__define = window.__define || function(o, p, g, s) {
Object.defineProperty(o, p, {
configurable: true,
enumerable: true,
get: g,
set: s
});
};
var dragonBones;
(function (dragonBones) {
var DragonBones = (function () {
function DragonBones() {
}
var d = __define,c=DragonBones,p=c.prototype;
DragonBones.DATA_VERSION = "4.0";
DragonBones.PARENT_COORDINATE_DATA_VERSION = "3.0";
DragonBones.VERSION = "4.3.5";
return DragonBones;
})();
dragonBones.DragonBones = DragonBones;
egret.registerClass(DragonBones,'dragonBones.DragonBones');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Animation = (function () {
function Animation(armature) {
this._animationStateCount = 0;
this._armature = armature;
this._animationList = [];
this._animationStateList = [];
this._timeScale = 1;
this._isPlaying = false;
this.tweenEnabled = true;
}
var d = __define,c=Animation,p=c.prototype;
p.dispose = function () {
if (!this._armature) {
return;
}
this._resetAnimationStateList();
this._animationList.length = 0;
this._armature = null;
this._animationDataList = null;
this._animationList = null;
this._animationStateList = null;
};
p._resetAnimationStateList = function () {
var i = this._animationStateList.length;
var animationState;
while (i--) {
animationState = this._animationStateList[i];
animationState._resetTimelineStateList();
dragonBones.AnimationState._returnObject(animationState);
}
this._animationStateList.length = 0;
};
p.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) {
if (fadeInTime === void 0) { fadeInTime = -1; }
if (duration === void 0) { duration = -1; }
if (playTimes === void 0) { playTimes = NaN; }
if (layer === void 0) { layer = 0; }
if (group === void 0) { group = null; }
if (fadeOutMode === void 0) { fadeOutMode = Animation.SAME_LAYER_AND_GROUP; }
if (pauseFadeOut === void 0) { pauseFadeOut = true; }
if (pauseFadeIn === void 0) { pauseFadeIn = true; }
if (!this._animationDataList) {
return null;
}
var i = this._animationDataList.length;
var animationData;
while (i--) {
if (this._animationDataList[i].name == animationName) {
animationData = this._animationDataList[i];
break;
}
}
if (!animationData) {
return null;
}
var needUpdate = this._isPlaying == false;
this._isPlaying = true;
this._isFading = true;
fadeInTime = fadeInTime < 0 ? (animationData.fadeTime < 0 ? 0.3 : animationData.fadeTime) : fadeInTime;
var durationScale;
if (duration < 0) {
durationScale = animationData.scale < 0 ? 1 : animationData.scale;
}
else {
durationScale = duration * 1000 / animationData.duration;
}
playTimes = isNaN(playTimes) ? animationData.playTimes : playTimes;
var animationState;
switch (fadeOutMode) {
case Animation.NONE:
break;
case Animation.SAME_LAYER:
i = this._animationStateList.length;
while (i--) {
animationState = this._animationStateList[i];
if (animationState.layer == layer) {
animationState.fadeOut(fadeInTime, pauseFadeOut);
}
}
break;
case Animation.SAME_GROUP:
i = this._animationStateList.length;
while (i--) {
animationState = this._animationStateList[i];
if (animationState.group == group) {
animationState.fadeOut(fadeInTime, pauseFadeOut);
}
}
break;
case Animation.ALL:
i = this._animationStateList.length;
while (i--) {
animationState = this._animationStateList[i];
animationState.fadeOut(fadeInTime, pauseFadeOut);
}
break;
case Animation.SAME_LAYER_AND_GROUP:
default:
i = this._animationStateList.length;
while (i--) {
animationState = this._animationStateList[i];
if (animationState.layer == layer && animationState.group == group) {
animationState.fadeOut(fadeInTime, pauseFadeOut);
}
}
break;
}
this._lastAnimationState = dragonBones.AnimationState._borrowObject();
this._lastAnimationState._layer = layer;
this._lastAnimationState._group = group;
this._lastAnimationState.autoTween = this.tweenEnabled;
this._lastAnimationState._fadeIn(this._armature, animationData, fadeInTime, 1 / durationScale, playTimes, pauseFadeIn);
this.addState(this._lastAnimationState);
var slotList = this._armature.getSlots(false);
i = slotList.length;
while (i--) {
var slot = slotList[i];
if (slot.childArmature) {
slot.childArmature.animation.gotoAndPlay(animationName, fadeInTime);
}
}
if (needUpdate) {
this._armature.advanceTime(0);
}
return this._lastAnimationState;
};
p.gotoAndStop = function (animationName, time, normalizedTime, fadeInTime, duration, layer, group, fadeOutMode) {
if (normalizedTime === void 0) { normalizedTime = -1; }
if (fadeInTime === void 0) { fadeInTime = 0; }
if (duration === void 0) { duration = -1; }
if (layer === void 0) { layer = 0; }
if (group === void 0) { group = null; }
if (fadeOutMode === void 0) { fadeOutMode = Animation.ALL; }
var animationState = this.getState(animationName, layer);
if (!animationState) {
animationState = this.gotoAndPlay(animationName, fadeInTime, duration, NaN, layer, group, fadeOutMode);
}
if (normalizedTime >= 0) {
animationState.setCurrentTime(animationState.totalTime * normalizedTime);
}
else {
animationState.setCurrentTime(time);
}
animationState.stop();
return animationState;
};
p.play = function () {
if (!this._animationDataList || this._animationDataList.length == 0) {
return;
}
if (!this._lastAnimationState) {
this.gotoAndPlay(this._animationDataList[0].name);
}
else if (!this._isPlaying) {
this._isPlaying = true;
}
else {
this.gotoAndPlay(this._lastAnimationState.name);
}
};
p.stop = function () {
this._isPlaying = false;
};
p.getState = function (name, layer) {
if (layer === void 0) { layer = 0; }
var i = this._animationStateList.length;
while (i--) {
var animationState = this._animationStateList[i];
if (animationState.name == name && animationState.layer == layer) {
return animationState;
}
}
return null;
};
p.hasAnimation = function (animationName) {
var i = this._animationDataList.length;
while (i--) {
if (this._animationDataList[i].name == animationName) {
return true;
}
}
return false;
};
p._advanceTime = function (passedTime) {
if (!this._isPlaying) {
return;
}
var isFading = false;
passedTime *= this._timeScale;
var i = this._animationStateList.length;
while (i--) {
var animationState = this._animationStateList[i];
if (animationState._advanceTime(passedTime)) {
this.removeState(animationState);
}
else if (animationState.fadeState != 1) {
isFading = true;
}
}
this._isFading = isFading;
};
p._updateAnimationStates = function () {
var i = this._animationStateList.length;
while (i--) {
this._animationStateList[i]._updateTimelineStates();
}
};
p.addState = function (animationState) {
if (this._animationStateList.indexOf(animationState) < 0) {
this._animationStateList.unshift(animationState);
this._animationStateCount = this._animationStateList.length;
}
};
p.removeState = function (animationState) {
var index = this._animationStateList.indexOf(animationState);
if (index >= 0) {
this._animationStateList.splice(index, 1);
dragonBones.AnimationState._returnObject(animationState);
if (this._lastAnimationState == animationState) {
if (this._animationStateList.length > 0) {
this._lastAnimationState = this._animationStateList[0];
}
else {
this._lastAnimationState = null;
}
}
this._animationStateCount = this._animationStateList.length;
}
};
d(p, "movementList"
,function () {
return this._animationList;
}
);
d(p, "movementID"
,function () {
return this.lastAnimationName;
}
);
d(p, "lastAnimationState"
,function () {
return this._lastAnimationState;
}
);
d(p, "lastAnimationName"
,function () {
return this._lastAnimationState ? this._lastAnimationState.name : null;
}
);
d(p, "animationList"
,function () {
return this._animationList;
}
);
d(p, "isPlaying"
,function () {
return this._isPlaying && !this.isComplete;
}
);
d(p, "isComplete"
,function () {
if (this._lastAnimationState) {
if (!this._lastAnimationState.isComplete) {
return false;
}
var i = this._animationStateList.length;
while (i--) {
if (!this._animationStateList[i].isComplete) {
return false;
}
}
return true;
}
return true;
}
);
d(p, "timeScale"
,function () {
return this._timeScale;
}
,function (value) {
if (isNaN(value) || value < 0) {
value = 1;
}
this._timeScale = value;
}
);
d(p, "animationDataList"
,function () {
return this._animationDataList;
}
,function (value) {
this._animationDataList = value;
this._animationList.length = 0;
for (var i = 0, len = this._animationDataList.length; i < len; i++) {
var animationData = this._animationDataList[i];
this._animationList[this._animationList.length] = animationData.name;
}
}
);
Animation.NONE = "none";
Animation.SAME_LAYER = "sameLayer";
Animation.SAME_GROUP = "sameGroup";
Animation.SAME_LAYER_AND_GROUP = "sameLayerAndGroup";
Animation.ALL = "all";
return Animation;
})();
dragonBones.Animation = Animation;
egret.registerClass(Animation,'dragonBones.Animation');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var AnimationState = (function () {
function AnimationState() {
this._layer = 0;
this._currentFrameIndex = 0;
this._currentFramePosition = 0;
this._currentFrameDuration = 0;
this._currentPlayTimes = 0;
this._totalTime = 0;
this._currentTime = 0;
this._lastTime = 0;
this._fadeState = 0;
this._playTimes = 0;
this._timelineStateList = [];
this._slotTimelineStateList = [];
this._boneMasks = [];
}
var d = __define,c=AnimationState,p=c.prototype;
AnimationState._borrowObject = function () {
if (AnimationState._pool.length == 0) {
return new AnimationState();
}
return AnimationState._pool.pop();
};
AnimationState._returnObject = function (animationState) {
animationState.clear();
if (AnimationState._pool.indexOf(animationState) < 0) {
AnimationState._pool[AnimationState._pool.length] = animationState;
}
};
AnimationState._clear = function () {
var i = AnimationState._pool.length;
while (i--) {
AnimationState._pool[i].clear();
}
AnimationState._pool.length = 0;
dragonBones.TimelineState._clear();
};
p.clear = function () {
this._resetTimelineStateList();
this._boneMasks.length = 0;
this._armature = null;
this._clip = null;
};
p._resetTimelineStateList = function () {
var i = this._timelineStateList.length;
while (i--) {
dragonBones.TimelineState._returnObject(this._timelineStateList[i]);
}
this._timelineStateList.length = 0;
i = this._slotTimelineStateList.length;
while (i--) {
dragonBones.SlotTimelineState._returnObject(this._slotTimelineStateList[i]);
}
this._slotTimelineStateList.length = 0;
};
p.containsBoneMask = function (boneName) {
return this._boneMasks.length == 0 || this._boneMasks.indexOf(boneName) >= 0;
};
p.addBoneMask = function (boneName, ifInvolveChildBones) {
if (ifInvolveChildBones === void 0) { ifInvolveChildBones = true; }
this.addBoneToBoneMask(boneName);
if (ifInvolveChildBones) {
var currentBone = this._armature.getBone(boneName);
if (currentBone) {
var boneList = this._armature.getBones(false);
var i = boneList.length;
while (i--) {
var tempBone = boneList[i];
if (currentBone.contains(tempBone)) {
this.addBoneToBoneMask(tempBone.name);
}
}
}
}
this._updateTimelineStates();
return this;
};
p.removeBoneMask = function (boneName, ifInvolveChildBones) {
if (ifInvolveChildBones === void 0) { ifInvolveChildBones = true; }
this.removeBoneFromBoneMask(boneName);
if (ifInvolveChildBones) {
var currentBone = this._armature.getBone(boneName);
if (currentBone) {
var boneList = this._armature.getBones(false);
var i = boneList.length;
while (i--) {
var tempBone = boneList[i];
if (currentBone.contains(tempBone)) {
this.removeBoneFromBoneMask(tempBone.name);
}
}
}
}
this._updateTimelineStates();
return this;
};
p.removeAllMixingTransform = function () {
this._boneMasks.length = 0;
this._updateTimelineStates();
return this;
};
p.addBoneToBoneMask = function (boneName) {
if (this._clip.getTimeline(boneName) && this._boneMasks.indexOf(boneName) < 0) {
this._boneMasks.push(boneName);
}
};
p.removeBoneFromBoneMask = function (boneName) {
var index = this._boneMasks.indexOf(boneName);
if (index >= 0) {
this._boneMasks.splice(index, 1);
}
};
p._updateTimelineStates = function () {
var timelineState;
var slotTimelineState;
var i = this._timelineStateList.length;
var len;
while (i--) {
timelineState = this._timelineStateList[i];
if (!this._armature.getBone(timelineState.name)) {
this.removeTimelineState(timelineState);
}
}
i = this._slotTimelineStateList.length;
while (i--) {
slotTimelineState = this._slotTimelineStateList[i];
if (!this._armature.getSlot(slotTimelineState.name)) {
this.removeSlotTimelineState(slotTimelineState);
}
}
if (this._boneMasks.length > 0) {
i = this._timelineStateList.length;
while (i--) {
timelineState = this._timelineStateList[i];
if (this._boneMasks.indexOf(timelineState.name) < 0) {
this.removeTimelineState(timelineState);
}
}
for (i = 0, len = this._boneMasks.length; i < len; i++) {
var timelineName = this._boneMasks[i];
this.addTimelineState(timelineName);
}
}
else {
for (i = 0, len = this._clip.timelineList.length; i < len; i++) {
var timeline = this._clip.timelineList[i];
this.addTimelineState(timeline.name);
}
}
for (i = 0, len = this._clip.slotTimelineList.length; i < len; i++) {
var slotTimeline = this._clip.slotTimelineList[i];
this.addSlotTimelineState(slotTimeline.name);
}
};
p.addTimelineState = function (timelineName) {
var bone = this._armature.getBone(timelineName);
if (bone) {
for (var i = 0, len = this._timelineStateList.length; i < len; i++) {
var eachState = this._timelineStateList[i];
if (eachState.name == timelineName) {
return;
}
}
var timelineState = dragonBones.TimelineState._borrowObject();
timelineState._fadeIn(bone, this, this._clip.getTimeline(timelineName));
this._timelineStateList.push(timelineState);
}
};
p.removeTimelineState = function (timelineState) {
var index = this._timelineStateList.indexOf(timelineState);
this._timelineStateList.splice(index, 1);
dragonBones.TimelineState._returnObject(timelineState);
};
p.addSlotTimelineState = function (timelineName) {
var slot = this._armature.getSlot(timelineName);
if (slot) {
for (var i = 0, len = this._slotTimelineStateList.length; i < len; i++) {
var eachState = this._slotTimelineStateList[i];
if (eachState.name == timelineName) {
return;
}
}
var timelineState = dragonBones.SlotTimelineState._borrowObject();
timelineState._fadeIn(slot, this, this._clip.getSlotTimeline(timelineName));
this._slotTimelineStateList.push(timelineState);
}
};
p.removeSlotTimelineState = function (timelineState) {
var index = this._slotTimelineStateList.indexOf(timelineState);
this._slotTimelineStateList.splice(index, 1);
dragonBones.SlotTimelineState._returnObject(timelineState);
};
p.play = function () {
this._isPlaying = true;
return this;
};
p.stop = function () {
this._isPlaying = false;
return this;
};
p._fadeIn = function (armature, clip, fadeTotalTime, timeScale, playTimes, pausePlayhead) {
this._armature = armature;
this._clip = clip;
this._pausePlayheadInFade = pausePlayhead;
this._name = this._clip.name;
this._totalTime = this._clip.duration;
this.autoTween = this._clip.autoTween;
this.setTimeScale(timeScale);
this.setPlayTimes(playTimes);
this._isComplete = false;
this._currentFrameIndex = -1;
this._currentPlayTimes = -1;
if (Math.round(this._totalTime * this._clip.frameRate * 0.001) < 2 || timeScale == Infinity) {
this._currentTime = this._totalTime;
}
else {
this._currentTime = -1;
}
this._time = 0;
this._boneMasks.length = 0;
this._isFadeOut = false;
this._fadeWeight = 0;
this._fadeTotalWeight = 1;
this._fadeState = -1;
this._fadeCurrentTime = 0;
this._fadeBeginTime = this._fadeCurrentTime;
this._fadeTotalTime = fadeTotalTime * this._timeScale;
this._isPlaying = true;
this.displayControl = true;
this.lastFrameAutoTween = true;
this.additiveBlending = false;
this.weight = 1;
this.fadeOutTime = fadeTotalTime;
this._updateTimelineStates();
return this;
};
p.fadeOut = function (fadeTotalTime, pausePlayhead) {
if (!this._armature) {
return null;
}
if (isNaN(fadeTotalTime) || fadeTotalTime < 0) {
fadeTotalTime = 0;
}
this._pausePlayheadInFade = pausePlayhead;
if (this._isFadeOut) {
if (fadeTotalTime > this._fadeTotalTime / this._timeScale - (this._fadeCurrentTime - this._fadeBeginTime)) {
return this;
}
}
else {
for (var i = 0, len = this._timelineStateList.length; i < len; i++) {
var timelineState = this._timelineStateList[i];
timelineState._fadeOut();
}
}
this._isFadeOut = true;
this._fadeTotalWeight = this._fadeWeight;
this._fadeState = -1;
this._fadeBeginTime = this._fadeCurrentTime;
this._fadeTotalTime = this._fadeTotalWeight >= 0 ? fadeTotalTime * this._timeScale : 0;
this.displayControl = false;
return this;
};
p._advanceTime = function (passedTime) {
passedTime *= this._timeScale;
this.advanceFadeTime(passedTime);
if (this._fadeWeight) {
this.advanceTimelinesTime(passedTime);
}
return this._isFadeOut && this._fadeState == 1;
};
p.advanceFadeTime = function (passedTime) {
var fadeStartFlg = false;
var fadeCompleteFlg = false;
if (this._fadeBeginTime >= 0) {
var fadeState = this._fadeState;
this._fadeCurrentTime += passedTime < 0 ? -passedTime : passedTime;
if (this._fadeCurrentTime >= this._fadeBeginTime + this._fadeTotalTime) {
if (this._fadeWeight == 1 ||
this._fadeWeight == 0) {
fadeState = 1;
if (this._pausePlayheadInFade) {
this._pausePlayheadInFade = false;
this._currentTime = -1;
}
}
this._fadeWeight = this._isFadeOut ? 0 : 1;
}
else if (this._fadeCurrentTime >= this._fadeBeginTime) {
fadeState = 0;
this._fadeWeight = (this._fadeCurrentTime - this._fadeBeginTime) / this._fadeTotalTime * this._fadeTotalWeight;
if (this._isFadeOut) {
this._fadeWeight = this._fadeTotalWeight - this._fadeWeight;
}
}
else {
fadeState = -1;
this._fadeWeight = this._isFadeOut ? 1 : 0;
}
if (this._fadeState != fadeState) {
if (this._fadeState == -1) {
fadeStartFlg = true;
}
if (fadeState == 1) {
fadeCompleteFlg = true;
}
this._fadeState = fadeState;
}
}
var event;
if (fadeStartFlg) {
if (this._isFadeOut) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.FADE_OUT)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.FADE_OUT);
event.animationState = this;
this._armature._eventList.push(event);
}
}
else {
this.hideBones();
if (this._armature.hasEventListener(dragonBones.AnimationEvent.FADE_IN)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.FADE_IN);
event.animationState = this;
this._armature._eventList.push(event);
}
}
}
if (fadeCompleteFlg) {
if (this._isFadeOut) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.FADE_OUT_COMPLETE)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.FADE_OUT_COMPLETE);
event.animationState = this;
this._armature._eventList.push(event);
}
}
else {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.FADE_IN_COMPLETE)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.FADE_IN_COMPLETE);
event.animationState = this;
this._armature._eventList.push(event);
}
}
}
};
p.advanceTimelinesTime = function (passedTime) {
if (this._isPlaying && !this._pausePlayheadInFade) {
this._time += passedTime;
}
var startFlg = false;
var completeFlg = false;
var loopCompleteFlg = false;
var isThisComplete = false;
var currentPlayTimes = 0;
var currentTime = this._time * 1000;
if (this._playTimes == 0) {
isThisComplete = false;
currentPlayTimes = Math.ceil(Math.abs(currentTime) / this._totalTime) || 1;
if (currentTime >= 0) {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
else {
currentTime -= Math.ceil(currentTime / this._totalTime) * this._totalTime;
}
if (currentTime < 0) {
currentTime += this._totalTime;
}
}
else {
var totalTimes = this._playTimes * this._totalTime;
if (currentTime >= totalTimes) {
currentTime = totalTimes;
isThisComplete = true;
}
else if (currentTime <= -totalTimes) {
currentTime = -totalTimes;
isThisComplete = true;
}
else {
isThisComplete = false;
}
if (currentTime < 0) {
currentTime += totalTimes;
}
currentPlayTimes = Math.ceil(currentTime / this._totalTime) || 1;
if (currentTime >= 0) {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
else {
currentTime -= Math.ceil(currentTime / this._totalTime) * this._totalTime;
}
if (isThisComplete) {
currentTime = this._totalTime;
}
}
this._isComplete = isThisComplete;
var progress = this._time * 1000 / this._totalTime;
var i = 0;
var len = 0;
for (i = 0, len = this._timelineStateList.length; i < len; i++) {
var timeline = this._timelineStateList[i];
timeline._update(progress);
this._isComplete = timeline._isComplete && this._isComplete;
}
for (i = 0, len = this._slotTimelineStateList.length; i < len; i++) {
var slotTimeline = this._slotTimelineStateList[i];
slotTimeline._update(progress);
this._isComplete = timeline._isComplete && this._isComplete;
}
if (this._currentTime != currentTime) {
if (this._currentPlayTimes != currentPlayTimes) {
if (this._currentPlayTimes > 0 && currentPlayTimes > 1) {
loopCompleteFlg = true;
}
this._currentPlayTimes = currentPlayTimes;
}
if (this._currentTime < 0) {
startFlg = true;
}
if (this._isComplete) {
completeFlg = true;
}
this._lastTime = this._currentTime;
this._currentTime = currentTime;
this.updateMainTimeline(isThisComplete);
}
var event;
if (startFlg) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.START)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.START);
event.animationState = this;
this._armature._eventList.push(event);
}
}
if (completeFlg) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.COMPLETE)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.COMPLETE);
event.animationState = this;
this._armature._eventList.push(event);
}
if (this.autoFadeOut) {
this.fadeOut(this.fadeOutTime, true);
}
}
else if (loopCompleteFlg) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.LOOP_COMPLETE)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.LOOP_COMPLETE);
event.animationState = this;
this._armature._eventList.push(event);
}
}
};
p.updateMainTimeline = function (isThisComplete) {
var frameList = this._clip.frameList;
if (frameList.length > 0) {
var prevFrame;
var currentFrame;
for (var i = 0, l = this._clip.frameList.length; i < l; ++i) {
if (this._currentFrameIndex < 0) {
this._currentFrameIndex = 0;
}
else if (this._currentTime < this._currentFramePosition || this._currentTime >= this._currentFramePosition + this._currentFrameDuration || this._currentTime < this._lastTime) {
this._currentFrameIndex++;
this._lastTime = this._currentTime;
if (this._currentFrameIndex >= frameList.length) {
if (isThisComplete) {
this._currentFrameIndex--;
break;
}
else {
this._currentFrameIndex = 0;
}
}
}
else {
break;
}
currentFrame = frameList[this._currentFrameIndex];
if (prevFrame) {
this._armature._arriveAtFrame(prevFrame, null, this, true);
}
this._currentFrameDuration = currentFrame.duration;
this._currentFramePosition = currentFrame.position;
prevFrame = currentFrame;
}
if (currentFrame) {
this._armature._arriveAtFrame(currentFrame, null, this, false);
}
}
};
p.hideBones = function () {
for (var i = 0, len = this._clip.hideTimelineNameMap.length; i < len; i++) {
var timelineName = this._clip.hideTimelineNameMap[i];
var bone = this._armature.getBone(timelineName);
if (bone) {
bone._hideSlots();
}
}
var slotTimelineName;
for (i = 0, len = this._clip.hideSlotTimelineNameMap.length; i < len; i++) {
slotTimelineName = this._clip.hideSlotTimelineNameMap[i];
var slot = this._armature.getSlot(slotTimelineName);
if (slot) {
slot._resetToOrigin();
}
}
};
p.setAdditiveBlending = function (value) {
this.additiveBlending = value;
return this;
};
p.setAutoFadeOut = function (value, fadeOutTime) {
if (fadeOutTime === void 0) { fadeOutTime = -1; }
this.autoFadeOut = value;
if (fadeOutTime >= 0) {
this.fadeOutTime = fadeOutTime * this._timeScale;
}
return this;
};
p.setWeight = function (value) {
if (isNaN(value) || value < 0) {
value = 1;
}
this.weight = value;
return this;
};
p.setFrameTween = function (autoTween, lastFrameAutoTween) {
this.autoTween = autoTween;
this.lastFrameAutoTween = lastFrameAutoTween;
return this;
};
p.setCurrentTime = function (value) {
if (value < 0 || isNaN(value)) {
value = 0;
}
this._time = value;
this._currentTime = this._time * 1000;
return this;
};
p.setTimeScale = function (value) {
if (isNaN(value) || value == Infinity) {
value = 1;
}
this._timeScale = value;
return this;
};
p.setPlayTimes = function (value) {
if (value === void 0) { value = 0; }
if (Math.round(this._totalTime * 0.001 * this._clip.frameRate) < 2) {
this._playTimes = value < 0 ? -1 : 1;
}
else {
this._playTimes = value < 0 ? -value : value;
}
this.autoFadeOut = value < 0 ? true : false;
return this;
};
d(p, "name"
,function () {
return this._name;
}
);
d(p, "layer"
,function () {
return this._layer;
}
);
d(p, "group"
,function () {
return this._group;
}
);
d(p, "clip"
,function () {
return this._clip;
}
);
d(p, "isComplete"
,function () {
return this._isComplete;
}
);
d(p, "isPlaying"
,function () {
return (this._isPlaying && !this._isComplete);
}
);
d(p, "currentPlayTimes"
,function () {
return this._currentPlayTimes < 0 ? 0 : this._currentPlayTimes;
}
);
d(p, "totalTime"
,function () {
return this._totalTime * 0.001;
}
);
d(p, "currentTime"
,function () {
return this._currentTime < 0 ? 0 : this._currentTime * 0.001;
}
);
d(p, "fadeWeight"
,function () {
return this._fadeWeight;
}
);
d(p, "fadeState"
,function () {
return this._fadeState;
}
);
d(p, "fadeTotalTime"
,function () {
return this._fadeTotalTime;
}
);
d(p, "timeScale"
,function () {
return this._timeScale;
}
);
d(p, "playTimes"
,function () {
return this._playTimes;
}
);
AnimationState._pool = [];
return AnimationState;
})();
dragonBones.AnimationState = AnimationState;
egret.registerClass(AnimationState,'dragonBones.AnimationState');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SlotTimelineState = (function () {
function SlotTimelineState() {
this._totalTime = 0;
this._currentTime = 0;
this._currentFrameIndex = 0;
this._currentFramePosition = 0;
this._currentFrameDuration = 0;
this._updateMode = 0;
this._durationColor = new dragonBones.ColorTransform();
}
var d = __define,c=SlotTimelineState,p=c.prototype;
SlotTimelineState._borrowObject = function () {
if (SlotTimelineState._pool.length == 0) {
return new SlotTimelineState();
}
return SlotTimelineState._pool.pop();
};
SlotTimelineState._returnObject = function (timeline) {
if (SlotTimelineState._pool.indexOf(timeline) < 0) {
SlotTimelineState._pool[SlotTimelineState._pool.length] = timeline;
}
timeline.clear();
};
SlotTimelineState._clear = function () {
var i = SlotTimelineState._pool.length;
while (i--) {
SlotTimelineState._pool[i].clear();
}
SlotTimelineState._pool.length = 0;
};
p.clear = function () {
if (this._slot) {
this._slot._removeState(this);
this._slot = null;
}
this._armature = null;
this._animation = null;
this._animationState = null;
this._timelineData = null;
};
p._fadeIn = function (slot, animationState, timelineData) {
this._slot = slot;
this._armature = this._slot.armature;
this._animation = this._armature.animation;
this._animationState = animationState;
this._timelineData = timelineData;
this.name = timelineData.name;
this._totalTime = this._timelineData.duration;
this._rawAnimationScale = this._animationState.clip.scale;
this._isComplete = false;
this._blendEnabled = false;
this._tweenColor = false;
this._currentFrameIndex = -1;
this._currentTime = -1;
this._tweenEasing = NaN;
this._weight = 1;
switch (this._timelineData.frameList.length) {
case 0:
this._updateMode = 0;
break;
case 1:
this._updateMode = 1;
break;
default:
this._updateMode = -1;
break;
}
this._slot._addState(this);
};
p._fadeOut = function () {
};
p._update = function (progress) {
if (this._updateMode == -1) {
this.updateMultipleFrame(progress);
}
else if (this._updateMode == 1) {
this._updateMode = 0;
this.updateSingleFrame();
}
};
p.updateMultipleFrame = function (progress) {
var currentPlayTimes = 0;
progress /= this._timelineData.scale;
progress += this._timelineData.offset;
var currentTime = this._totalTime * progress;
var playTimes = this._animationState.playTimes;
if (playTimes == 0) {
this._isComplete = false;
currentPlayTimes = Math.ceil(Math.abs(currentTime) / this._totalTime) || 1;
if (currentTime >= 0) {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
else {
currentTime -= Math.ceil(currentTime / this._totalTime) * this._totalTime;
}
if (currentTime < 0) {
currentTime += this._totalTime;
}
}
else {
var totalTimes = playTimes * this._totalTime;
if (currentTime >= totalTimes) {
currentTime = totalTimes;
this._isComplete = true;
}
else if (currentTime <= -totalTimes) {
currentTime = -totalTimes;
this._isComplete = true;
}
else {
this._isComplete = false;
}
if (currentTime < 0) {
currentTime += totalTimes;
}
currentPlayTimes = Math.ceil(currentTime / this._totalTime) || 1;
if (this._isComplete) {
currentTime = this._totalTime;
}
else {
if (currentTime >= 0) {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
else {
currentTime -= Math.ceil(currentTime / this._totalTime) * this._totalTime;
}
}
}
if (this._currentTime != currentTime) {
this._currentTime = currentTime;
var frameList = this._timelineData.frameList;
var prevFrame;
var currentFrame;
for (var i = 0, l = this._timelineData.frameList.length; i < l; ++i) {
if (this._currentFrameIndex < 0) {
this._currentFrameIndex = 0;
}
else if (this._currentTime < this._currentFramePosition || this._currentTime >= this._currentFramePosition + this._currentFrameDuration) {
this._currentFrameIndex++;
if (this._currentFrameIndex >= frameList.length) {
if (this._isComplete) {
this._currentFrameIndex--;
break;
}
else {
this._currentFrameIndex = 0;
}
}
}
else {
break;
}
currentFrame = (frameList[this._currentFrameIndex]);
if (prevFrame) {
this._slot._arriveAtFrame(prevFrame, this, this._animationState, true);
}
this._currentFrameDuration = currentFrame.duration;
this._currentFramePosition = currentFrame.position;
prevFrame = currentFrame;
}
if (currentFrame) {
this._slot._arriveAtFrame(currentFrame, this, this._animationState, false);
this._blendEnabled = currentFrame.displayIndex >= 0;
if (this._blendEnabled) {
this.updateToNextFrame(currentPlayTimes);
}
else {
this._tweenEasing = NaN;
this._tweenColor = false;
}
}
if (this._blendEnabled) {
this.updateTween();
}
}
};
p.updateToNextFrame = function (currentPlayTimes) {
if (currentPlayTimes === void 0) { currentPlayTimes = 0; }
var nextFrameIndex = this._currentFrameIndex + 1;
if (nextFrameIndex >= this._timelineData.frameList.length) {
nextFrameIndex = 0;
}
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
var nextFrame = (this._timelineData.frameList[nextFrameIndex]);
var tweenEnabled = false;
if (nextFrameIndex == 0 &&
(!this._animationState.lastFrameAutoTween ||
(this._animationState.playTimes &&
this._animationState.currentPlayTimes >= this._animationState.playTimes &&
((this._currentFramePosition + this._currentFrameDuration) / this._totalTime + currentPlayTimes - this._timelineData.offset) * this._timelineData.scale > 0.999999))) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else if (currentFrame.displayIndex < 0 || nextFrame.displayIndex < 0) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else if (this._animationState.autoTween) {
this._tweenEasing = this._animationState.clip.tweenEasing;
if (isNaN(this._tweenEasing)) {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if (isNaN(this._tweenEasing) && this._tweenCurve == null) {
tweenEnabled = false;
}
else {
if (this._tweenEasing == 10) {
this._tweenEasing = 0;
}
tweenEnabled = true;
}
}
else {
tweenEnabled = true;
}
}
else {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if ((isNaN(this._tweenEasing) || this._tweenEasing == 10) && this._tweenCurve == null) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else {
tweenEnabled = true;
}
}
if (tweenEnabled) {
if (currentFrame.color && nextFrame.color) {
this._durationColor.alphaOffset = nextFrame.color.alphaOffset - currentFrame.color.alphaOffset;
this._durationColor.redOffset = nextFrame.color.redOffset - currentFrame.color.redOffset;
this._durationColor.greenOffset = nextFrame.color.greenOffset - currentFrame.color.greenOffset;
this._durationColor.blueOffset = nextFrame.color.blueOffset - currentFrame.color.blueOffset;
this._durationColor.alphaMultiplier = nextFrame.color.alphaMultiplier - currentFrame.color.alphaMultiplier;
this._durationColor.redMultiplier = nextFrame.color.redMultiplier - currentFrame.color.redMultiplier;
this._durationColor.greenMultiplier = nextFrame.color.greenMultiplier - currentFrame.color.greenMultiplier;
this._durationColor.blueMultiplier = nextFrame.color.blueMultiplier - currentFrame.color.blueMultiplier;
if (this._durationColor.alphaOffset ||
this._durationColor.redOffset ||
this._durationColor.greenOffset ||
this._durationColor.blueOffset ||
this._durationColor.alphaMultiplier ||
this._durationColor.redMultiplier ||
this._durationColor.greenMultiplier ||
this._durationColor.blueMultiplier) {
this._tweenColor = true;
}
else {
this._tweenColor = false;
}
}
else if (currentFrame.color) {
this._tweenColor = true;
this._durationColor.alphaOffset = -currentFrame.color.alphaOffset;
this._durationColor.redOffset = -currentFrame.color.redOffset;
this._durationColor.greenOffset = -currentFrame.color.greenOffset;
this._durationColor.blueOffset = -currentFrame.color.blueOffset;
this._durationColor.alphaMultiplier = 1 - currentFrame.color.alphaMultiplier;
this._durationColor.redMultiplier = 1 - currentFrame.color.redMultiplier;
this._durationColor.greenMultiplier = 1 - currentFrame.color.greenMultiplier;
this._durationColor.blueMultiplier = 1 - currentFrame.color.blueMultiplier;
}
else if (nextFrame.color) {
this._tweenColor = true;
this._durationColor.alphaOffset = nextFrame.color.alphaOffset;
this._durationColor.redOffset = nextFrame.color.redOffset;
this._durationColor.greenOffset = nextFrame.color.greenOffset;
this._durationColor.blueOffset = nextFrame.color.blueOffset;
this._durationColor.alphaMultiplier = nextFrame.color.alphaMultiplier - 1;
this._durationColor.redMultiplier = nextFrame.color.redMultiplier - 1;
this._durationColor.greenMultiplier = nextFrame.color.greenMultiplier - 1;
this._durationColor.blueMultiplier = nextFrame.color.blueMultiplier - 1;
}
else {
this._tweenColor = false;
}
}
else {
this._tweenColor = false;
}
if (!this._tweenColor && this._animationState.displayControl) {
if (currentFrame.color) {
this._slot._updateDisplayColor(currentFrame.color.alphaOffset, currentFrame.color.redOffset, currentFrame.color.greenOffset, currentFrame.color.blueOffset, currentFrame.color.alphaMultiplier, currentFrame.color.redMultiplier, currentFrame.color.greenMultiplier, currentFrame.color.blueMultiplier, true);
}
else if (this._slot._isColorChanged) {
this._slot._updateDisplayColor(0, 0, 0, 0, 1, 1, 1, 1, false);
}
}
};
p.updateTween = function () {
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
if (this._tweenColor && this._animationState.displayControl) {
var progress = (this._currentTime - this._currentFramePosition) / this._currentFrameDuration;
if (this._tweenCurve != null) {
progress = this._tweenCurve.getValueByProgress(progress);
}
else if (this._tweenEasing) {
progress = dragonBones.MathUtil.getEaseValue(progress, this._tweenEasing);
}
if (currentFrame.color) {
this._slot._updateDisplayColor(currentFrame.color.alphaOffset + this._durationColor.alphaOffset * progress, currentFrame.color.redOffset + this._durationColor.redOffset * progress, currentFrame.color.greenOffset + this._durationColor.greenOffset * progress, currentFrame.color.blueOffset + this._durationColor.blueOffset * progress, currentFrame.color.alphaMultiplier + this._durationColor.alphaMultiplier * progress, currentFrame.color.redMultiplier + this._durationColor.redMultiplier * progress, currentFrame.color.greenMultiplier + this._durationColor.greenMultiplier * progress, currentFrame.color.blueMultiplier + this._durationColor.blueMultiplier * progress, true);
}
else {
this._slot._updateDisplayColor(this._durationColor.alphaOffset * progress, this._durationColor.redOffset * progress, this._durationColor.greenOffset * progress, this._durationColor.blueOffset * progress, 1 + this._durationColor.alphaMultiplier * progress, 1 + this._durationColor.redMultiplier * progress, 1 + this._durationColor.greenMultiplier * progress, 1 + this._durationColor.blueMultiplier * progress, true);
}
}
};
p.updateSingleFrame = function () {
var currentFrame = (this._timelineData.frameList[0]);
this._slot._arriveAtFrame(currentFrame, this, this._animationState, false);
this._isComplete = true;
this._tweenEasing = NaN;
this._tweenColor = false;
this._blendEnabled = currentFrame.displayIndex >= 0;
if (this._blendEnabled) {
if (this._animationState.displayControl) {
if (currentFrame.color) {
this._slot._updateDisplayColor(currentFrame.color.alphaOffset, currentFrame.color.redOffset, currentFrame.color.greenOffset, currentFrame.color.blueOffset, currentFrame.color.alphaMultiplier, currentFrame.color.redMultiplier, currentFrame.color.greenMultiplier, currentFrame.color.blueMultiplier, true);
}
else if (this._slot._isColorChanged) {
this._slot._updateDisplayColor(0, 0, 0, 0, 1, 1, 1, 1, false);
}
}
}
};
SlotTimelineState.HALF_PI = Math.PI * 0.5;
SlotTimelineState.DOUBLE_PI = Math.PI * 2;
SlotTimelineState._pool = [];
return SlotTimelineState;
})();
dragonBones.SlotTimelineState = SlotTimelineState;
egret.registerClass(SlotTimelineState,'dragonBones.SlotTimelineState');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var TimelineState = (function () {
function TimelineState() {
this._totalTime = 0;
this._currentTime = 0;
this._lastTime = 0;
this._currentFrameIndex = 0;
this._currentFramePosition = 0;
this._currentFrameDuration = 0;
this._updateMode = 0;
this._transform = new dragonBones.DBTransform();
this._pivot = new dragonBones.Point();
this._durationTransform = new dragonBones.DBTransform();
this._durationPivot = new dragonBones.Point();
this._durationColor = new dragonBones.ColorTransform();
}
var d = __define,c=TimelineState,p=c.prototype;
TimelineState._borrowObject = function () {
if (TimelineState._pool.length == 0) {
return new TimelineState();
}
return TimelineState._pool.pop();
};
TimelineState._returnObject = function (timeline) {
if (TimelineState._pool.indexOf(timeline) < 0) {
TimelineState._pool[TimelineState._pool.length] = timeline;
}
timeline.clear();
};
TimelineState._clear = function () {
var i = TimelineState._pool.length;
while (i--) {
TimelineState._pool[i].clear();
}
TimelineState._pool.length = 0;
};
p.clear = function () {
if (this._bone) {
this._bone._removeState(this);
this._bone = null;
}
this._armature = null;
this._animation = null;
this._animationState = null;
this._timelineData = null;
this._originTransform = null;
this._originPivot = null;
};
p._fadeIn = function (bone, animationState, timelineData) {
this._bone = bone;
this._armature = this._bone.armature;
this._animation = this._armature.animation;
this._animationState = animationState;
this._timelineData = timelineData;
this._originTransform = this._timelineData.originTransform;
this._originPivot = this._timelineData.originPivot;
this.name = timelineData.name;
this._totalTime = this._timelineData.duration;
this._rawAnimationScale = this._animationState.clip.scale;
this._isComplete = false;
this._tweenTransform = false;
this._tweenScale = false;
this._currentFrameIndex = -1;
this._currentTime = -1;
this._tweenEasing = NaN;
this._weight = 1;
this._transform.x = 0;
this._transform.y = 0;
this._transform.scaleX = 1;
this._transform.scaleY = 1;
this._transform.skewX = 0;
this._transform.skewY = 0;
this._pivot.x = 0;
this._pivot.y = 0;
this._durationTransform.x = 0;
this._durationTransform.y = 0;
this._durationTransform.scaleX = 1;
this._durationTransform.scaleY = 1;
this._durationTransform.skewX = 0;
this._durationTransform.skewY = 0;
this._durationPivot.x = 0;
this._durationPivot.y = 0;
switch (this._timelineData.frameList.length) {
case 0:
this._updateMode = 0;
break;
case 1:
this._updateMode = 1;
break;
default:
this._updateMode = -1;
break;
}
this._bone._addState(this);
};
p._fadeOut = function () {
this._transform.skewX = dragonBones.TransformUtil.formatRadian(this._transform.skewX);
this._transform.skewY = dragonBones.TransformUtil.formatRadian(this._transform.skewY);
};
p._update = function (progress) {
if (this._updateMode == -1) {
this.updateMultipleFrame(progress);
}
else if (this._updateMode == 1) {
this._updateMode = 0;
this.updateSingleFrame();
}
};
p.updateMultipleFrame = function (progress) {
var currentPlayTimes = 0;
progress /= this._timelineData.scale;
progress += this._timelineData.offset;
var currentTime = this._totalTime * progress;
var playTimes = this._animationState.playTimes;
if (playTimes == 0) {
this._isComplete = false;
currentPlayTimes = Math.ceil(Math.abs(currentTime) / this._totalTime) || 1;
if (currentTime >= 0) {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
else {
currentTime -= Math.ceil(currentTime / this._totalTime) * this._totalTime;
}
if (currentTime < 0) {
currentTime += this._totalTime;
}
}
else {
var totalTimes = playTimes * this._totalTime;
if (currentTime >= totalTimes) {
currentTime = totalTimes;
this._isComplete = true;
}
else if (currentTime <= -totalTimes) {
currentTime = -totalTimes;
this._isComplete = true;
}
else {
this._isComplete = false;
}
if (currentTime < 0) {
currentTime += totalTimes;
}
currentPlayTimes = Math.ceil(currentTime / this._totalTime) || 1;
if (this._isComplete) {
currentTime = this._totalTime;
}
else {
if (currentTime >= 0) {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
else {
currentTime -= Math.ceil(currentTime / this._totalTime) * this._totalTime;
}
}
}
if (this._currentTime != currentTime) {
this._lastTime = this._currentTime;
this._currentTime = currentTime;
var frameList = this._timelineData.frameList;
var prevFrame;
var currentFrame;
for (var i = 0, l = this._timelineData.frameList.length; i < l; ++i) {
if (this._currentFrameIndex < 0) {
this._currentFrameIndex = 0;
}
else if (this._currentTime < this._currentFramePosition || this._currentTime >= this._currentFramePosition + this._currentFrameDuration || this._currentTime < this._lastTime) {
this._currentFrameIndex++;
this._lastTime = this._currentTime;
if (this._currentFrameIndex >= frameList.length) {
if (this._isComplete) {
this._currentFrameIndex--;
break;
}
else {
this._currentFrameIndex = 0;
}
}
}
else {
break;
}
currentFrame = (frameList[this._currentFrameIndex]);
if (prevFrame) {
this._bone._arriveAtFrame(prevFrame, this, this._animationState, true);
}
this._currentFrameDuration = currentFrame.duration;
this._currentFramePosition = currentFrame.position;
prevFrame = currentFrame;
}
if (currentFrame) {
this._bone._arriveAtFrame(currentFrame, this, this._animationState, false);
this.updateToNextFrame(currentPlayTimes);
}
this.updateTween();
}
};
p.updateToNextFrame = function (currentPlayTimes) {
if (currentPlayTimes === void 0) { currentPlayTimes = 0; }
var nextFrameIndex = this._currentFrameIndex + 1;
if (nextFrameIndex >= this._timelineData.frameList.length) {
nextFrameIndex = 0;
}
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
var nextFrame = (this._timelineData.frameList[nextFrameIndex]);
var tweenEnabled = false;
if (nextFrameIndex == 0 &&
(!this._animationState.lastFrameAutoTween ||
(this._animationState.playTimes &&
this._animationState.currentPlayTimes >= this._animationState.playTimes &&
((this._currentFramePosition + this._currentFrameDuration) / this._totalTime + currentPlayTimes - this._timelineData.offset) * this._timelineData.scale > 0.999999))) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else if (currentFrame.displayIndex < 0 || nextFrame.displayIndex < 0) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else if (this._animationState.autoTween) {
this._tweenEasing = this._animationState.clip.tweenEasing;
if (isNaN(this._tweenEasing)) {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if (isNaN(this._tweenEasing) && this._tweenCurve == null) {
tweenEnabled = false;
}
else {
if (this._tweenEasing == 10) {
this._tweenEasing = 0;
}
tweenEnabled = true;
}
}
else {
tweenEnabled = true;
}
}
else {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if ((isNaN(this._tweenEasing) || this._tweenEasing == 10) && this._tweenCurve == null) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else {
tweenEnabled = true;
}
}
if (tweenEnabled) {
this._durationTransform.x = nextFrame.transform.x - currentFrame.transform.x;
this._durationTransform.y = nextFrame.transform.y - currentFrame.transform.y;
this._durationTransform.skewX = nextFrame.transform.skewX - currentFrame.transform.skewX;
this._durationTransform.skewY = nextFrame.transform.skewY - currentFrame.transform.skewY;
this._durationTransform.scaleX = nextFrame.transform.scaleX - currentFrame.transform.scaleX + nextFrame.scaleOffset.x;
this._durationTransform.scaleY = nextFrame.transform.scaleY - currentFrame.transform.scaleY + nextFrame.scaleOffset.y;
this._durationTransform.normalizeRotation();
if (nextFrameIndex == 0) {
this._durationTransform.skewX = dragonBones.TransformUtil.formatRadian(this._durationTransform.skewX);
this._durationTransform.skewY = dragonBones.TransformUtil.formatRadian(this._durationTransform.skewY);
}
this._durationPivot.x = nextFrame.pivot.x - currentFrame.pivot.x;
this._durationPivot.y = nextFrame.pivot.y - currentFrame.pivot.y;
if (this._durationTransform.x ||
this._durationTransform.y ||
this._durationTransform.skewX ||
this._durationTransform.skewY ||
this._durationTransform.scaleX ||
this._durationTransform.scaleY ||
this._durationPivot.x ||
this._durationPivot.y) {
this._tweenTransform = true;
this._tweenScale = currentFrame.tweenScale;
}
else {
this._tweenTransform = false;
this._tweenScale = false;
}
}
else {
this._tweenTransform = false;
this._tweenScale = false;
}
if (!this._tweenTransform) {
if (this._animationState.additiveBlending) {
this._transform.x = currentFrame.transform.x;
this._transform.y = currentFrame.transform.y;
this._transform.skewX = currentFrame.transform.skewX;
this._transform.skewY = currentFrame.transform.skewY;
this._transform.scaleX = currentFrame.transform.scaleX;
this._transform.scaleY = currentFrame.transform.scaleY;
this._pivot.x = currentFrame.pivot.x;
this._pivot.y = currentFrame.pivot.y;
}
else {
this._transform.x = this._originTransform.x + currentFrame.transform.x;
this._transform.y = this._originTransform.y + currentFrame.transform.y;
this._transform.skewX = this._originTransform.skewX + currentFrame.transform.skewX;
this._transform.skewY = this._originTransform.skewY + currentFrame.transform.skewY;
this._transform.scaleX = this._originTransform.scaleX * currentFrame.transform.scaleX;
this._transform.scaleY = this._originTransform.scaleY * currentFrame.transform.scaleY;
this._pivot.x = this._originPivot.x + currentFrame.pivot.x;
this._pivot.y = this._originPivot.y + currentFrame.pivot.y;
}
this._bone.invalidUpdate();
}
else if (!this._tweenScale) {
if (this._animationState.additiveBlending) {
this._transform.scaleX = currentFrame.transform.scaleX;
this._transform.scaleY = currentFrame.transform.scaleY;
}
else {
this._transform.scaleX = this._originTransform.scaleX * currentFrame.transform.scaleX;
this._transform.scaleY = this._originTransform.scaleY * currentFrame.transform.scaleY;
}
}
};
p.updateTween = function () {
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
if (this._tweenTransform) {
var progress = (this._currentTime - this._currentFramePosition) / this._currentFrameDuration;
if (this._tweenCurve != null) {
progress = this._tweenCurve.getValueByProgress(progress);
}
else if (this._tweenEasing) {
progress = dragonBones.MathUtil.getEaseValue(progress, this._tweenEasing);
}
var currentTransform = currentFrame.transform;
var currentPivot = currentFrame.pivot;
if (this._animationState.additiveBlending) {
this._transform.x = currentTransform.x + this._durationTransform.x * progress;
this._transform.y = currentTransform.y + this._durationTransform.y * progress;
this._transform.skewX = currentTransform.skewX + this._durationTransform.skewX * progress;
this._transform.skewY = currentTransform.skewY + this._durationTransform.skewY * progress;
if (this._tweenScale) {
this._transform.scaleX = currentTransform.scaleX + this._durationTransform.scaleX * progress;
this._transform.scaleY = currentTransform.scaleY + this._durationTransform.scaleY * progress;
}
this._pivot.x = currentPivot.x + this._durationPivot.x * progress;
this._pivot.y = currentPivot.y + this._durationPivot.y * progress;
}
else {
this._transform.x = this._originTransform.x + currentTransform.x + this._durationTransform.x * progress;
this._transform.y = this._originTransform.y + currentTransform.y + this._durationTransform.y * progress;
this._transform.skewX = this._originTransform.skewX + currentTransform.skewX + this._durationTransform.skewX * progress;
this._transform.skewY = this._originTransform.skewY + currentTransform.skewY + this._durationTransform.skewY * progress;
if (this._tweenScale) {
this._transform.scaleX = this._originTransform.scaleX * currentTransform.scaleX + this._durationTransform.scaleX * progress;
this._transform.scaleY = this._originTransform.scaleY * currentTransform.scaleY + this._durationTransform.scaleY * progress;
}
this._pivot.x = this._originPivot.x + currentPivot.x + this._durationPivot.x * progress;
this._pivot.y = this._originPivot.y + currentPivot.y + this._durationPivot.y * progress;
}
this._bone.invalidUpdate();
}
};
p.updateSingleFrame = function () {
var currentFrame = (this._timelineData.frameList[0]);
this._bone._arriveAtFrame(currentFrame, this, this._animationState, false);
this._isComplete = true;
this._tweenEasing = NaN;
this._tweenTransform = false;
this._tweenScale = false;
this._tweenColor = false;
if (this._animationState.additiveBlending) {
this._transform.x = currentFrame.transform.x;
this._transform.y = currentFrame.transform.y;
this._transform.skewX = currentFrame.transform.skewX;
this._transform.skewY = currentFrame.transform.skewY;
this._transform.scaleX = currentFrame.transform.scaleX;
this._transform.scaleY = currentFrame.transform.scaleY;
this._pivot.x = currentFrame.pivot.x;
this._pivot.y = currentFrame.pivot.y;
}
else {
this._transform.x = this._originTransform.x + currentFrame.transform.x;
this._transform.y = this._originTransform.y + currentFrame.transform.y;
this._transform.skewX = this._originTransform.skewX + currentFrame.transform.skewX;
this._transform.skewY = this._originTransform.skewY + currentFrame.transform.skewY;
this._transform.scaleX = this._originTransform.scaleX * currentFrame.transform.scaleX;
this._transform.scaleY = this._originTransform.scaleY * currentFrame.transform.scaleY;
this._pivot.x = this._originPivot.x + currentFrame.pivot.x;
this._pivot.y = this._originPivot.y + currentFrame.pivot.y;
}
this._bone.invalidUpdate();
};
TimelineState.HALF_PI = Math.PI * 0.5;
TimelineState.DOUBLE_PI = Math.PI * 2;
TimelineState._pool = [];
return TimelineState;
})();
dragonBones.TimelineState = TimelineState;
egret.registerClass(TimelineState,'dragonBones.TimelineState');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var WorldClock = (function () {
function WorldClock(time, timeScale) {
if (time === void 0) { time = -1; }
if (timeScale === void 0) { timeScale = 1; }
this._time = time >= 0 ? time : new Date().getTime() * 0.001;
this._timeScale = isNaN(timeScale) ? 1 : timeScale;
this._animatableList = [];
}
var d = __define,c=WorldClock,p=c.prototype;
d(p, "time"
,function () {
return this._time;
}
);
d(p, "timeScale"
,function () {
return this._timeScale;
}
,function (value) {
if (isNaN(value) || value < 0) {
value = 1;
}
this._timeScale = value;
}
);
p.contains = function (animatable) {
return this._animatableList.indexOf(animatable) >= 0;
};
p.add = function (animatable) {
if (animatable && this._animatableList.indexOf(animatable) == -1) {
this._animatableList.push(animatable);
}
};
p.remove = function (animatable) {
var index = this._animatableList.indexOf(animatable);
if (index >= 0) {
this._animatableList[index] = null;
}
};
p.clear = function () {
this._animatableList.length = 0;
};
p.advanceTime = function (passedTime) {
if (passedTime === void 0) { passedTime = -1; }
if (passedTime < 0) {
passedTime = new Date().getTime() * 0.001 - this._time;
}
passedTime *= this._timeScale;
this._time += passedTime;
var length = this._animatableList.length;
if (length == 0) {
return;
}
var currentIndex = 0;
for (var i = 0; i < length; i++) {
var animatable = this._animatableList[i];
if (animatable) {
if (currentIndex != i) {
this._animatableList[currentIndex] = animatable;
this._animatableList[i] = null;
}
animatable.advanceTime(passedTime);
currentIndex++;
}
}
if (currentIndex != i) {
length = this._animatableList.length;
while (i < length) {
this._animatableList[currentIndex++] = this._animatableList[i++];
}
this._animatableList.length = currentIndex;
}
};
WorldClock.clock = new WorldClock();
return WorldClock;
})();
dragonBones.WorldClock = WorldClock;
egret.registerClass(WorldClock,'dragonBones.WorldClock',["dragonBones.IAnimatable"]);
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var EventDispatcher = (function (_super) {
__extends(EventDispatcher, _super);
function EventDispatcher(target) {
if (target === void 0) { target = null; }
_super.call(this, target);
}
var d = __define,c=EventDispatcher,p=c.prototype;
return EventDispatcher;
})(egret.EventDispatcher);
dragonBones.EventDispatcher = EventDispatcher;
egret.registerClass(EventDispatcher,'dragonBones.EventDispatcher');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SoundEventManager = (function (_super) {
__extends(SoundEventManager, _super);
function SoundEventManager() {
_super.call(this);
if (SoundEventManager._instance) {
throw new Error("Singleton already constructed!");
}
}
var d = __define,c=SoundEventManager,p=c.prototype;
SoundEventManager.getInstance = function () {
if (!SoundEventManager._instance) {
SoundEventManager._instance = new SoundEventManager();
}
return SoundEventManager._instance;
};
return SoundEventManager;
})(dragonBones.EventDispatcher);
dragonBones.SoundEventManager = SoundEventManager;
egret.registerClass(SoundEventManager,'dragonBones.SoundEventManager');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Armature = (function (_super) {
__extends(Armature, _super);
function Armature(display) {
_super.call(this);
this._display = display;
this._animation = new dragonBones.Animation(this);
this._slotsZOrderChanged = false;
this._slotList = [];
this._boneList = [];
this._eventList = [];
this._delayDispose = false;
this._lockDispose = false;
this._armatureData = null;
}
var d = __define,c=Armature,p=c.prototype;
d(p, "armatureData"
,function () {
return this._armatureData;
}
);
d(p, "display"
,function () {
return this._display;
}
);
p.getDisplay = function () {
return this._display;
};
d(p, "animation"
,function () {
return this._animation;
}
);
p.dispose = function () {
this._delayDispose = true;
if (!this._animation || this._lockDispose) {
return;
}
this.userData = null;
this._animation.dispose();
var i = this._slotList.length;
while (i--) {
this._slotList[i].dispose();
}
i = this._boneList.length;
while (i--) {
this._boneList[i].dispose();
}
this._armatureData = null;
this._animation = null;
this._slotList = null;
this._boneList = null;
this._eventList = null;
};
p.invalidUpdate = function (boneName) {
if (boneName === void 0) { boneName = null; }
if (boneName) {
var bone = this.getBone(boneName);
if (bone) {
bone.invalidUpdate();
}
}
else {
var i = this._boneList.length;
while (i--) {
this._boneList[i].invalidUpdate();
}
}
};
p.advanceTime = function (passedTime) {
this._lockDispose = true;
this._animation._advanceTime(passedTime);
passedTime *= this._animation.timeScale;
var isFading = this._animation._isFading;
var i = this._boneList.length;
while (i--) {
var bone = this._boneList[i];
bone._update(isFading);
}
i = this._slotList.length;
while (i--) {
var slot = this._slotList[i];
slot._update();
if (slot._isShowDisplay) {
var childArmature = slot.childArmature;
if (childArmature) {
childArmature.advanceTime(passedTime);
}
}
}
if (this._slotsZOrderChanged) {
this.updateSlotsZOrder();
if (this.hasEventListener(dragonBones.ArmatureEvent.Z_ORDER_UPDATED)) {
this.dispatchEvent(new dragonBones.ArmatureEvent(dragonBones.ArmatureEvent.Z_ORDER_UPDATED));
}
}
if (this._eventList.length > 0) {
for (var i = 0, len = this._eventList.length; i < len; i++) {
var event = this._eventList[i];
this.dispatchEvent(event);
}
this._eventList.length = 0;
}
this._lockDispose = false;
if (this._delayDispose) {
this.dispose();
}
};
p.resetAnimation = function () {
this.animation.stop();
this.animation._resetAnimationStateList();
for (var i = 0, len = this._boneList.length; i < len; i++) {
this._boneList[i]._removeAllStates();
}
};
p.getSlots = function (returnCopy) {
if (returnCopy === void 0) { returnCopy = true; }
return returnCopy ? this._slotList.concat() : this._slotList;
};
p.getSlot = function (slotName) {
var length = this._slotList.length;
for (var i = 0; i < length; i++) {
var slot = this._slotList[i];
if (slot.name == slotName) {
return slot;
}
}
return null;
};
p.getSlotByDisplay = function (displayObj) {
if (displayObj) {
var length = this._slotList.length;
for (var i = 0; i < length; i++) {
var slot = this._slotList[i];
if (slot.display == displayObj) {
return slot;
}
}
}
return null;
};
p.addSlot = function (slot, boneName) {
var bone = this.getBone(boneName);
if (bone) {
bone.addSlot(slot);
}
else {
throw new Error();
}
};
p.removeSlot = function (slot) {
if (!slot || slot.armature != this) {
throw new Error();
}
slot.parent.removeSlot(slot);
};
p.removeSlotByName = function (slotName) {
var slot = this.getSlot(slotName);
if (slot) {
this.removeSlot(slot);
}
return slot;
};
p.getBones = function (returnCopy) {
if (returnCopy === void 0) { returnCopy = true; }
return returnCopy ? this._boneList.concat() : this._boneList;
};
p.getBone = function (boneName) {
var length = this._boneList.length;
for (var i = 0; i < length; i++) {
var bone = this._boneList[i];
if (bone.name == boneName) {
return bone;
}
}
return null;
};
p.getBoneByDisplay = function (display) {
var slot = this.getSlotByDisplay(display);
return slot ? slot.parent : null;
};
p.addBone = function (bone, parentName, updateLater) {
if (parentName === void 0) { parentName = null; }
if (updateLater === void 0) { updateLater = false; }
var parentBone;
if (parentName) {
parentBone = this.getBone(parentName);
if (!parentBone) {
throw new Error();
}
}
if (parentBone) {
parentBone.addChildBone(bone, updateLater);
}
else {
if (bone.parent) {
bone.parent.removeChildBone(bone, updateLater);
}
bone._setArmature(this);
if (!updateLater) {
this._updateAnimationAfterBoneListChanged();
}
}
};
p.removeBone = function (bone, updateLater) {
if (updateLater === void 0) { updateLater = false; }
if (!bone || bone.armature != this) {
throw new Error();
}
if (bone.parent) {
bone.parent.removeChildBone(bone, updateLater);
}
else {
bone._setArmature(null);
if (!updateLater) {
this._updateAnimationAfterBoneListChanged(false);
}
}
};
p.removeBoneByName = function (boneName) {
var bone = this.getBone(boneName);
if (bone) {
this.removeBone(bone);
}
return bone;
};
p._addBoneToBoneList = function (bone) {
if (this._boneList.indexOf(bone) < 0) {
this._boneList[this._boneList.length] = bone;
}
};
p._removeBoneFromBoneList = function (bone) {
var index = this._boneList.indexOf(bone);
if (index >= 0) {
this._boneList.splice(index, 1);
}
};
p._addSlotToSlotList = function (slot) {
if (this._slotList.indexOf(slot) < 0) {
this._slotList[this._slotList.length] = slot;
}
};
p._removeSlotFromSlotList = function (slot) {
var index = this._slotList.indexOf(slot);
if (index >= 0) {
this._slotList.splice(index, 1);
}
};
p.updateSlotsZOrder = function () {
this._slotList.sort(this.sortSlot);
var i = this._slotList.length;
while (i--) {
var slot = this._slotList[i];
if (slot._isShowDisplay) {
slot._addDisplayToContainer(this._display);
}
}
this._slotsZOrderChanged = false;
};
p._updateAnimationAfterBoneListChanged = function (ifNeedSortBoneList) {
if (ifNeedSortBoneList === void 0) { ifNeedSortBoneList = true; }
if (ifNeedSortBoneList) {
this.sortBoneList();
}
this._animation._updateAnimationStates();
};
p.sortBoneList = function () {
var i = this._boneList.length;
if (i == 0) {
return;
}
var helpArray = [];
while (i--) {
var level = 0;
var bone = this._boneList[i];
var boneParent = bone;
while (boneParent) {
level++;
boneParent = boneParent.parent;
}
helpArray[i] = [level, bone];
}
helpArray.sort(dragonBones.ArmatureData.sortBoneDataHelpArrayDescending);
i = helpArray.length;
while (i--) {
this._boneList[i] = helpArray[i][1];
}
helpArray.length = 0;
};
p._arriveAtFrame = function (frame, timelineState, animationState, isCross) {
if (frame.event && this.hasEventListener(dragonBones.FrameEvent.ANIMATION_FRAME_EVENT)) {
var frameEvent = new dragonBones.FrameEvent(dragonBones.FrameEvent.ANIMATION_FRAME_EVENT);
frameEvent.animationState = animationState;
frameEvent.frameLabel = frame.event;
this._eventList.push(frameEvent);
}
if (frame.sound && Armature._soundManager.hasEventListener(dragonBones.SoundEvent.SOUND)) {
var soundEvent = new dragonBones.SoundEvent(dragonBones.SoundEvent.SOUND);
soundEvent.armature = this;
soundEvent.animationState = animationState;
soundEvent.sound = frame.sound;
Armature._soundManager.dispatchEvent(soundEvent);
}
if (frame.action) {
if (animationState.displayControl) {
this.animation.gotoAndPlay(frame.action);
}
}
};
p.sortSlot = function (slot1, slot2) {
return slot1.zOrder < slot2.zOrder ? 1 : -1;
};
p.getAnimation = function () {
return this._animation;
};
Armature._soundManager = dragonBones.SoundEventManager.getInstance();
return Armature;
})(dragonBones.EventDispatcher);
dragonBones.Armature = Armature;
egret.registerClass(Armature,'dragonBones.Armature',["dragonBones.IAnimatable"]);
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Matrix = (function () {
function Matrix() {
this.a = 1;
this.b = 0;
this.c = 0;
this.d = 1;
this.tx = 0;
this.ty = 0;
}
var d = __define,c=Matrix,p=c.prototype;
p.invert = function () {
var a1 = this.a;
var b1 = this.b;
var c1 = this.c;
var d1 = this.d;
var tx1 = this.tx;
var n = a1 * d1 - b1 * c1;
this.a = d1 / n;
this.b = -b1 / n;
this.c = -c1 / n;
this.d = a1 / n;
this.tx = (c1 * this.ty - d1 * tx1) / n;
this.ty = -(a1 * this.ty - b1 * tx1) / n;
};
p.concat = function (m) {
var ma = m.a;
var mb = m.b;
var mc = m.c;
var md = m.d;
var tx1 = this.tx;
var ty1 = this.ty;
if (ma != 1 || mb != 0 || mc != 0 || md != 1) {
var a1 = this.a;
var b1 = this.b;
var c1 = this.c;
var d1 = this.d;
this.a = a1 * ma + b1 * mc;
this.b = a1 * mb + b1 * md;
this.c = c1 * ma + d1 * mc;
this.d = c1 * mb + d1 * md;
}
this.tx = tx1 * ma + ty1 * mc + m.tx;
this.ty = tx1 * mb + ty1 * md + m.ty;
};
p.copyFrom = function (m) {
this.tx = m.tx;
this.ty = m.ty;
this.a = m.a;
this.b = m.b;
this.c = m.c;
this.d = m.d;
};
return Matrix;
})();
dragonBones.Matrix = Matrix;
egret.registerClass(Matrix,'dragonBones.Matrix');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var DBTransform = (function () {
function DBTransform() {
this.x = 0;
this.y = 0;
this.skewX = 0;
this.skewY = 0;
this.scaleX = 1;
this.scaleY = 1;
}
var d = __define,c=DBTransform,p=c.prototype;
d(p, "rotation"
,function () {
return this.skewX;
}
,function (value) {
this.skewX = this.skewY = value;
}
);
p.copy = function (transform) {
this.x = transform.x;
this.y = transform.y;
this.skewX = transform.skewX;
this.skewY = transform.skewY;
this.scaleX = transform.scaleX;
this.scaleY = transform.scaleY;
};
p.add = function (transform) {
this.x += transform.x;
this.y += transform.y;
this.skewX += transform.skewX;
this.skewY += transform.skewY;
this.scaleX *= transform.scaleX;
this.scaleY *= transform.scaleY;
};
p.minus = function (transform) {
this.x -= transform.x;
this.y -= transform.y;
this.skewX -= transform.skewX;
this.skewY -= transform.skewY;
this.scaleX /= transform.scaleX;
this.scaleY /= transform.scaleY;
};
p.normalizeRotation = function () {
this.skewX = dragonBones.TransformUtil.normalizeRotation(this.skewX);
this.skewY = dragonBones.TransformUtil.normalizeRotation(this.skewY);
};
p.toString = function () {
var string = "x:" + this.x + " y:" + this.y + " skewX:" + this.skewX + " skewY:" + this.skewY + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY;
return string;
};
return DBTransform;
})();
dragonBones.DBTransform = DBTransform;
egret.registerClass(DBTransform,'dragonBones.DBTransform');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var DBObject = (function () {
function DBObject() {
this._globalTransformMatrix = new dragonBones.Matrix();
this._global = new dragonBones.DBTransform();
this._origin = new dragonBones.DBTransform();
this._offset = new dragonBones.DBTransform();
this._offset.scaleX = this._offset.scaleY = 1;
this._visible = true;
this._armature = null;
this._parent = null;
this.userData = null;
this.inheritRotation = true;
this.inheritScale = true;
this.inheritTranslation = true;
}
var d = __define,c=DBObject,p=c.prototype;
d(p, "global"
,function () {
return this._global;
}
);
d(p, "origin"
,function () {
return this._origin;
}
);
d(p, "offset"
,function () {
return this._offset;
}
);
d(p, "armature"
,function () {
return this._armature;
}
);
p._setArmature = function (value) {
this._armature = value;
};
d(p, "parent"
,function () {
return this._parent;
}
);
p._setParent = function (value) {
this._parent = value;
};
p.dispose = function () {
this.userData = null;
this._globalTransformMatrix = null;
this._global = null;
this._origin = null;
this._offset = null;
this._armature = null;
this._parent = null;
};
p._calculateRelativeParentTransform = function () {
};
p._calculateParentTransform = function () {
if (this.parent && (this.inheritTranslation || this.inheritRotation || this.inheritScale)) {
var parentGlobalTransform = this._parent._globalTransformForChild;
var parentGlobalTransformMatrix = this._parent._globalTransformMatrixForChild;
if (!this.inheritTranslation || !this.inheritRotation || !this.inheritScale) {
parentGlobalTransform = DBObject._tempParentGlobalTransform;
parentGlobalTransform.copy(this._parent._globalTransformForChild);
if (!this.inheritTranslation) {
parentGlobalTransform.x = 0;
parentGlobalTransform.y = 0;
}
if (!this.inheritScale) {
parentGlobalTransform.scaleX = 1;
parentGlobalTransform.scaleY = 1;
}
if (!this.inheritRotation) {
parentGlobalTransform.skewX = 0;
parentGlobalTransform.skewY = 0;
}
parentGlobalTransformMatrix = DBObject._tempParentGlobalTransformMatrix;
dragonBones.TransformUtil.transformToMatrix(parentGlobalTransform, parentGlobalTransformMatrix, true);
}
return { parentGlobalTransform: parentGlobalTransform, parentGlobalTransformMatrix: parentGlobalTransformMatrix };
}
return null;
};
p._updateGlobal = function () {
this._calculateRelativeParentTransform();
var output = this._calculateParentTransform();
if (output != null) {
var parentMatrix = output.parentGlobalTransformMatrix;
var parentGlobalTransform = output.parentGlobalTransform;
var x = this._global.x;
var y = this._global.y;
this._global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx;
this._global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty;
if (this.inheritRotation) {
this._global.skewX += parentGlobalTransform.skewX;
this._global.skewY += parentGlobalTransform.skewY;
}
if (this.inheritScale) {
this._global.scaleX *= parentGlobalTransform.scaleX;
this._global.scaleY *= parentGlobalTransform.scaleY;
}
}
dragonBones.TransformUtil.transformToMatrix(this._global, this._globalTransformMatrix, true);
return output;
};
DBObject._tempParentGlobalTransformMatrix = new dragonBones.Matrix();
DBObject._tempParentGlobalTransform = new dragonBones.DBTransform();
return DBObject;
})();
dragonBones.DBObject = DBObject;
egret.registerClass(DBObject,'dragonBones.DBObject');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Bone = (function (_super) {
__extends(Bone, _super);
function Bone() {
_super.call(this);
this.applyOffsetTranslationToChild = true;
this.applyOffsetRotationToChild = true;
this.applyOffsetScaleToChild = false;
this._needUpdate = 0;
this._tween = new dragonBones.DBTransform();
this._tweenPivot = new dragonBones.Point();
this._tween.scaleX = this._tween.scaleY = 1;
this._boneList = [];
this._slotList = [];
this._timelineStateList = [];
this._needUpdate = 2;
this._isColorChanged = false;
}
var d = __define,c=Bone,p=c.prototype;
Bone.initWithBoneData = function (boneData) {
var outputBone = new Bone();
outputBone.name = boneData.name;
outputBone.inheritRotation = boneData.inheritRotation;
outputBone.inheritScale = boneData.inheritScale;
outputBone.origin.copy(boneData.transform);
return outputBone;
};
p.dispose = function () {
if (!this._boneList) {
return;
}
_super.prototype.dispose.call(this);
var i = this._boneList.length;
while (i--) {
this._boneList[i].dispose();
}
i = this._slotList.length;
while (i--) {
this._slotList[i].dispose();
}
this._tween = null;
this._tweenPivot = null;
this._boneList = null;
this._slotList = null;
this._timelineStateList = null;
};
p.contains = function (child) {
if (!child) {
throw new Error();
}
if (child == this) {
return false;
}
var ancestor = child;
while (!(ancestor == this || ancestor == null)) {
ancestor = ancestor.parent;
}
return ancestor == this;
};
p.addChildBone = function (childBone, updateLater) {
if (updateLater === void 0) { updateLater = false; }
if (!childBone) {
throw new Error();
}
if (childBone == this || childBone.contains(this)) {
throw new Error();
}
if (childBone.parent == this) {
return;
}
if (childBone.parent) {
childBone.parent.removeChildBone(childBone, updateLater);
}
this._boneList[this._boneList.length] = childBone;
childBone._setParent(this);
childBone._setArmature(this._armature);
if (this._armature && !updateLater) {
this._armature._updateAnimationAfterBoneListChanged();
}
};
p.removeChildBone = function (childBone, updateLater) {
if (updateLater === void 0) { updateLater = false; }
if (!childBone) {
throw new Error();
}
var index = this._boneList.indexOf(childBone);
if (index < 0) {
throw new Error();
}
this._boneList.splice(index, 1);
childBone._setParent(null);
childBone._setArmature(null);
if (this._armature && !updateLater) {
this._armature._updateAnimationAfterBoneListChanged(false);
}
};
p.addSlot = function (childSlot) {
if (!childSlot) {
throw new Error();
}
if (childSlot.parent) {
childSlot.parent.removeSlot(childSlot);
}
this._slotList[this._slotList.length] = childSlot;
childSlot._setParent(this);
childSlot.setArmature(this._armature);
};
p.removeSlot = function (childSlot) {
if (!childSlot) {
throw new Error();
}
var index = this._slotList.indexOf(childSlot);
if (index < 0) {
throw new Error();
}
this._slotList.splice(index, 1);
childSlot._setParent(null);
childSlot.setArmature(null);
};
p._setArmature = function (value) {
if (this._armature == value) {
return;
}
if (this._armature) {
this._armature._removeBoneFromBoneList(this);
this._armature._updateAnimationAfterBoneListChanged(false);
}
this._armature = value;
if (this._armature) {
this._armature._addBoneToBoneList(this);
}
var i = this._boneList.length;
while (i--) {
this._boneList[i]._setArmature(this._armature);
}
i = this._slotList.length;
while (i--) {
this._slotList[i].setArmature(this._armature);
}
};
p.getBones = function (returnCopy) {
if (returnCopy === void 0) { returnCopy = true; }
return returnCopy ? this._boneList.concat() : this._boneList;
};
p.getSlots = function (returnCopy) {
if (returnCopy === void 0) { returnCopy = true; }
return returnCopy ? this._slotList.concat() : this._slotList;
};
p.invalidUpdate = function () {
this._needUpdate = 2;
};
p._calculateRelativeParentTransform = function () {
this._global.scaleX = this._origin.scaleX * this._tween.scaleX * this._offset.scaleX;
this._global.scaleY = this._origin.scaleY * this._tween.scaleY * this._offset.scaleY;
this._global.skewX = this._origin.skewX + this._tween.skewX + this._offset.skewX;
this._global.skewY = this._origin.skewY + this._tween.skewY + this._offset.skewY;
this._global.x = this._origin.x + this._tween.x + this._offset.x;
this._global.y = this._origin.y + this._tween.y + this._offset.y;
};
p._update = function (needUpdate) {
if (needUpdate === void 0) { needUpdate = false; }
this._needUpdate--;
if (needUpdate || this._needUpdate > 0 || (this._parent && this._parent._needUpdate > 0)) {
this._needUpdate = 1;
}
else {
return;
}
this.blendingTimeline();
var result = this._updateGlobal();
var parentGlobalTransform = result ? result.parentGlobalTransform : null;
var parentGlobalTransformMatrix = result ? result.parentGlobalTransformMatrix : null;
var ifExistOffsetTranslation = this._offset.x != 0 || this._offset.y != 0;
var ifExistOffsetScale = this._offset.scaleX != 0 || this._offset.scaleY != 0;
var ifExistOffsetRotation = this._offset.skewX != 0 || this._offset.skewY != 0;
if ((!ifExistOffsetTranslation || this.applyOffsetTranslationToChild) &&
(!ifExistOffsetScale || this.applyOffsetScaleToChild) &&
(!ifExistOffsetRotation || this.applyOffsetRotationToChild)) {
this._globalTransformForChild = this._global;
this._globalTransformMatrixForChild = this._globalTransformMatrix;
}
else {
if (!this._tempGlobalTransformForChild) {
this._tempGlobalTransformForChild = new dragonBones.DBTransform();
}
this._globalTransformForChild = this._tempGlobalTransformForChild;
if (!this._tempGlobalTransformMatrixForChild) {
this._tempGlobalTransformMatrixForChild = new dragonBones.Matrix();
}
this._globalTransformMatrixForChild = this._tempGlobalTransformMatrixForChild;
this._globalTransformForChild.x = this._origin.x + this._tween.x;
this._globalTransformForChild.y = this._origin.y + this._tween.y;
this._globalTransformForChild.scaleX = this._origin.scaleX * this._tween.scaleX;
this._globalTransformForChild.scaleY = this._origin.scaleY * this._tween.scaleY;
this._globalTransformForChild.skewX = this._origin.skewX + this._tween.skewX;
this._globalTransformForChild.skewY = this._origin.skewY + this._tween.skewY;
if (this.applyOffsetTranslationToChild) {
this._globalTransformForChild.x += this._offset.x;
this._globalTransformForChild.y += this._offset.y;
}
if (this.applyOffsetScaleToChild) {
this._globalTransformForChild.scaleX *= this._offset.scaleX;
this._globalTransformForChild.scaleY *= this._offset.scaleY;
}
if (this.applyOffsetRotationToChild) {
this._globalTransformForChild.skewX += this._offset.skewX;
this._globalTransformForChild.skewY += this._offset.skewY;
}
dragonBones.TransformUtil.transformToMatrix(this._globalTransformForChild, this._globalTransformMatrixForChild, true);
if (parentGlobalTransformMatrix) {
this._globalTransformMatrixForChild.concat(parentGlobalTransformMatrix);
dragonBones.TransformUtil.matrixToTransform(this._globalTransformMatrixForChild, this._globalTransformForChild, this._globalTransformForChild.scaleX * parentGlobalTransform.scaleX >= 0, this._globalTransformForChild.scaleY * parentGlobalTransform.scaleY >= 0);
}
}
};
p._updateColor = function (aOffset, rOffset, gOffset, bOffset, aMultiplier, rMultiplier, gMultiplier, bMultiplier, colorChanged) {
var length = this._slotList.length;
for (var i = 0; i < length; i++) {
var childSlot = this._slotList[i];
childSlot._updateDisplayColor(aOffset, rOffset, gOffset, bOffset, aMultiplier, rMultiplier, gMultiplier, bMultiplier);
}
this._isColorChanged = colorChanged;
};
p._hideSlots = function () {
var length = this._slotList.length;
for (var i = 0; i < length; i++) {
var childSlot = this._slotList[i];
childSlot._changeDisplay(-1);
}
};
p._arriveAtFrame = function (frame, timelineState, animationState, isCross) {
var displayControl = animationState.displayControl &&
(!this.displayController || this.displayController == animationState.name) &&
animationState.containsBoneMask(this.name);
if (displayControl) {
var tansformFrame = frame;
var displayIndex = tansformFrame.displayIndex;
var childSlot;
if (frame.event && this._armature.hasEventListener(dragonBones.FrameEvent.BONE_FRAME_EVENT)) {
var frameEvent = new dragonBones.FrameEvent(dragonBones.FrameEvent.BONE_FRAME_EVENT);
frameEvent.bone = this;
frameEvent.animationState = animationState;
frameEvent.frameLabel = frame.event;
this._armature._eventList.push(frameEvent);
}
if (frame.sound && Bone._soundManager.hasEventListener(dragonBones.SoundEvent.SOUND)) {
var soundEvent = new dragonBones.SoundEvent(dragonBones.SoundEvent.SOUND);
soundEvent.armature = this._armature;
soundEvent.animationState = animationState;
soundEvent.sound = frame.sound;
Bone._soundManager.dispatchEvent(soundEvent);
}
if (frame.action) {
var length1 = this._slotList.length;
for (var i1 = 0; i1 < length1; i1++) {
childSlot = this._slotList[i1];
var childArmature = childSlot.childArmature;
if (childArmature) {
childArmature.animation.gotoAndPlay(frame.action);
}
}
}
}
};
p._addState = function (timelineState) {
if (this._timelineStateList.indexOf(timelineState) < 0) {
this._timelineStateList.push(timelineState);
this._timelineStateList.sort(this.sortState);
}
};
p._removeState = function (timelineState) {
var index = this._timelineStateList.indexOf(timelineState);
if (index >= 0) {
this._timelineStateList.splice(index, 1);
}
};
p._removeAllStates = function () {
this._timelineStateList.length = 0;
};
p.blendingTimeline = function () {
var timelineState;
var transform;
var pivot;
var weight;
var i = this._timelineStateList.length;
if (i == 1) {
timelineState = this._timelineStateList[0];
weight = timelineState._animationState.weight * timelineState._animationState.fadeWeight;
timelineState._weight = weight;
transform = timelineState._transform;
pivot = timelineState._pivot;
this._tween.x = transform.x * weight;
this._tween.y = transform.y * weight;
this._tween.skewX = transform.skewX * weight;
this._tween.skewY = transform.skewY * weight;
this._tween.scaleX = 1 + (transform.scaleX - 1) * weight;
this._tween.scaleY = 1 + (transform.scaleY - 1) * weight;
this._tweenPivot.x = pivot.x * weight;
this._tweenPivot.y = pivot.y * weight;
}
else if (i > 1) {
var x = 0;
var y = 0;
var skewX = 0;
var skewY = 0;
var scaleX = 1;
var scaleY = 1;
var pivotX = 0;
var pivotY = 0;
var weigthLeft = 1;
var layerTotalWeight = 0;
var prevLayer = this._timelineStateList[i - 1]._animationState.layer;
var currentLayer = 0;
while (i--) {
timelineState = this._timelineStateList[i];
currentLayer = timelineState._animationState.layer;
if (prevLayer != currentLayer) {
if (layerTotalWeight >= weigthLeft) {
timelineState._weight = 0;
break;
}
else {
weigthLeft -= layerTotalWeight;
}
}
prevLayer = currentLayer;
weight = timelineState._animationState.weight * timelineState._animationState.fadeWeight * weigthLeft;
timelineState._weight = weight;
if (weight) {
transform = timelineState._transform;
pivot = timelineState._pivot;
x += transform.x * weight;
y += transform.y * weight;
skewX += transform.skewX * weight;
skewY += transform.skewY * weight;
scaleX += (transform.scaleX - 1) * weight;
scaleY += (transform.scaleY - 1) * weight;
pivotX += pivot.x * weight;
pivotY += pivot.y * weight;
layerTotalWeight += weight;
}
}
this._tween.x = x;
this._tween.y = y;
this._tween.skewX = skewX;
this._tween.skewY = skewY;
this._tween.scaleX = scaleX;
this._tween.scaleY = scaleY;
this._tweenPivot.x = pivotX;
this._tweenPivot.y = pivotY;
}
};
p.sortState = function (state1, state2) {
return state1._animationState.layer < state2._animationState.layer ? -1 : 1;
};
d(p, "childArmature"
,function () {
if (this.slot) {
return this.slot.childArmature;
}
return null;
}
);
d(p, "display"
,function () {
if (this.slot) {
return this.slot.display;
}
return null;
}
,function (value) {
if (this.slot) {
this.slot.display = value;
}
}
);
d(p, "node"
,function () {
return this._offset;
}
);
d(p, "visible",undefined
,function (value) {
if (this._visible != value) {
this._visible = value;
var length = this._slotList.length;
for (var i = 0; i < length; i++) {
var childSlot = this._slotList[i];
childSlot._updateDisplayVisible(this._visible);
}
}
}
);
d(p, "slot"
,function () {
return this._slotList.length > 0 ? this._slotList[0] : null;
}
);
Bone._soundManager = dragonBones.SoundEventManager.getInstance();
return Bone;
})(dragonBones.DBObject);
dragonBones.Bone = Bone;
egret.registerClass(Bone,'dragonBones.Bone');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Slot = (function (_super) {
__extends(Slot, _super);
function Slot(self) {
_super.call(this);
this._currentDisplayIndex = 0;
if (self != this) {
throw new Error(egret.getString(4001));
}
this._displayList = [];
this._timelineStateList = [];
this._currentDisplayIndex = -1;
this._originZOrder = 0;
this._tweenZOrder = 0;
this._offsetZOrder = 0;
this._isShowDisplay = false;
this._colorTransform = new dragonBones.ColorTransform();
this._displayDataList = null;
this._currentDisplay = null;
this.inheritRotation = true;
this.inheritScale = true;
}
var d = __define,c=Slot,p=c.prototype;
p.initWithSlotData = function (slotData) {
this.name = slotData.name;
this.blendMode = slotData.blendMode;
this._originZOrder = slotData.zOrder;
this._displayDataList = slotData.displayDataList;
this._originDisplayIndex = slotData.displayIndex;
};
p.dispose = function () {
if (!this._displayList) {
return;
}
_super.prototype.dispose.call(this);
this._displayList.length = 0;
this._displayDataList = null;
this._displayList = null;
this._currentDisplay = null;
};
p.sortState = function (state1, state2) {
return state1._animationState.layer < state2._animationState.layer ? -1 : 1;
};
p._addState = function (timelineState) {
if (this._timelineStateList.indexOf(timelineState) < 0) {
this._timelineStateList.push(timelineState);
this._timelineStateList.sort(this.sortState);
}
};
p._removeState = function (timelineState) {
var index = this._timelineStateList.indexOf(timelineState);
if (index >= 0) {
this._timelineStateList.splice(index, 1);
}
};
p.setArmature = function (value) {
if (this._armature == value) {
return;
}
if (this._armature) {
this._armature._removeSlotFromSlotList(this);
}
this._armature = value;
if (this._armature) {
this._armature._addSlotToSlotList(this);
this._armature._slotsZOrderChanged = true;
this._addDisplayToContainer(this._armature.display);
}
else {
this._removeDisplayFromContainer();
}
};
p._update = function () {
if (this._parent._needUpdate <= 0 && !this._needUpdate) {
return;
}
this._updateGlobal();
this._updateTransform();
this._needUpdate = false;
};
p._calculateRelativeParentTransform = function () {
this._global.scaleX = this._origin.scaleX * this._offset.scaleX;
this._global.scaleY = this._origin.scaleY * this._offset.scaleY;
this._global.skewX = this._origin.skewX + this._offset.skewX;
this._global.skewY = this._origin.skewY + this._offset.skewY;
this._global.x = this._origin.x + this._offset.x + this._parent._tweenPivot.x;
this._global.y = this._origin.y + this._offset.y + this._parent._tweenPivot.y;
};
p.updateChildArmatureAnimation = function () {
if (this.childArmature) {
if (this._isShowDisplay) {
if (this._armature &&
this._armature.animation.lastAnimationState &&
this.childArmature.animation.hasAnimation(this._armature.animation.lastAnimationState.name)) {
this.childArmature.animation.gotoAndPlay(this._armature.animation.lastAnimationState.name);
}
else {
this.childArmature.animation.play();
}
}
else {
this.childArmature.animation.stop();
this.childArmature.animation._lastAnimationState = null;
}
}
};
p._changeDisplay = function (displayIndex) {
if (displayIndex === void 0) { displayIndex = 0; }
if (displayIndex < 0) {
if (this._isShowDisplay) {
this._isShowDisplay = false;
this._removeDisplayFromContainer();
this.updateChildArmatureAnimation();
}
}
else if (this._displayList.length > 0) {
var length = this._displayList.length;
if (displayIndex >= length) {
displayIndex = length - 1;
}
if (this._currentDisplayIndex != displayIndex) {
this._isShowDisplay = true;
this._currentDisplayIndex = displayIndex;
this._updateSlotDisplay();
this.updateChildArmatureAnimation();
if (this._displayDataList &&
this._displayDataList.length > 0 &&
this._currentDisplayIndex < this._displayDataList.length) {
this._origin.copy(this._displayDataList[this._currentDisplayIndex].transform);
}
this._needUpdate = true;
}
else if (!this._isShowDisplay) {
this._isShowDisplay = true;
if (this._armature) {
this._armature._slotsZOrderChanged = true;
this._addDisplayToContainer(this._armature.display);
}
this.updateChildArmatureAnimation();
}
}
};
p._updateSlotDisplay = function () {
var currentDisplayIndex = -1;
if (this._currentDisplay) {
currentDisplayIndex = this._getDisplayIndex();
this._removeDisplayFromContainer();
}
var displayObj = this._displayList[this._currentDisplayIndex];
if (displayObj) {
if (displayObj instanceof dragonBones.Armature) {
this._currentDisplay = displayObj.display;
}
else {
this._currentDisplay = displayObj;
}
}
else {
this._currentDisplay = null;
}
this._updateDisplay(this._currentDisplay);
if (this._currentDisplay) {
if (this._armature && this._isShowDisplay) {
if (currentDisplayIndex < 0) {
this._armature._slotsZOrderChanged = true;
this._addDisplayToContainer(this._armature.display);
}
else {
this._addDisplayToContainer(this._armature.display, currentDisplayIndex);
}
}
this._updateDisplayBlendMode(this._blendMode);
this._updateDisplayColor(this._colorTransform.alphaOffset, this._colorTransform.redOffset, this._colorTransform.greenOffset, this._colorTransform.blueOffset, this._colorTransform.alphaMultiplier, this._colorTransform.redMultiplier, this._colorTransform.greenMultiplier, this._colorTransform.blueMultiplier, true);
this._updateDisplayVisible(this._visible);
this._updateTransform();
}
};
d(p, "visible",undefined
,function (value) {
if (this._visible != value) {
this._visible = value;
this._updateDisplayVisible(this._visible);
}
}
);
d(p, "displayList"
,function () {
return this._displayList;
}
,function (value) {
if (!value) {
throw new Error();
}
if (this._currentDisplayIndex < 0) {
this._currentDisplayIndex = 0;
}
var i = this._displayList.length = value.length;
while (i--) {
this._displayList[i] = value[i];
}
var displayIndexBackup = this._currentDisplayIndex;
this._currentDisplayIndex = -1;
this._changeDisplay(displayIndexBackup);
}
);
d(p, "display"
,function () {
return this._currentDisplay;
}
,function (value) {
if (this._currentDisplayIndex < 0) {
this._currentDisplayIndex = 0;
}
if (this._displayList[this._currentDisplayIndex] == value) {
return;
}
this._displayList[this._currentDisplayIndex] = value;
this._updateSlotDisplay();
this.updateChildArmatureAnimation();
this._updateTransform();
}
);
p.getDisplay = function () {
return this.display;
};
p.setDisplay = function (value) {
this.display = value;
};
d(p, "childArmature"
,function () {
if (this._displayList[this._currentDisplayIndex] instanceof dragonBones.Armature) {
return (this._displayList[this._currentDisplayIndex]);
}
return null;
}
,function (value) {
this.display = value;
}
);
d(p, "zOrder"
,function () {
return this._originZOrder + this._tweenZOrder + this._offsetZOrder;
}
,function (value) {
if (this.zOrder != value) {
this._offsetZOrder = value - this._originZOrder - this._tweenZOrder;
if (this._armature) {
this._armature._slotsZOrderChanged = true;
}
}
}
);
d(p, "blendMode"
,function () {
return this._blendMode;
}
,function (value) {
if (this._blendMode != value) {
this._blendMode = value;
this._updateDisplayBlendMode(this._blendMode);
}
}
);
p._updateDisplay = function (value) {
throw new Error("");
};
p._getDisplayIndex = function () {
throw new Error(egret.getString(4001));
};
p._addDisplayToContainer = function (container, index) {
if (index === void 0) { index = -1; }
throw new Error(egret.getString(4001));
};
p._removeDisplayFromContainer = function () {
throw new Error(egret.getString(4001));
};
p._updateTransform = function () {
throw new Error(egret.getString(4001));
};
p._updateDisplayVisible = function (value) {
throw new Error(egret.getString(4001));
};
p._updateDisplayColor = function (aOffset, rOffset, gOffset, bOffset, aMultiplier, rMultiplier, gMultiplier, bMultiplier, colorChanged) {
if (colorChanged === void 0) { colorChanged = false; }
this._colorTransform.alphaOffset = aOffset;
this._colorTransform.redOffset = rOffset;
this._colorTransform.greenOffset = gOffset;
this._colorTransform.blueOffset = bOffset;
this._colorTransform.alphaMultiplier = aMultiplier;
this._colorTransform.redMultiplier = rMultiplier;
this._colorTransform.greenMultiplier = gMultiplier;
this._colorTransform.blueMultiplier = bMultiplier;
this._isColorChanged = colorChanged;
};
p._updateDisplayBlendMode = function (value) {
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._arriveAtFrame = function (frame, timelineState, animationState, isCross) {
var displayControl = animationState.displayControl &&
animationState.containsBoneMask(this.parent.name);
if (displayControl) {
var slotFrame = frame;
var displayIndex = slotFrame.displayIndex;
var childSlot;
this._changeDisplay(displayIndex);
this._updateDisplayVisible(slotFrame.visible);
if (displayIndex >= 0) {
if (!isNaN(slotFrame.zOrder) && slotFrame.zOrder != this._tweenZOrder) {
this._tweenZOrder = slotFrame.zOrder;
this._armature._slotsZOrderChanged = true;
}
}
if (frame.action) {
if (this.childArmature) {
this.childArmature.animation.gotoAndPlay(frame.action);
}
}
}
};
p._updateGlobal = function () {
this._calculateRelativeParentTransform();
dragonBones.TransformUtil.transformToMatrix(this._global, this._globalTransformMatrix, true);
var output = this._calculateParentTransform();
if (output) {
this._globalTransformMatrix.concat(output.parentGlobalTransformMatrix);
dragonBones.TransformUtil.matrixToTransform(this._globalTransformMatrix, this._global, this._global.scaleX * output.parentGlobalTransform.scaleX >= 0, this._global.scaleY * output.parentGlobalTransform.scaleY >= 0);
}
return output;
};
p._resetToOrigin = function () {
this._changeDisplay(this._originDisplayIndex);
this._updateDisplayColor(0, 0, 0, 0, 1, 1, 1, 1, true);
};
return Slot;
})(dragonBones.DBObject);
dragonBones.Slot = Slot;
egret.registerClass(Slot,'dragonBones.Slot');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var AnimationCache = (function () {
function AnimationCache() {
this.slotTimelineCacheList = [];
this.slotTimelineCacheDic = {};
this.frameNum = 0;
}
var d = __define,c=AnimationCache,p=c.prototype;
AnimationCache.initWithAnimationData = function (animationData, armatureData) {
var output = new AnimationCache();
output.name = animationData.name;
var boneTimelineList = animationData.timelineList;
var boneName;
var boneData;
var slotData;
var slotTimelineCache;
var slotName;
for (var i = 0, length = boneTimelineList.length; i < length; i++) {
boneName = boneTimelineList[i].name;
for (var j = 0, jlen = armatureData.slotDataList.length; j < jlen; j++) {
slotData = armatureData.slotDataList[j];
slotName = slotData.name;
if (slotData.parent == boneName) {
if (output.slotTimelineCacheDic[slotName] == null) {
slotTimelineCache = new dragonBones.SlotTimelineCache();
slotTimelineCache.name = slotName;
output.slotTimelineCacheList.push(slotTimelineCache);
output.slotTimelineCacheDic[slotName] = slotTimelineCache;
}
}
}
}
return output;
};
p.initSlotTimelineCacheDic = function (slotCacheGeneratorDic, slotFrameCacheDic) {
var name;
for (var k in this.slotTimelineCacheDic) {
var slotTimelineCache = this.slotTimelineCacheDic[k];
name = slotTimelineCache.name;
slotTimelineCache.cacheGenerator = slotCacheGeneratorDic[name];
slotTimelineCache.currentFrameCache = slotFrameCacheDic[name];
}
};
p.bindCacheUserSlotDic = function (slotDic) {
for (var name in slotDic) {
(this.slotTimelineCacheDic[name]).bindCacheUser(slotDic[name]);
}
};
p.addFrame = function () {
this.frameNum++;
var slotTimelineCache;
for (var i = 0, length = this.slotTimelineCacheList.length; i < length; i++) {
slotTimelineCache = this.slotTimelineCacheList[i];
slotTimelineCache.addFrame();
}
};
p.update = function (progress) {
var frameIndex = Math.floor(progress * (this.frameNum - 1));
var slotTimelineCache;
for (var i = 0, length = this.slotTimelineCacheList.length; i < length; i++) {
slotTimelineCache = this.slotTimelineCacheList[i];
slotTimelineCache.update(frameIndex);
}
};
return AnimationCache;
})();
dragonBones.AnimationCache = AnimationCache;
egret.registerClass(AnimationCache,'dragonBones.AnimationCache');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var AnimationCacheManager = (function () {
function AnimationCacheManager() {
this.animationCacheDic = {};
this.slotFrameCacheDic = {};
}
var d = __define,c=AnimationCacheManager,p=c.prototype;
AnimationCacheManager.initWithArmatureData = function (armatureData, frameRate) {
if (frameRate === void 0) { frameRate = 0; }
var output = new AnimationCacheManager();
output.armatureData = armatureData;
if (frameRate <= 0) {
var animationData = armatureData.animationDataList[0];
if (animationData) {
output.frameRate = animationData.frameRate;
}
}
else {
output.frameRate = frameRate;
}
return output;
};
p.initAllAnimationCache = function () {
var length = this.armatureData.animationDataList.length;
for (var i = 0; i < length; i++) {
var animationData = this.armatureData.animationDataList[i];
this.animationCacheDic[animationData.name] = dragonBones.AnimationCache.initWithAnimationData(animationData, this.armatureData);
}
};
p.initAnimationCache = function (animationName) {
this.animationCacheDic[animationName] = dragonBones.AnimationCache.initWithAnimationData(this.armatureData.getAnimationData(animationName), this.armatureData);
};
p.bindCacheUserArmatures = function (armatures) {
var length = armatures.length;
for (var i = 0; i < length; i++) {
var armature = armatures[i];
this.bindCacheUserArmature(armature);
}
};
p.bindCacheUserArmature = function (armature) {
armature.animation.animationCacheManager = this;
var cacheUser;
for (var k in armature._slotDic) {
cacheUser = armature._slotDic[k];
cacheUser.frameCache = this.slotFrameCacheDic[cacheUser.name];
}
};
p.setCacheGeneratorArmature = function (armature) {
this.cacheGeneratorArmature = armature;
var cacheUser;
for (var slot in armature._slotDic) {
cacheUser = armature._slotDic[slot];
this.slotFrameCacheDic[cacheUser.name] = new dragonBones.SlotFrameCache();
}
for (var anim in this.animationCacheDic) {
var animationCache = this.animationCacheDic[anim];
animationCache.initSlotTimelineCacheDic(armature._slotDic, this.slotFrameCacheDic);
}
};
p.generateAllAnimationCache = function (loop) {
for (var anim in this.animationCacheDic) {
var animationCache = this.animationCacheDic[anim];
this.generateAnimationCache(animationCache.name, loop);
}
};
p.generateAnimationCache = function (animationName, loop) {
var temp = this.cacheGeneratorArmature.enableCache;
this.cacheGeneratorArmature.enableCache = false;
var animationCache = this.animationCacheDic[animationName];
if (!animationCache) {
return;
}
var animationState = this.cacheGeneratorArmature.getAnimation().animationState;
var passTime = 1 / this.frameRate;
if (loop) {
this.cacheGeneratorArmature.getAnimation().gotoAndPlay(animationName, 0, -1, 0);
}
else {
this.cacheGeneratorArmature.getAnimation().gotoAndPlay(animationName, 0, -1, 1);
}
var tempEnableEventDispatch = this.cacheGeneratorArmature.enableEventDispatch;
this.cacheGeneratorArmature.enableEventDispatch = false;
var lastProgress;
do {
lastProgress = animationState.progress;
this.cacheGeneratorArmature.advanceTime(passTime);
animationCache.addFrame();
} while (animationState.progress >= lastProgress && animationState.progress < 1);
this.cacheGeneratorArmature.enableEventDispatch = tempEnableEventDispatch;
this.resetCacheGeneratorArmature();
this.cacheGeneratorArmature.enableCache = temp;
};
p.resetCacheGeneratorArmature = function () {
this.cacheGeneratorArmature.resetAnimation();
};
p.getAnimationCache = function (animationName) {
return this.animationCacheDic[animationName];
};
return AnimationCacheManager;
})();
dragonBones.AnimationCacheManager = AnimationCacheManager;
egret.registerClass(AnimationCacheManager,'dragonBones.AnimationCacheManager');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FrameCache = (function () {
function FrameCache() {
this.globalTransform = new dragonBones.DBTransform();
this.globalTransformMatrix = new dragonBones.Matrix();
}
var d = __define,c=FrameCache,p=c.prototype;
p.copy = function (frameCache) {
this.globalTransform = frameCache.globalTransform;
this.globalTransformMatrix = frameCache.globalTransformMatrix;
};
p.clear = function () {
this.globalTransform = FrameCache.ORIGIN_TRAMSFORM;
this.globalTransformMatrix = FrameCache.ORIGIN_MATRIX;
};
FrameCache.ORIGIN_TRAMSFORM = new dragonBones.DBTransform();
FrameCache.ORIGIN_MATRIX = new dragonBones.Matrix();
return FrameCache;
})();
dragonBones.FrameCache = FrameCache;
egret.registerClass(FrameCache,'dragonBones.FrameCache');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SlotFrameCache = (function (_super) {
__extends(SlotFrameCache, _super);
function SlotFrameCache() {
_super.call(this);
this.displayIndex = -1;
}
var d = __define,c=SlotFrameCache,p=c.prototype;
p.copy = function (frameCache) {
_super.prototype.copy.call(this, frameCache);
this.colorTransform = frameCache.colorTransform;
this.displayIndex = frameCache.displayIndex;
};
p.clear = function () {
_super.prototype.clear.call(this);
this.colorTransform = null;
this.displayIndex = -1;
};
return SlotFrameCache;
})(dragonBones.FrameCache);
dragonBones.SlotFrameCache = SlotFrameCache;
egret.registerClass(SlotFrameCache,'dragonBones.SlotFrameCache');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var TimelineCache = (function () {
function TimelineCache() {
this.frameCacheList = new Array();
}
var d = __define,c=TimelineCache,p=c.prototype;
p.addFrame = function () {
};
p.update = function (frameIndex) {
if (frameIndex === void 0) { frameIndex = 0; }
this.currentFrameCache.copy(this.frameCacheList[frameIndex]);
};
p.bindCacheUser = function (cacheUser) {
cacheUser.frameCache = this.currentFrameCache;
};
return TimelineCache;
})();
dragonBones.TimelineCache = TimelineCache;
egret.registerClass(TimelineCache,'dragonBones.TimelineCache');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SlotTimelineCache = (function (_super) {
__extends(SlotTimelineCache, _super);
function SlotTimelineCache() {
_super.call(this);
}
var d = __define,c=SlotTimelineCache,p=c.prototype;
p.addFrame = function () {
var cache = new dragonBones.SlotFrameCache();
cache.globalTransform.copy(this.cacheGenerator.global);
cache.globalTransformMatrix.copyFrom(this.cacheGenerator.globalTransformMatrix);
if (this.cacheGenerator.colorChanged) {
cache.colorTransform = dragonBones.ColorTransformUtil.cloneColor(this.cacheGenerator.colorTransform);
}
cache.displayIndex = this.cacheGenerator.displayIndex;
this.frameCacheList.push(cache);
};
return SlotTimelineCache;
})(dragonBones.TimelineCache);
dragonBones.SlotTimelineCache = SlotTimelineCache;
egret.registerClass(SlotTimelineCache,'dragonBones.SlotTimelineCache');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Event = (function (_super) {
__extends(Event, _super);
function Event(type, bubbles, cancelable) {
if (bubbles === void 0) { bubbles = false; }
if (cancelable === void 0) { cancelable = false; }
_super.call(this, type, bubbles, cancelable);
}
var d = __define,c=Event,p=c.prototype;
return Event;
})(egret.Event);
dragonBones.Event = Event;
egret.registerClass(Event,'dragonBones.Event');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var AnimationEvent = (function (_super) {
__extends(AnimationEvent, _super);
function AnimationEvent(type, cancelable) {
if (cancelable === void 0) { cancelable = false; }
_super.call(this, type);
}
var d = __define,c=AnimationEvent,p=c.prototype;
d(AnimationEvent, "MOVEMENT_CHANGE"
,function () {
return AnimationEvent.FADE_IN;
}
);
d(p, "movementID"
,function () {
return this.animationName;
}
);
d(p, "armature"
,function () {
return (this.target);
}
);
d(p, "animationName"
,function () {
return this.animationState.name;
}
);
AnimationEvent.FADE_IN = "fadeIn";
AnimationEvent.FADE_OUT = "fadeOut";
AnimationEvent.START = "start";
AnimationEvent.COMPLETE = "complete";
AnimationEvent.LOOP_COMPLETE = "loopComplete";
AnimationEvent.FADE_IN_COMPLETE = "fadeInComplete";
AnimationEvent.FADE_OUT_COMPLETE = "fadeOutComplete";
return AnimationEvent;
})(dragonBones.Event);
dragonBones.AnimationEvent = AnimationEvent;
egret.registerClass(AnimationEvent,'dragonBones.AnimationEvent');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var ArmatureEvent = (function (_super) {
__extends(ArmatureEvent, _super);
function ArmatureEvent(type) {
_super.call(this, type);
}
var d = __define,c=ArmatureEvent,p=c.prototype;
ArmatureEvent.Z_ORDER_UPDATED = "zOrderUpdated";
return ArmatureEvent;
})(dragonBones.Event);
dragonBones.ArmatureEvent = ArmatureEvent;
egret.registerClass(ArmatureEvent,'dragonBones.ArmatureEvent');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FrameEvent = (function (_super) {
__extends(FrameEvent, _super);
function FrameEvent(type, cancelable) {
if (cancelable === void 0) { cancelable = false; }
_super.call(this, type);
}
var d = __define,c=FrameEvent,p=c.prototype;
d(FrameEvent, "MOVEMENT_FRAME_EVENT"
,function () {
return FrameEvent.ANIMATION_FRAME_EVENT;
}
);
d(p, "armature"
,function () {
return (this.target);
}
);
FrameEvent.ANIMATION_FRAME_EVENT = "animationFrameEvent";
FrameEvent.BONE_FRAME_EVENT = "boneFrameEvent";
return FrameEvent;
})(dragonBones.Event);
dragonBones.FrameEvent = FrameEvent;
egret.registerClass(FrameEvent,'dragonBones.FrameEvent');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SoundEvent = (function (_super) {
__extends(SoundEvent, _super);
function SoundEvent(type, cancelable) {
if (cancelable === void 0) { cancelable = false; }
_super.call(this, type);
}
var d = __define,c=SoundEvent,p=c.prototype;
SoundEvent.SOUND = "sound";
return SoundEvent;
})(dragonBones.Event);
dragonBones.SoundEvent = SoundEvent;
egret.registerClass(SoundEvent,'dragonBones.SoundEvent');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var BaseFactory = (function (_super) {
__extends(BaseFactory, _super);
function BaseFactory(self) {
_super.call(this);
this.dragonBonesDataDic = {};
this.textureAtlasDic = {};
if (self != this) {
throw new Error(egret.getString(4001));
}
}
var d = __define,c=BaseFactory,p=c.prototype;
p.dispose = function (disposeData) {
if (disposeData === void 0) { disposeData = true; }
if (disposeData) {
for (var skeletonName in this.dragonBonesDataDic) {
(this.dragonBonesDataDic[skeletonName]).dispose();
delete this.dragonBonesDataDic[skeletonName];
}
for (var textureAtlasName in this.textureAtlasDic) {
var textureAtlasArr = this.textureAtlasDic[textureAtlasName];
if (textureAtlasArr) {
for (var i = 0, len = textureAtlasArr.length; i < len; i++) {
textureAtlasArr[i].dispose();
}
}
delete this.textureAtlasDic[textureAtlasName];
}
}
this.dragonBonesDataDic = null;
this.textureAtlasDic = null;
};
p.getDragonBonesData = function (name) {
return this.dragonBonesDataDic[name];
};
p.getSkeletonData = function (name) {
return this.getDragonBonesData(name);
};
p.addDragonBonesData = function (data, name) {
if (name === void 0) { name = null; }
if (!data) {
throw new Error();
}
name = name || data.name;
if (!name) {
throw new Error(egret.getString(4002));
}
this.dragonBonesDataDic[name] = data;
};
p.addSkeletonData = function (data, name) {
if (name === void 0) { name = null; }
this.addDragonBonesData(data, name);
};
p.removeDragonBonesData = function (name) {
delete this.dragonBonesDataDic[name];
};
p.removeSkeletonData = function (name) {
delete this.dragonBonesDataDic[name];
};
p.getTextureAtlas = function (name) {
return this.textureAtlasDic[name];
};
p.addTextureAtlas = function (textureAtlas, name) {
if (name === void 0) { name = null; }
if (!textureAtlas) {
throw new Error();
}
if (!name && textureAtlas.hasOwnProperty("name")) {
name = textureAtlas.name;
}
if (!name) {
throw new Error(egret.getString(4002));
}
var textureAtlasArr = this.textureAtlasDic[name];
if (textureAtlasArr == null) {
textureAtlasArr = [];
this.textureAtlasDic[name] = textureAtlasArr;
}
if (textureAtlasArr.indexOf(textureAtlas) != -1) {
return;
}
textureAtlasArr.push(textureAtlas);
};
p.removeTextureAtlas = function (name) {
delete this.textureAtlasDic[name];
};
p.getTextureDisplay = function (textureName, textureAtlasName, pivotX, pivotY) {
if (textureAtlasName === void 0) { textureAtlasName = null; }
if (pivotX === void 0) { pivotX = NaN; }
if (pivotY === void 0) { pivotY = NaN; }
var targetTextureAtlas;
var textureAtlasArr;
var i;
var len;
if (textureAtlasName) {
textureAtlasArr = this.textureAtlasDic[textureAtlasName];
if (textureAtlasArr) {
for (i = 0, len = textureAtlasArr.length; i < len; i++) {
targetTextureAtlas = textureAtlasArr[i];
if (targetTextureAtlas.getRegion(textureName)) {
break;
}
targetTextureAtlas = null;
}
}
}
else {
for (textureAtlasName in this.textureAtlasDic) {
textureAtlasArr = this.textureAtlasDic[textureAtlasName];
if (textureAtlasArr) {
for (i = 0, len = textureAtlasArr.length; i < len; i++) {
targetTextureAtlas = textureAtlasArr[i];
if (targetTextureAtlas.getRegion(textureName)) {
break;
}
targetTextureAtlas = null;
}
if (targetTextureAtlas != null) {
break;
}
}
}
}
if (!targetTextureAtlas) {
return null;
}
if (isNaN(pivotX) || isNaN(pivotY)) {
var data = this.dragonBonesDataDic[textureAtlasName];
data = data ? data : this.findFirstDragonBonesData();
if (data) {
var displayData = data.getDisplayDataByName(textureName);
if (displayData) {
pivotX = displayData.pivot.x;
pivotY = displayData.pivot.y;
}
}
}
return this._generateDisplay(targetTextureAtlas, textureName, pivotX, pivotY);
};
p.buildArmature = function (armatureName, fromDragonBonesDataName, fromTextureAtlasName, skinName) {
if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; }
if (fromTextureAtlasName === void 0) { fromTextureAtlasName = null; }
if (skinName === void 0) { skinName = null; }
var buildArmatureDataPackage = {};
this.fillBuildArmatureDataPackageArmatureInfo(armatureName, fromDragonBonesDataName, buildArmatureDataPackage);
if (fromTextureAtlasName == null) {
fromTextureAtlasName = buildArmatureDataPackage.dragonBonesDataName;
}
var dragonBonesData = buildArmatureDataPackage.dragonBonesData;
var armatureData = buildArmatureDataPackage.armatureData;
if (!armatureData) {
return null;
}
return this.buildArmatureUsingArmatureDataFromTextureAtlas(dragonBonesData, armatureData, fromTextureAtlasName, skinName);
};
p.buildFastArmature = function (armatureName, fromDragonBonesDataName, fromTextureAtlasName, skinName) {
if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; }
if (fromTextureAtlasName === void 0) { fromTextureAtlasName = null; }
if (skinName === void 0) { skinName = null; }
var buildArmatureDataPackage = new BuildArmatureDataPackage();
this.fillBuildArmatureDataPackageArmatureInfo(armatureName, fromDragonBonesDataName, buildArmatureDataPackage);
if (fromTextureAtlasName == null) {
fromTextureAtlasName = buildArmatureDataPackage.dragonBonesDataName;
}
var dragonBonesData = buildArmatureDataPackage.dragonBonesData;
var armatureData = buildArmatureDataPackage.armatureData;
if (!armatureData) {
return null;
}
return this.buildFastArmatureUsingArmatureDataFromTextureAtlas(dragonBonesData, armatureData, fromTextureAtlasName, skinName);
};
p.buildArmatureUsingArmatureDataFromTextureAtlas = function (dragonBonesData, armatureData, textureAtlasName, skinName) {
if (skinName === void 0) { skinName = null; }
var outputArmature = this._generateArmature();
outputArmature.name = armatureData.name;
outputArmature.__dragonBonesData = dragonBonesData;
outputArmature._armatureData = armatureData;
outputArmature.animation.animationDataList = armatureData.animationDataList;
this._buildBones(outputArmature);
this._buildSlots(outputArmature, skinName, textureAtlasName);
outputArmature.advanceTime(0);
return outputArmature;
};
p.buildFastArmatureUsingArmatureDataFromTextureAtlas = function (dragonBonesData, armatureData, textureAtlasName, skinName) {
if (skinName === void 0) { skinName = null; }
var outputArmature = this._generateFastArmature();
outputArmature.name = armatureData.name;
outputArmature.__dragonBonesData = dragonBonesData;
outputArmature._armatureData = armatureData;
outputArmature.animation.animationDataList = armatureData.animationDataList;
this._buildFastBones(outputArmature);
this._buildFastSlots(outputArmature, skinName, textureAtlasName);
outputArmature.advanceTime(0);
return outputArmature;
};
p.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromDragonBonesDataName, ifRemoveOriginalAnimationList) {
if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; }
if (ifRemoveOriginalAnimationList === void 0) { ifRemoveOriginalAnimationList = true; }
var buildArmatureDataPackage = {};
if (!this.fillBuildArmatureDataPackageArmatureInfo(fromArmatreName, fromDragonBonesDataName, buildArmatureDataPackage)) {
return false;
}
var fromArmatureData = buildArmatureDataPackage.armatureData;
toArmature.animation.animationDataList = fromArmatureData.animationDataList;
var fromSkinData = fromArmatureData.getSkinData("");
var fromSlotData;
var fromDisplayData;
var toSlotList = toArmature.getSlots(false);
var toSlot;
var toSlotDisplayList;
var toSlotDisplayListLength = 0;
var toDisplayObject;
var toChildArmature;
var length1 = toSlotList.length;
for (var i1 = 0; i1 < length1; i1++) {
toSlot = toSlotList[i1];
toSlotDisplayList = toSlot.displayList;
toSlotDisplayListLength = toSlotDisplayList.length;
for (var i = 0; i < toSlotDisplayListLength; i++) {
toDisplayObject = toSlotDisplayList[i];
if (toDisplayObject instanceof dragonBones.Armature) {
toChildArmature = toDisplayObject;
fromSlotData = fromSkinData.getSlotData(toSlot.name);
fromDisplayData = fromSlotData.displayDataList[i];
if (fromDisplayData.type == dragonBones.DisplayData.ARMATURE) {
this.copyAnimationsToArmature(toChildArmature, fromDisplayData.name, buildArmatureDataPackage.dragonBonesDataName, ifRemoveOriginalAnimationList);
}
}
}
}
return true;
};
p.fillBuildArmatureDataPackageArmatureInfo = function (armatureName, dragonBonesDataName, outputBuildArmatureDataPackage) {
if (dragonBonesDataName) {
outputBuildArmatureDataPackage.dragonBonesDataName = dragonBonesDataName;
outputBuildArmatureDataPackage.dragonBonesData = this.dragonBonesDataDic[dragonBonesDataName];
outputBuildArmatureDataPackage.armatureData = outputBuildArmatureDataPackage.dragonBonesData.getArmatureDataByName(armatureName);
return true;
}
else {
for (dragonBonesDataName in this.dragonBonesDataDic) {
outputBuildArmatureDataPackage.dragonBonesData = this.dragonBonesDataDic[dragonBonesDataName];
outputBuildArmatureDataPackage.armatureData = outputBuildArmatureDataPackage.dragonBonesData.getArmatureDataByName(armatureName);
if (outputBuildArmatureDataPackage.armatureData) {
outputBuildArmatureDataPackage.dragonBonesDataName = dragonBonesDataName;
return true;
}
}
}
return false;
};
p.fillBuildArmatureDataPackageTextureInfo = function (fromTextureAtlasName, outputBuildArmatureDataPackage) {
outputBuildArmatureDataPackage.textureAtlas = this.textureAtlasDic[fromTextureAtlasName ? fromTextureAtlasName : outputBuildArmatureDataPackage.dragonBonesDataName];
};
p.findFirstDragonBonesData = function () {
for (var key in this.dragonBonesDataDic) {
var outputDragonBonesData = this.dragonBonesDataDic[key];
if (outputDragonBonesData) {
return outputDragonBonesData;
}
}
return null;
};
p.findFirstTextureAtlas = function () {
for (var key in this.textureAtlasDic) {
var outputTextureAtlas = this.textureAtlasDic[key];
if (outputTextureAtlas) {
return outputTextureAtlas;
}
}
return null;
};
p._buildBones = function (armature) {
var boneDataList = armature.armatureData.boneDataList;
var boneData;
var bone;
var parent;
for (var i = 0; i < boneDataList.length; i++) {
boneData = boneDataList[i];
bone = dragonBones.Bone.initWithBoneData(boneData);
parent = boneData.parent;
if (parent && armature.armatureData.getBoneData(parent) == null) {
parent = null;
}
armature.addBone(bone, parent, true);
}
armature._updateAnimationAfterBoneListChanged();
};
p._buildSlots = function (armature, skinName, textureAtlasName) {
var skinData = armature.armatureData.getSkinData(skinName);
if (!skinData) {
return;
}
armature.armatureData.setSkinData(skinName);
var displayList = [];
var slotDataList = armature.armatureData.slotDataList;
var slotData;
var slot;
var bone;
for (var i = 0; i < slotDataList.length; i++) {
slotData = slotDataList[i];
bone = armature.getBone(slotData.parent);
if (!bone) {
continue;
}
slot = this._generateSlot();
slot.initWithSlotData(slotData);
bone.addSlot(slot);
displayList.length = 0;
var l = slotData.displayDataList.length;
while (l--) {
var displayData = slotData.displayDataList[l];
switch (displayData.type) {
case dragonBones.DisplayData.ARMATURE:
var childArmature = this.buildArmatureUsingArmatureDataFromTextureAtlas(armature.__dragonBonesData, armature.__dragonBonesData.getArmatureDataByName(displayData.name), textureAtlasName, skinName);
displayList[l] = childArmature;
break;
case dragonBones.DisplayData.IMAGE:
default:
displayList[l] = this.getTextureDisplay(displayData.name, textureAtlasName, displayData.pivot.x, displayData.pivot.y);
break;
}
}
for (var j = 0, jLen = displayList.length; j < jLen; j++) {
var displayObject = displayList[j];
if (!displayObject) {
continue;
}
if (displayObject instanceof dragonBones.Armature) {
displayObject = displayObject.display;
}
if (displayObject.hasOwnProperty("name")) {
try {
displayObject["name"] = slot.name;
}
catch (err) {
}
}
}
slot.displayList = displayList;
slot._changeDisplay(slotData.displayIndex);
}
};
p._buildFastBones = function (armature) {
var boneDataList = armature.armatureData.boneDataList;
var boneData;
var bone;
for (var i = 0; i < boneDataList.length; i++) {
boneData = boneDataList[i];
bone = dragonBones.FastBone.initWithBoneData(boneData);
armature.addBone(bone, boneData.parent);
}
};
p._buildFastSlots = function (armature, skinName, textureAtlasName) {
var skinData = armature.armatureData.getSkinData(skinName);
if (!skinData) {
return;
}
armature.armatureData.setSkinData(skinName);
var displayList = [];
var slotDataList = armature.armatureData.slotDataList;
var slotData;
var slot;
for (var i = 0; i < slotDataList.length; i++) {
displayList.length = 0;
slotData = slotDataList[i];
slot = this._generateFastSlot();
slot.initWithSlotData(slotData);
var l = slotData.displayDataList.length;
while (l--) {
var displayData = slotData.displayDataList[l];
switch (displayData.type) {
case dragonBones.DisplayData.ARMATURE:
var childArmature = this.buildFastArmatureUsingArmatureDataFromTextureAtlas(armature.__dragonBonesData, armature.__dragonBonesData.getArmatureDataByName(displayData.name), textureAtlasName, skinName);
displayList[l] = childArmature;
slot.hasChildArmature = true;
break;
case dragonBones.DisplayData.IMAGE:
default:
displayList[l] = this.getTextureDisplay(displayData.name, textureAtlasName, displayData.pivot.x, displayData.pivot.y);
break;
}
}
var length1 = displayList.length;
for (var i1 = 0; i1 < length1; i1++) {
var displayObject = displayList[i1];
if (!displayObject) {
continue;
}
if (displayObject instanceof dragonBones.FastArmature) {
displayObject = displayObject.display;
}
if (displayObject.hasOwnProperty("name")) {
try {
displayObject["name"] = slot.name;
}
catch (err) {
}
}
}
slot.initDisplayList(displayList.concat());
armature.addSlot(slot, slotData.parent);
slot._changeDisplayIndex(slotData.displayIndex);
}
};
p._generateArmature = function () {
return null;
};
p._generateSlot = function () {
return null;
};
p._generateFastArmature = function () {
return null;
};
p._generateFastSlot = function () {
return null;
};
p._generateDisplay = function (textureAtlas, fullName, pivotX, pivotY) {
return null;
};
BaseFactory._helpMatrix = new dragonBones.Matrix();
return BaseFactory;
})(dragonBones.EventDispatcher);
dragonBones.BaseFactory = BaseFactory;
egret.registerClass(BaseFactory,'dragonBones.BaseFactory');
var BuildArmatureDataPackage = (function () {
function BuildArmatureDataPackage() {
}
var d = __define,c=BuildArmatureDataPackage,p=c.prototype;
return BuildArmatureDataPackage;
})();
dragonBones.BuildArmatureDataPackage = BuildArmatureDataPackage;
egret.registerClass(BuildArmatureDataPackage,'dragonBones.BuildArmatureDataPackage');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastArmature = (function (_super) {
__extends(FastArmature, _super);
function FastArmature(display) {
_super.call(this);
this.isCacheManagerExclusive = false;
this._enableEventDispatch = true;
this.useCache = true;
this._display = display;
this._animation = new dragonBones.FastAnimation(this);
this._slotsZOrderChanged = false;
this._armatureData = null;
this.boneList = [];
this._boneDic = {};
this.slotList = [];
this._slotDic = {};
this.slotHasChildArmatureList = [];
this._eventList = [];
this._delayDispose = false;
this._lockDispose = false;
}
var d = __define,c=FastArmature,p=c.prototype;
p.dispose = function () {
this._delayDispose = true;
if (!this._animation || this._lockDispose) {
return;
}
this.userData = null;
this._animation.dispose();
var i = this.slotList.length;
while (i--) {
this.slotList[i].dispose();
}
i = this.boneList.length;
while (i--) {
this.boneList[i].dispose();
}
this.slotList.length = 0;
this.boneList.length = 0;
this._armatureData = null;
this._animation = null;
this.slotList = null;
this.boneList = null;
this._eventList = null;
};
p.advanceTime = function (passedTime) {
this._lockDispose = true;
this._animation.advanceTime(passedTime);
var bone;
var slot;
var i = 0;
if (this._animation.animationState.isUseCache()) {
if (!this.useCache) {
this.useCache = true;
}
i = this.slotList.length;
while (i--) {
slot = this.slotList[i];
slot.updateByCache();
}
}
else {
if (this.useCache) {
this.useCache = false;
i = this.slotList.length;
while (i--) {
slot = this.slotList[i];
slot.switchTransformToBackup();
}
}
i = this.boneList.length;
while (i--) {
bone = this.boneList[i];
bone.update();
}
i = this.slotList.length;
while (i--) {
slot = this.slotList[i];
slot._update();
}
}
i = this.slotHasChildArmatureList.length;
while (i--) {
slot = this.slotHasChildArmatureList[i];
var childArmature = slot.childArmature;
if (childArmature) {
childArmature.advanceTime(passedTime);
}
}
if (this._slotsZOrderChanged) {
this.updateSlotsZOrder();
}
while (this._eventList.length > 0) {
this.dispatchEvent(this._eventList.shift());
}
this._lockDispose = false;
if (this._delayDispose) {
this.dispose();
}
};
p.enableAnimationCache = function (frameRate, animationList, loop) {
if (animationList === void 0) { animationList = null; }
if (loop === void 0) { loop = true; }
var animationCacheManager = dragonBones.AnimationCacheManager.initWithArmatureData(this.armatureData, frameRate);
if (animationList) {
var length = animationList.length;
for (var i = 0; i < length; i++) {
var animationName = animationList[i];
animationCacheManager.initAnimationCache(animationName);
}
}
else {
animationCacheManager.initAllAnimationCache();
}
animationCacheManager.setCacheGeneratorArmature(this);
animationCacheManager.generateAllAnimationCache(loop);
animationCacheManager.bindCacheUserArmature(this);
this.enableCache = true;
return animationCacheManager;
};
p.getBone = function (boneName) {
return this._boneDic[boneName];
};
p.getSlot = function (slotName) {
return this._slotDic[slotName];
};
p.getBoneByDisplay = function (display) {
var slot = this.getSlotByDisplay(display);
return slot ? slot.parent : null;
};
p.getSlotByDisplay = function (displayObj) {
if (displayObj) {
for (var i = 0, len = this.slotList.length; i < len; i++) {
if (this.slotList[i].display == displayObj) {
return this.slotList[i];
}
}
}
return null;
};
p.getSlots = function (returnCopy) {
if (returnCopy === void 0) { returnCopy = true; }
return returnCopy ? this.slotList.concat() : this.slotList;
};
p._updateBonesByCache = function () {
var i = this.boneList.length;
var bone;
while (i--) {
bone = this.boneList[i];
bone.update();
}
};
p.addBone = function (bone, parentName) {
if (parentName === void 0) { parentName = null; }
var parentBone;
if (parentName) {
parentBone = this.getBone(parentName);
parentBone.boneList.push(bone);
}
bone.armature = this;
bone.setParent(parentBone);
this.boneList.unshift(bone);
this._boneDic[bone.name] = bone;
};
p.addSlot = function (slot, parentBoneName) {
var bone = this.getBone(parentBoneName);
if (bone) {
slot.armature = this;
slot.setParent(bone);
bone.slotList.push(slot);
slot._addDisplayToContainer(this.display);
this.slotList.push(slot);
this._slotDic[slot.name] = slot;
if (slot.hasChildArmature) {
this.slotHasChildArmatureList.push(slot);
}
}
else {
throw new Error();
}
};
p.updateSlotsZOrder = function () {
this.slotList.sort(this.sortSlot);
var i = this.slotList.length;
while (i--) {
var slot = this.slotList[i];
if ((slot._frameCache && (slot._frameCache).displayIndex >= 0)
|| (!slot._frameCache && slot.displayIndex >= 0)) {
slot._addDisplayToContainer(this._display);
}
}
this._slotsZOrderChanged = false;
};
p.sortBoneList = function () {
var i = this.boneList.length;
if (i == 0) {
return;
}
var helpArray = [];
while (i--) {
var level = 0;
var bone = this.boneList[i];
var boneParent = bone;
while (boneParent) {
level++;
boneParent = boneParent.parent;
}
helpArray[i] = [level, bone];
}
helpArray.sort(dragonBones.ArmatureData.sortBoneDataHelpArrayDescending);
i = helpArray.length;
while (i--) {
this.boneList[i] = helpArray[i][1];
}
helpArray.length = 0;
};
p.arriveAtFrame = function (frame, animationState) {
if (frame.event && this.hasEventListener(dragonBones.FrameEvent.ANIMATION_FRAME_EVENT)) {
var frameEvent = new dragonBones.FrameEvent(dragonBones.FrameEvent.ANIMATION_FRAME_EVENT);
frameEvent.animationState = animationState;
frameEvent.frameLabel = frame.event;
this._addEvent(frameEvent);
}
if (frame.action) {
this.animation.gotoAndPlay(frame.action);
}
};
p.invalidUpdate = function (boneName) {
if (boneName === void 0) { boneName = null; }
if (boneName) {
var bone = this.getBone(boneName);
if (bone) {
bone.invalidUpdate();
}
}
else {
var i = this.boneList.length;
while (i--) {
this.boneList[i].invalidUpdate();
}
}
};
p.resetAnimation = function () {
this.animation.animationState._resetTimelineStateList();
var length = this.boneList.length;
for (var i = 0; i < length; i++) {
var boneItem = this.boneList[i];
boneItem._timelineState = null;
}
this.animation.stop();
};
p.sortSlot = function (slot1, slot2) {
return slot1.zOrder < slot2.zOrder ? 1 : -1;
};
p.getAnimation = function () {
return this._animation;
};
d(p, "armatureData"
,function () {
return this._armatureData;
}
);
d(p, "animation"
,function () {
return this._animation;
}
);
d(p, "display"
,function () {
return this._display;
}
);
d(p, "enableCache"
,function () {
return this._enableCache;
}
,function (value) {
this._enableCache = value;
}
);
d(p, "enableEventDispatch"
,function () {
return this._enableEventDispatch;
}
,function (value) {
this._enableEventDispatch = value;
}
);
p._addEvent = function (event) {
if (this._enableEventDispatch) {
this._eventList.push(event);
}
};
return FastArmature;
})(dragonBones.EventDispatcher);
dragonBones.FastArmature = FastArmature;
egret.registerClass(FastArmature,'dragonBones.FastArmature',["dragonBones.ICacheableArmature","dragonBones.IArmature","dragonBones.IAnimatable"]);
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastDBObject = (function () {
function FastDBObject() {
this._globalTransformMatrix = new dragonBones.Matrix();
this._global = new dragonBones.DBTransform();
this._origin = new dragonBones.DBTransform();
this._visible = true;
this.armature = null;
this._parent = null;
this.userData = null;
this.inheritRotation = true;
this.inheritScale = true;
this.inheritTranslation = true;
}
var d = __define,c=FastDBObject,p=c.prototype;
p.updateByCache = function () {
this._global = this._frameCache.globalTransform;
this._globalTransformMatrix = this._frameCache.globalTransformMatrix;
};
p.switchTransformToBackup = function () {
if (!this._globalBackup) {
this._globalBackup = new dragonBones.DBTransform();
this._globalTransformMatrixBackup = new dragonBones.Matrix();
}
this._global = this._globalBackup;
this._globalTransformMatrix = this._globalTransformMatrixBackup;
};
p.setParent = function (value) {
this._parent = value;
};
p.dispose = function () {
this.userData = null;
this._globalTransformMatrix = null;
this._global = null;
this._origin = null;
this.armature = null;
this._parent = null;
};
p._calculateParentTransform = function () {
if (this.parent && (this.inheritTranslation || this.inheritRotation || this.inheritScale)) {
var parentGlobalTransform = this._parent._global;
var parentGlobalTransformMatrix = this._parent._globalTransformMatrix;
if (!this.inheritTranslation && (parentGlobalTransform.x != 0 || parentGlobalTransform.y != 0) ||
!this.inheritRotation && (parentGlobalTransform.skewX != 0 || parentGlobalTransform.skewY != 0) ||
!this.inheritScale && (parentGlobalTransform.scaleX != 1 || parentGlobalTransform.scaleY != 1)) {
parentGlobalTransform = FastDBObject._tempParentGlobalTransform;
parentGlobalTransform.copy(this._parent._global);
if (!this.inheritTranslation) {
parentGlobalTransform.x = 0;
parentGlobalTransform.y = 0;
}
if (!this.inheritScale) {
parentGlobalTransform.scaleX = 1;
parentGlobalTransform.scaleY = 1;
}
if (!this.inheritRotation) {
parentGlobalTransform.skewX = 0;
parentGlobalTransform.skewY = 0;
}
parentGlobalTransformMatrix = dragonBones.DBObject._tempParentGlobalTransformMatrix;
dragonBones.TransformUtil.transformToMatrix(parentGlobalTransform, parentGlobalTransformMatrix);
}
FastDBObject.tempOutputObj.parentGlobalTransform = parentGlobalTransform;
FastDBObject.tempOutputObj.parentGlobalTransformMatrix = parentGlobalTransformMatrix;
return FastDBObject.tempOutputObj;
}
return null;
};
p._updateGlobal = function () {
this._calculateRelativeParentTransform();
var output = this._calculateParentTransform();
if (output != null) {
var parentMatrix = output.parentGlobalTransformMatrix;
var parentGlobalTransform = output.parentGlobalTransform;
var x = this._global.x;
var y = this._global.y;
this._global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx;
this._global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty;
if (this.inheritRotation) {
this._global.skewX += parentGlobalTransform.skewX;
this._global.skewY += parentGlobalTransform.skewY;
}
if (this.inheritScale) {
this._global.scaleX *= parentGlobalTransform.scaleX;
this._global.scaleY *= parentGlobalTransform.scaleY;
}
}
dragonBones.TransformUtil.transformToMatrix(this._global, this._globalTransformMatrix, true);
return output;
};
p._calculateRelativeParentTransform = function () {
};
d(p, "name"
,function () {
return this._name;
}
,function (value) {
this._name = value;
}
);
d(p, "global"
,function () {
return this._global;
}
);
d(p, "globalTransformMatrix"
,function () {
return this._globalTransformMatrix;
}
);
d(p, "origin"
,function () {
return this._origin;
}
);
d(p, "parent"
,function () {
return this._parent;
}
);
d(p, "visible"
,function () {
return this._visible;
}
,function (value) {
this._visible = value;
}
);
d(p, "frameCache",undefined
,function (cache) {
this._frameCache = cache;
}
);
FastDBObject._tempParentGlobalTransform = new dragonBones.DBTransform();
FastDBObject.tempOutputObj = {};
return FastDBObject;
})();
dragonBones.FastDBObject = FastDBObject;
egret.registerClass(FastDBObject,'dragonBones.FastDBObject');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastBone = (function (_super) {
__extends(FastBone, _super);
function FastBone() {
_super.call(this);
this.slotList = [];
this.boneList = [];
this._needUpdate = 0;
this._needUpdate = 2;
this._tweenPivot = new dragonBones.Point();
}
var d = __define,c=FastBone,p=c.prototype;
FastBone.initWithBoneData = function (boneData) {
var outputBone = new FastBone();
outputBone.name = boneData.name;
outputBone.inheritRotation = boneData.inheritRotation;
outputBone.inheritScale = boneData.inheritScale;
outputBone.origin.copy(boneData.transform);
return outputBone;
};
p.getBones = function (returnCopy) {
if (returnCopy === void 0) { returnCopy = true; }
return returnCopy ? this.boneList.concat() : this.boneList;
};
p.getSlots = function (returnCopy) {
if (returnCopy === void 0) { returnCopy = true; }
return returnCopy ? this.slotList.concat() : this.slotList;
};
p.dispose = function () {
_super.prototype.dispose.call(this);
this._timelineState = null;
this._tweenPivot = null;
};
p.invalidUpdate = function () {
this._needUpdate = 2;
};
p._calculateRelativeParentTransform = function () {
this._global.copy(this._origin);
if (this._timelineState) {
this._global.add(this._timelineState._transform);
}
};
p.updateByCache = function () {
_super.prototype.updateByCache.call(this);
this._global = this._frameCache.globalTransform;
this._globalTransformMatrix = this._frameCache.globalTransformMatrix;
};
p.update = function (needUpdate) {
if (needUpdate === void 0) { needUpdate = false; }
this._needUpdate--;
if (needUpdate || this._needUpdate > 0 || (this._parent && this._parent._needUpdate > 0)) {
this._needUpdate = 1;
}
else {
return;
}
this.blendingTimeline();
this._updateGlobal();
};
p._hideSlots = function () {
var length = this.slotList.length;
for (var i = 0; i < length; i++) {
var childSlot = this.slotList[i];
childSlot.hideSlots();
}
};
p.blendingTimeline = function () {
if (this._timelineState) {
this._tweenPivot.x = this._timelineState._pivot.x;
this._tweenPivot.y = this._timelineState._pivot.y;
}
};
p.arriveAtFrame = function (frame, animationState) {
var childSlot;
if (frame.event && this.armature.hasEventListener(dragonBones.FrameEvent.BONE_FRAME_EVENT)) {
var frameEvent = new dragonBones.FrameEvent(dragonBones.FrameEvent.BONE_FRAME_EVENT);
frameEvent.bone = this;
frameEvent.animationState = animationState;
frameEvent.frameLabel = frame.event;
this.armature._addEvent(frameEvent);
}
};
d(p, "childArmature"
,function () {
var s = this.slot;
if (s) {
return s.childArmature;
}
return null;
}
);
d(p, "display"
,function () {
var s = this.slot;
if (s) {
return s.display;
}
return null;
}
,function (value) {
var s = this.slot;
if (s) {
s.display = value;
}
}
);
d(p, "visible",undefined
,function (value) {
if (this._visible != value) {
this._visible = value;
for (var i = 0, len = this.armature.slotList.length; i < len; i++) {
if (this.armature.slotList[i].parent == this) {
this.armature.slotList[i]._updateDisplayVisible(this._visible);
}
}
}
}
);
d(p, "slot"
,function () {
return this.slotList.length > 0 ? this.slotList[0] : null;
}
);
return FastBone;
})(dragonBones.FastDBObject);
dragonBones.FastBone = FastBone;
egret.registerClass(FastBone,'dragonBones.FastBone');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastSlot = (function (_super) {
__extends(FastSlot, _super);
function FastSlot(self) {
_super.call(this);
this._currentDisplayIndex = 0;
if (self != this) {
throw new Error("Abstract class can not be instantiated!");
}
this.hasChildArmature = false;
this._currentDisplayIndex = -1;
this._originZOrder = 0;
this._tweenZOrder = 0;
this._offsetZOrder = 0;
this._colorTransform = new dragonBones.ColorTransform();
this._isColorChanged = false;
this._displayDataList = null;
this._currentDisplay = null;
this.inheritRotation = true;
this.inheritScale = true;
}
var d = __define,c=FastSlot,p=c.prototype;
p.initWithSlotData = function (slotData) {
this.name = slotData.name;
this.blendMode = slotData.blendMode;
this._originZOrder = slotData.zOrder;
this._displayDataList = slotData.displayDataList;
this._originDisplayIndex = slotData.displayIndex;
};
p.dispose = function () {
if (!this._displayList) {
return;
}
_super.prototype.dispose.call(this);
this._displayDataList = null;
this._displayList = null;
this._currentDisplay = null;
};
p.updateByCache = function () {
_super.prototype.updateByCache.call(this);
this._updateTransform();
var cacheColor = (this._frameCache).colorTransform;
var cacheColorChanged = cacheColor != null;
if (this.colorChanged != cacheColorChanged ||
(this.colorChanged && cacheColorChanged && !dragonBones.ColorTransformUtil.isEqual(this._colorTransform, cacheColor))) {
cacheColor = cacheColor || dragonBones.ColorTransformUtil.originalColor;
this._updateDisplayColor(cacheColor.alphaOffset, cacheColor.redOffset, cacheColor.greenOffset, cacheColor.blueOffset, cacheColor.alphaMultiplier, cacheColor.redMultiplier, cacheColor.greenMultiplier, cacheColor.blueMultiplier, cacheColorChanged);
}
this._changeDisplayIndex((this._frameCache).displayIndex);
};
p._update = function () {
if (this._parent._needUpdate <= 0) {
return;
}
this._updateGlobal();
this._updateTransform();
};
p._calculateRelativeParentTransform = function () {
this._global.copy(this._origin);
this._global.x += this._parent._tweenPivot.x;
this._global.y += this._parent._tweenPivot.y;
};
p.initDisplayList = function (newDisplayList) {
this._displayList = newDisplayList;
};
p.clearCurrentDisplay = function () {
if (this.hasChildArmature) {
var targetArmature = this.childArmature;
if (targetArmature) {
targetArmature.resetAnimation();
}
}
var slotIndex = this._getDisplayIndex();
this._removeDisplayFromContainer();
return slotIndex;
};
p._changeDisplayIndex = function (displayIndex) {
if (displayIndex === void 0) { displayIndex = 0; }
if (this._currentDisplayIndex == displayIndex) {
return;
}
var slotIndex = -1;
if (this._currentDisplayIndex >= 0) {
slotIndex = this.clearCurrentDisplay();
}
this._currentDisplayIndex = displayIndex;
if (this._currentDisplayIndex >= 0) {
this._origin.copy(this._displayDataList[this._currentDisplayIndex].transform);
this.initCurrentDisplay(slotIndex);
}
};
p.changeSlotDisplay = function (value) {
var slotIndex = this.clearCurrentDisplay();
this._displayList[this._currentDisplayIndex] = value;
this.initCurrentDisplay(slotIndex);
};
p.initCurrentDisplay = function (slotIndex) {
if (slotIndex === void 0) { slotIndex = 0; }
var display = this._displayList[this._currentDisplayIndex];
if (display) {
if (display instanceof dragonBones.FastArmature) {
this._currentDisplay = display.display;
}
else {
this._currentDisplay = display;
}
}
else {
this._currentDisplay = null;
}
this._updateDisplay(this._currentDisplay);
if (this._currentDisplay) {
if (slotIndex != -1) {
this._addDisplayToContainer(this.armature.display, slotIndex);
}
else {
this.armature._slotsZOrderChanged = true;
this._addDisplayToContainer(this.armature.display);
}
if (this._blendMode) {
this._updateDisplayBlendMode(this._blendMode);
}
if (this._isColorChanged) {
this._updateDisplayColor(this._colorTransform.alphaOffset, this._colorTransform.redOffset, this._colorTransform.greenOffset, this._colorTransform.blueOffset, this._colorTransform.alphaMultiplier, this._colorTransform.redMultiplier, this._colorTransform.greenMultiplier, this._colorTransform.blueMultiplier, true);
}
this._updateTransform();
if (display instanceof dragonBones.FastArmature) {
var targetArmature = (display);
if (this.armature &&
this.armature.animation.animationState &&
targetArmature.animation.hasAnimation(this.armature.animation.animationState.name)) {
targetArmature.animation.gotoAndPlay(this.armature.animation.animationState.name);
}
else {
targetArmature.animation.play();
}
}
}
};
d(p, "visible",undefined
,function (value) {
if (this._visible != value) {
this._visible = value;
this._updateDisplayVisible(this._visible);
}
}
);
d(p, "displayList"
,function () {
return this._displayList;
}
,function (value) {
if (!value) {
throw new Error();
}
var newDisplay = value[this._currentDisplayIndex];
var displayChanged = this._currentDisplayIndex >= 0 && this._displayList[this._currentDisplayIndex] != newDisplay;
this._displayList = value;
if (displayChanged) {
this.changeSlotDisplay(newDisplay);
}
}
);
d(p, "display"
,function () {
return this._currentDisplay;
}
,function (value) {
if (this._currentDisplayIndex < 0) {
return;
}
if (this._displayList[this._currentDisplayIndex] == value) {
return;
}
this.changeSlotDisplay(value);
}
);
d(p, "childArmature"
,function () {
return (this._displayList[this._currentDisplayIndex] instanceof dragonBones.Armature
|| this._displayList[this._currentDisplayIndex] instanceof dragonBones.FastArmature) ? this._displayList[this._currentDisplayIndex] : null;
}
,function (value) {
this.display = value;
}
);
d(p, "zOrder"
,function () {
return this._originZOrder + this._tweenZOrder + this._offsetZOrder;
}
,function (value) {
if (this.zOrder != value) {
this._offsetZOrder = value - this._originZOrder - this._tweenZOrder;
if (this.armature) {
this.armature._slotsZOrderChanged = true;
}
}
}
);
d(p, "blendMode"
,function () {
return this._blendMode;
}
,function (value) {
if (this._blendMode != value) {
this._blendMode = value;
this._updateDisplayBlendMode(this._blendMode);
}
}
);
d(p, "colorTransform"
,function () {
return this._colorTransform;
}
);
d(p, "displayIndex"
,function () {
return this._currentDisplayIndex;
}
);
d(p, "colorChanged"
,function () {
return this._isColorChanged;
}
);
p._updateDisplay = function (value) {
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._getDisplayIndex = function () {
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._addDisplayToContainer = function (container, index) {
if (index === void 0) { index = -1; }
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._removeDisplayFromContainer = function () {
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._updateTransform = function () {
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._updateDisplayVisible = function (value) {
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._updateDisplayColor = function (aOffset, rOffset, gOffset, bOffset, aMultiplier, rMultiplier, gMultiplier, bMultiplier, colorChanged) {
if (colorChanged === void 0) { colorChanged = false; }
this._colorTransform.alphaOffset = aOffset;
this._colorTransform.redOffset = rOffset;
this._colorTransform.greenOffset = gOffset;
this._colorTransform.blueOffset = bOffset;
this._colorTransform.alphaMultiplier = aMultiplier;
this._colorTransform.redMultiplier = rMultiplier;
this._colorTransform.greenMultiplier = gMultiplier;
this._colorTransform.blueMultiplier = bMultiplier;
this._isColorChanged = colorChanged;
};
p._updateDisplayBlendMode = function (value) {
throw new Error("Abstract method needs to be implemented in subclass!");
};
p._arriveAtFrame = function (frame, animationState) {
var slotFrame = frame;
var displayIndex = slotFrame.displayIndex;
this._changeDisplayIndex(displayIndex);
this._updateDisplayVisible(slotFrame.visible);
if (displayIndex >= 0) {
if (!isNaN(slotFrame.zOrder) && slotFrame.zOrder != this._tweenZOrder) {
this._tweenZOrder = slotFrame.zOrder;
this.armature._slotsZOrderChanged = true;
}
}
if (frame.action) {
var targetArmature = this.childArmature;
if (targetArmature) {
targetArmature.getAnimation().gotoAndPlay(frame.action);
}
}
};
p.hideSlots = function () {
this._changeDisplayIndex(-1);
this._removeDisplayFromContainer();
if (this._frameCache) {
this._frameCache.clear();
}
};
p._updateGlobal = function () {
this._calculateRelativeParentTransform();
dragonBones.TransformUtil.transformToMatrix(this._global, this._globalTransformMatrix, true);
var output = this._calculateParentTransform();
if (output) {
this._globalTransformMatrix.concat(output.parentGlobalTransformMatrix);
dragonBones.TransformUtil.matrixToTransform(this._globalTransformMatrix, this._global, this._global.scaleX * output.parentGlobalTransform.scaleX >= 0, this._global.scaleY * output.parentGlobalTransform.scaleY >= 0);
}
return output;
};
p._resetToOrigin = function () {
this._changeDisplayIndex(this._originDisplayIndex);
this._updateDisplayColor(0, 0, 0, 0, 1, 1, 1, 1, true);
};
return FastSlot;
})(dragonBones.FastDBObject);
dragonBones.FastSlot = FastSlot;
egret.registerClass(FastSlot,'dragonBones.FastSlot',["dragonBones.ISlotCacheGenerator","dragonBones.ICacheUser"]);
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Point = (function () {
function Point(x, y) {
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
this.x = x;
this.y = y;
}
var d = __define,c=Point,p=c.prototype;
p.toString = function () {
return "[Point (x=" + this.x + " y=" + this.y + ")]";
};
return Point;
})();
dragonBones.Point = Point;
egret.registerClass(Point,'dragonBones.Point');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Rectangle = (function () {
function Rectangle(x, y, width, height) {
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
if (width === void 0) { width = 0; }
if (height === void 0) { height = 0; }
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
var d = __define,c=Rectangle,p=c.prototype;
return Rectangle;
})();
dragonBones.Rectangle = Rectangle;
egret.registerClass(Rectangle,'dragonBones.Rectangle');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Data3Parser = (function () {
function Data3Parser() {
}
var d = __define,c=Data3Parser,p=c.prototype;
Data3Parser.parseDragonBonesData = function (rawDataToParse) {
if (!rawDataToParse) {
throw new Error();
}
var version = rawDataToParse[dragonBones.ConstValues.A_VERSION];
version = version.toString();
if (version.toString() != dragonBones.DragonBones.DATA_VERSION &&
version.toString() != dragonBones.DragonBones.PARENT_COORDINATE_DATA_VERSION &&
version.toString() != "2.3") {
throw new Error("Nonsupport version!");
}
var frameRate = Data3Parser.getNumber(rawDataToParse, dragonBones.ConstValues.A_FRAME_RATE, 0) || 0;
var outputDragonBonesData = new dragonBones.DragonBonesData();
outputDragonBonesData.name = rawDataToParse[dragonBones.ConstValues.A_NAME];
outputDragonBonesData.isGlobal = rawDataToParse[dragonBones.ConstValues.A_IS_GLOBAL] == "0" ? false : true;
Data3Parser.tempDragonBonesData = outputDragonBonesData;
var armatureList = rawDataToParse[dragonBones.ConstValues.ARMATURE];
for (var i = 0, len = armatureList.length; i < len; i++) {
var armatureObject = armatureList[i];
outputDragonBonesData.addArmatureData(Data3Parser.parseArmatureData(armatureObject, frameRate));
}
Data3Parser.tempDragonBonesData = null;
return outputDragonBonesData;
};
Data3Parser.parseArmatureData = function (armatureDataToParse, frameRate) {
var outputArmatureData = new dragonBones.ArmatureData();
outputArmatureData.name = armatureDataToParse[dragonBones.ConstValues.A_NAME];
var i;
var len;
var boneList = armatureDataToParse[dragonBones.ConstValues.BONE];
for (i = 0, len = boneList.length; i < len; i++) {
var boneObject = boneList[i];
outputArmatureData.addBoneData(Data3Parser.parseBoneData(boneObject));
}
var skinList = armatureDataToParse[dragonBones.ConstValues.SKIN];
for (i = 0, len = skinList.length; i < len; i++) {
var skinSlotList = skinList[i];
var skinSlotObject = skinSlotList[dragonBones.ConstValues.SLOT];
for (var j = 0, jLen = skinSlotObject.length; j < jLen; j++) {
var slotObject = skinSlotObject[j];
outputArmatureData.addSlotData(Data3Parser.parseSlotData(slotObject));
}
}
for (i = 0, len = skinList.length; i < len; i++) {
var skinObject = skinList[i];
outputArmatureData.addSkinData(Data3Parser.parseSkinData(skinObject));
}
if (Data3Parser.tempDragonBonesData.isGlobal) {
dragonBones.DBDataUtil.transformArmatureData(outputArmatureData);
}
outputArmatureData.sortBoneDataList();
var animationList = armatureDataToParse[dragonBones.ConstValues.ANIMATION];
for (i = 0, len = animationList.length; i < len; i++) {
var animationObject = animationList[i];
var animationData = Data3Parser.parseAnimationData(animationObject, frameRate);
dragonBones.DBDataUtil.addHideTimeline(animationData, outputArmatureData);
dragonBones.DBDataUtil.transformAnimationData(animationData, outputArmatureData, Data3Parser.tempDragonBonesData.isGlobal);
outputArmatureData.addAnimationData(animationData);
}
return outputArmatureData;
};
Data3Parser.parseBoneData = function (boneObject) {
var boneData = new dragonBones.BoneData();
boneData.name = boneObject[dragonBones.ConstValues.A_NAME];
boneData.parent = boneObject[dragonBones.ConstValues.A_PARENT];
boneData.length = Number(boneObject[dragonBones.ConstValues.A_LENGTH]) || 0;
boneData.inheritRotation = Data3Parser.getBoolean(boneObject, dragonBones.ConstValues.A_INHERIT_ROTATION, true);
boneData.inheritScale = Data3Parser.getBoolean(boneObject, dragonBones.ConstValues.A_INHERIT_SCALE, true);
Data3Parser.parseTransform(boneObject[dragonBones.ConstValues.TRANSFORM], boneData.transform);
if (Data3Parser.tempDragonBonesData.isGlobal) {
boneData.global.copy(boneData.transform);
}
return boneData;
};
Data3Parser.parseSkinData = function (skinObject) {
var skinData = new dragonBones.SkinData();
skinData.name = skinObject[dragonBones.ConstValues.A_NAME];
var slotList = skinObject[dragonBones.ConstValues.SLOT];
for (var i = 0, len = slotList.length; i < len; i++) {
var slotObject = slotList[i];
skinData.addSlotData(Data3Parser.parseSkinSlotData(slotObject));
}
return skinData;
};
Data3Parser.parseSkinSlotData = function (slotObject) {
var slotData = new dragonBones.SlotData();
slotData.name = slotObject[dragonBones.ConstValues.A_NAME];
slotData.parent = slotObject[dragonBones.ConstValues.A_PARENT];
slotData.zOrder = (slotObject[dragonBones.ConstValues.A_Z_ORDER]);
slotData.zOrder = Data3Parser.getNumber(slotObject, dragonBones.ConstValues.A_Z_ORDER, 0) || 0;
slotData.blendMode = slotObject[dragonBones.ConstValues.A_BLENDMODE];
var displayList = slotObject[dragonBones.ConstValues.DISPLAY];
if (displayList) {
for (var i = 0, len = displayList.length; i < len; i++) {
var displayObject = displayList[i];
slotData.addDisplayData(Data3Parser.parseDisplayData(displayObject));
}
}
return slotData;
};
Data3Parser.parseSlotData = function (slotObject) {
var slotData = new dragonBones.SlotData();
slotData.name = slotObject[dragonBones.ConstValues.A_NAME];
slotData.parent = slotObject[dragonBones.ConstValues.A_PARENT];
slotData.zOrder = (slotObject[dragonBones.ConstValues.A_Z_ORDER]);
slotData.zOrder = Data3Parser.getNumber(slotObject, dragonBones.ConstValues.A_Z_ORDER, 0) || 0;
slotData.blendMode = slotObject[dragonBones.ConstValues.A_BLENDMODE];
slotData.displayIndex = 0;
return slotData;
};
Data3Parser.parseDisplayData = function (displayObject) {
var displayData = new dragonBones.DisplayData();
displayData.name = displayObject[dragonBones.ConstValues.A_NAME];
displayData.type = displayObject[dragonBones.ConstValues.A_TYPE];
Data3Parser.parseTransform(displayObject[dragonBones.ConstValues.TRANSFORM], displayData.transform, displayData.pivot);
if (Data3Parser.tempDragonBonesData != null) {
Data3Parser.tempDragonBonesData.addDisplayData(displayData);
}
return displayData;
};
Data3Parser.parseAnimationData = function (animationObject, frameRate) {
var animationData = new dragonBones.AnimationData();
animationData.name = animationObject[dragonBones.ConstValues.A_NAME];
animationData.frameRate = frameRate;
animationData.duration = Math.round((Data3Parser.getNumber(animationObject, dragonBones.ConstValues.A_DURATION, 1) || 1) * 1000 / frameRate);
animationData.playTimes = Data3Parser.getNumber(animationObject, dragonBones.ConstValues.A_LOOP, 1);
animationData.playTimes = animationData.playTimes != NaN ? animationData.playTimes : 1;
animationData.fadeTime = Data3Parser.getNumber(animationObject, dragonBones.ConstValues.A_FADE_IN_TIME, 0) || 0;
animationData.scale = Data3Parser.getNumber(animationObject, dragonBones.ConstValues.A_SCALE, 1) || 0;
animationData.tweenEasing = Data3Parser.getNumber(animationObject, dragonBones.ConstValues.A_TWEEN_EASING, NaN);
animationData.autoTween = Data3Parser.getBoolean(animationObject, dragonBones.ConstValues.A_AUTO_TWEEN, true);
var frameObjectList = animationObject[dragonBones.ConstValues.FRAME];
var i = 0;
var len = 0;
if (frameObjectList) {
for (i = 0, len = frameObjectList.length; i < len; i++) {
var frameObject = frameObjectList[i];
var frame = Data3Parser.parseTransformFrame(frameObject, null, frameRate);
animationData.addFrame(frame);
}
}
Data3Parser.parseTimeline(animationObject, animationData);
var lastFrameDuration = animationData.duration;
var displayIndexChangeSlotTimelines = [];
var displayIndexChangeTimelines = [];
var timelineObjectList = animationObject[dragonBones.ConstValues.TIMELINE];
var displayIndexChange;
if (timelineObjectList) {
for (i = 0, len = timelineObjectList.length; i < len; i++) {
var timelineObject = timelineObjectList[i];
var timeline = Data3Parser.parseTransformTimeline(timelineObject, animationData.duration, frameRate);
timeline = Data3Parser.parseTransformTimeline(timelineObject, animationData.duration, frameRate);
lastFrameDuration = Math.min(lastFrameDuration, timeline.frameList[timeline.frameList.length - 1].duration);
animationData.addTimeline(timeline);
var slotTimeline = Data3Parser.parseSlotTimeline(timelineObject, animationData.duration, frameRate);
animationData.addSlotTimeline(slotTimeline);
if (animationData.autoTween && !displayIndexChange) {
var slotFrame;
for (var j = 0, jlen = slotTimeline.frameList.length; j < jlen; j++) {
slotFrame = slotTimeline.frameList[j];
if (slotFrame && slotFrame.displayIndex < 0) {
displayIndexChange = true;
break;
}
}
}
}
var animationTween = animationData.tweenEasing;
if (displayIndexChange) {
len = animationData.slotTimelineList.length;
for (i = 0; i < len; i++) {
slotTimeline = animationData.slotTimelineList[i];
timeline = animationData.timelineList[i];
var curFrame;
var curSlotFrame;
var nextSlotFrame;
for (j = 0, jlen = slotTimeline.frameList.length; j < jlen; j++) {
curSlotFrame = slotTimeline.frameList[j];
curFrame = timeline.frameList[j];
nextSlotFrame = (j == jlen - 1) ? slotTimeline.frameList[0] : slotTimeline.frameList[j + 1];
if (curSlotFrame.displayIndex < 0 || nextSlotFrame.displayIndex < 0) {
curFrame.tweenEasing = curSlotFrame.tweenEasing = NaN;
}
else if (animationTween == 10) {
curFrame.tweenEasing = curSlotFrame.tweenEasing = 0;
}
else if (!isNaN(animationTween)) {
curFrame.tweenEasing = curSlotFrame.tweenEasing = animationTween;
}
else if (curFrame.tweenEasing == 10) {
curFrame.tweenEasing = 0;
}
}
}
animationData.autoTween = false;
}
}
if (animationData.frameList.length > 0) {
lastFrameDuration = Math.min(lastFrameDuration, animationData.frameList[animationData.frameList.length - 1].duration);
}
animationData.lastFrameDuration = lastFrameDuration;
return animationData;
};
Data3Parser.parseSlotTimeline = function (timelineObject, duration, frameRate) {
var outputTimeline = new dragonBones.SlotTimeline();
outputTimeline.name = timelineObject[dragonBones.ConstValues.A_NAME];
outputTimeline.scale = Data3Parser.getNumber(timelineObject, dragonBones.ConstValues.A_SCALE, 1) || 0;
outputTimeline.offset = Data3Parser.getNumber(timelineObject, dragonBones.ConstValues.A_OFFSET, 0) || 0;
outputTimeline.duration = duration;
var frameList = timelineObject[dragonBones.ConstValues.FRAME];
for (var i = 0, len = frameList.length; i < len; i++) {
var frameObject = frameList[i];
var frame = Data3Parser.parseSlotFrame(frameObject, frameRate);
outputTimeline.addFrame(frame);
}
Data3Parser.parseTimeline(timelineObject, outputTimeline);
return outputTimeline;
};
Data3Parser.parseSlotFrame = function (frameObject, frameRate) {
var outputFrame = new dragonBones.SlotFrame();
Data3Parser.parseFrame(frameObject, outputFrame, frameRate);
outputFrame.visible = !Data3Parser.getBoolean(frameObject, dragonBones.ConstValues.A_HIDE, false);
outputFrame.tweenEasing = Data3Parser.getNumber(frameObject, dragonBones.ConstValues.A_TWEEN_EASING, 10);
outputFrame.displayIndex = Math.floor(Data3Parser.getNumber(frameObject, dragonBones.ConstValues.A_DISPLAY_INDEX, 0) || 0);
outputFrame.zOrder = Data3Parser.getNumber(frameObject, dragonBones.ConstValues.A_Z_ORDER, Data3Parser.tempDragonBonesData.isGlobal ? NaN : 0);
var colorTransformObject = frameObject[dragonBones.ConstValues.COLOR_TRANSFORM];
if (colorTransformObject) {
outputFrame.color = new dragonBones.ColorTransform();
Data3Parser.parseColorTransform(colorTransformObject, outputFrame.color);
}
return outputFrame;
};
Data3Parser.parseTransformTimeline = function (timelineObject, duration, frameRate) {
var outputTimeline = new dragonBones.TransformTimeline();
outputTimeline.name = timelineObject[dragonBones.ConstValues.A_NAME];
outputTimeline.scale = Data3Parser.getNumber(timelineObject, dragonBones.ConstValues.A_SCALE, 1) || 0;
outputTimeline.offset = Data3Parser.getNumber(timelineObject, dragonBones.ConstValues.A_OFFSET, 0) || 0;
outputTimeline.originPivot.x = Data3Parser.getNumber(timelineObject, dragonBones.ConstValues.A_PIVOT_X, 0) || 0;
outputTimeline.originPivot.y = Data3Parser.getNumber(timelineObject, dragonBones.ConstValues.A_PIVOT_Y, 0) || 0;
outputTimeline.duration = duration;
var frameList = timelineObject[dragonBones.ConstValues.FRAME];
var nextFrameObject;
for (var i = 0, len = frameList.length; i < len; i++) {
var frameObject = frameList[i];
if (i < len - 1) {
nextFrameObject = frameList[i + 1];
}
else if (i != 0) {
nextFrameObject = frameList[0];
}
else {
nextFrameObject = null;
}
var frame = Data3Parser.parseTransformFrame(frameObject, nextFrameObject, frameRate);
outputTimeline.addFrame(frame);
}
Data3Parser.parseTimeline(timelineObject, outputTimeline);
return outputTimeline;
};
Data3Parser.parseTransformFrame = function (frameObject, nextFrameObject, frameRate) {
var outputFrame = new dragonBones.TransformFrame();
Data3Parser.parseFrame(frameObject, outputFrame, frameRate);
outputFrame.visible = !Data3Parser.getBoolean(frameObject, dragonBones.ConstValues.A_HIDE, false);
outputFrame.tweenEasing = Data3Parser.getNumber(frameObject, dragonBones.ConstValues.A_TWEEN_EASING, 10);
outputFrame.tweenRotate = Math.floor(Data3Parser.getNumber(frameObject, dragonBones.ConstValues.A_TWEEN_ROTATE, 0) || 0);
outputFrame.tweenScale = Data3Parser.getBoolean(frameObject, dragonBones.ConstValues.A_TWEEN_SCALE, true);
if (nextFrameObject && Math.floor(Data3Parser.getNumber(nextFrameObject, dragonBones.ConstValues.A_DISPLAY_INDEX, 0) || 0) == -1) {
outputFrame.tweenEasing = NaN;
}
Data3Parser.parseTransform(frameObject[dragonBones.ConstValues.TRANSFORM], outputFrame.transform, outputFrame.pivot);
if (Data3Parser.tempDragonBonesData.isGlobal) {
outputFrame.global.copy(outputFrame.transform);
}
outputFrame.scaleOffset.x = Data3Parser.getNumber(frameObject, dragonBones.ConstValues.A_SCALE_X_OFFSET, 0) || 0;
outputFrame.scaleOffset.y = Data3Parser.getNumber(frameObject, dragonBones.ConstValues.A_SCALE_Y_OFFSET, 0) || 0;
return outputFrame;
};
Data3Parser.parseTimeline = function (timelineObject, outputTimeline) {
var position = 0;
var frame;
var frameList = outputTimeline.frameList;
for (var i = 0, len = frameList.length; i < len; i++) {
frame = frameList[i];
frame.position = position;
position += frame.duration;
}
if (frame) {
frame.duration = outputTimeline.duration - frame.position;
}
};
Data3Parser.parseFrame = function (frameObject, outputFrame, frameRate) {
if (frameRate === void 0) { frameRate = 0; }
outputFrame.duration = Math.round(((frameObject[dragonBones.ConstValues.A_DURATION]) || 1) * 1000 / frameRate);
outputFrame.action = frameObject[dragonBones.ConstValues.A_ACTION];
outputFrame.event = frameObject[dragonBones.ConstValues.A_EVENT];
outputFrame.sound = frameObject[dragonBones.ConstValues.A_SOUND];
};
Data3Parser.parseTransform = function (transformObject, transform, pivot) {
if (pivot === void 0) { pivot = null; }
if (transformObject) {
if (transform) {
transform.x = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_X, 0) || 0;
transform.y = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_Y, 0) || 0;
transform.skewX = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_SKEW_X, 0) * dragonBones.ConstValues.ANGLE_TO_RADIAN || 0;
transform.skewY = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_SKEW_Y, 0) * dragonBones.ConstValues.ANGLE_TO_RADIAN || 0;
transform.scaleX = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_SCALE_X, 1) || 0;
transform.scaleY = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_SCALE_Y, 1) || 0;
}
if (pivot) {
pivot.x = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_PIVOT_X, 0) || 0;
pivot.y = Data3Parser.getNumber(transformObject, dragonBones.ConstValues.A_PIVOT_Y, 0) || 0;
}
}
};
Data3Parser.parseColorTransform = function (colorTransformObject, colorTransform) {
if (colorTransformObject) {
if (colorTransform) {
colorTransform.alphaOffset = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_ALPHA_OFFSET, 0);
colorTransform.redOffset = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_RED_OFFSET, 0);
colorTransform.greenOffset = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_GREEN_OFFSET, 0);
colorTransform.blueOffset = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_BLUE_OFFSET, 0);
colorTransform.alphaMultiplier = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_ALPHA_MULTIPLIER, 100) * 0.01;
colorTransform.redMultiplier = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_RED_MULTIPLIER, 100) * 0.01;
colorTransform.greenMultiplier = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_GREEN_MULTIPLIER, 100) * 0.01;
colorTransform.blueMultiplier = Data3Parser.getNumber(colorTransformObject, dragonBones.ConstValues.A_BLUE_MULTIPLIER, 100) * 0.01;
}
}
};
Data3Parser.getBoolean = function (data, key, defaultValue) {
if (data && key in data) {
switch (String(data[key])) {
case "0":
case "NaN":
case "":
case "false":
case "null":
case "undefined":
return false;
case "1":
case "true":
default:
return true;
}
}
return defaultValue;
};
Data3Parser.getNumber = function (data, key, defaultValue) {
if (data && key in data) {
switch (String(data[key])) {
case "NaN":
case "":
case "false":
case "null":
case "undefined":
return NaN;
default:
return Number(data[key]);
}
}
return defaultValue;
};
return Data3Parser;
})();
dragonBones.Data3Parser = Data3Parser;
egret.registerClass(Data3Parser,'dragonBones.Data3Parser');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var DataParser = (function () {
function DataParser() {
}
var d = __define,c=DataParser,p=c.prototype;
DataParser.parseTextureAtlasData = function (rawData, scale) {
if (scale === void 0) { scale = 1; }
var textureAtlasData = {};
var subTextureFrame;
var subTextureList = rawData[dragonBones.ConstValues.SUB_TEXTURE];
for (var i = 0, len = subTextureList.length; i < len; i++) {
var subTextureObject = subTextureList[i];
var subTextureName = subTextureObject[dragonBones.ConstValues.A_NAME];
var subTextureRegion = new dragonBones.Rectangle();
subTextureRegion.x = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_X, 0) / scale;
subTextureRegion.y = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_Y, 0) / scale;
subTextureRegion.width = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_WIDTH, 0) / scale;
subTextureRegion.height = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_HEIGHT, 0) / scale;
var rotated = subTextureObject[dragonBones.ConstValues.A_ROTATED] == "true";
var frameWidth = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_FRAME_WIDTH, 0) / scale;
var frameHeight = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_FRAME_HEIGHT, 0) / scale;
if (frameWidth > 0 && frameHeight > 0) {
subTextureFrame = new dragonBones.Rectangle();
subTextureFrame.x = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_FRAME_X, 0) / scale;
subTextureFrame.y = DataParser.getNumber(subTextureObject, dragonBones.ConstValues.A_FRAME_Y, 0) / scale;
subTextureFrame.width = frameWidth;
subTextureFrame.height = frameHeight;
}
else {
subTextureFrame = null;
}
textureAtlasData[subTextureName] = new dragonBones.TextureData(subTextureRegion, subTextureFrame, rotated);
}
return textureAtlasData;
};
DataParser.parseDragonBonesData = function (rawDataToParse) {
if (!rawDataToParse) {
throw new Error();
}
var version = rawDataToParse[dragonBones.ConstValues.A_VERSION];
version = version.toString();
if (version.toString() == dragonBones.DragonBones.PARENT_COORDINATE_DATA_VERSION ||
version.toString() == "2.3") {
return dragonBones.Data3Parser.parseDragonBonesData(rawDataToParse);
}
var frameRate = DataParser.getNumber(rawDataToParse, dragonBones.ConstValues.A_FRAME_RATE, 0) || 0;
var outputDragonBonesData = new dragonBones.DragonBonesData();
outputDragonBonesData.name = rawDataToParse[dragonBones.ConstValues.A_NAME];
outputDragonBonesData.isGlobal = rawDataToParse[dragonBones.ConstValues.A_IS_GLOBAL] == "0" ? false : true;
DataParser.tempDragonBonesData = outputDragonBonesData;
var armatureList = rawDataToParse[dragonBones.ConstValues.ARMATURE];
for (var i = 0, len = armatureList.length; i < len; i++) {
var armatureObject = armatureList[i];
outputDragonBonesData.addArmatureData(DataParser.parseArmatureData(armatureObject, frameRate));
}
DataParser.tempDragonBonesData = null;
return outputDragonBonesData;
};
DataParser.parseArmatureData = function (armatureDataToParse, frameRate) {
var outputArmatureData = new dragonBones.ArmatureData();
outputArmatureData.name = armatureDataToParse[dragonBones.ConstValues.A_NAME];
var boneList = armatureDataToParse[dragonBones.ConstValues.BONE];
var i;
var len;
for (i = 0, len = boneList.length; i < len; i++) {
var boneObject = boneList[i];
outputArmatureData.addBoneData(DataParser.parseBoneData(boneObject));
}
var slotList = armatureDataToParse[dragonBones.ConstValues.SLOT];
for (i = 0, len = slotList.length; i < len; i++) {
var slotObject = slotList[i];
outputArmatureData.addSlotData(DataParser.parseSlotData(slotObject));
}
var skinList = armatureDataToParse[dragonBones.ConstValues.SKIN];
for (i = 0, len = skinList.length; i < len; i++) {
var skinObject = skinList[i];
outputArmatureData.addSkinData(DataParser.parseSkinData(skinObject));
}
if (DataParser.tempDragonBonesData.isGlobal) {
dragonBones.DBDataUtil.transformArmatureData(outputArmatureData);
}
outputArmatureData.sortBoneDataList();
var animationList = armatureDataToParse[dragonBones.ConstValues.ANIMATION];
for (i = 0, len = animationList.length; i < len; i++) {
var animationObject = animationList[i];
var animationData = DataParser.parseAnimationData(animationObject, frameRate);
dragonBones.DBDataUtil.addHideTimeline(animationData, outputArmatureData, true);
dragonBones.DBDataUtil.transformAnimationData(animationData, outputArmatureData, DataParser.tempDragonBonesData.isGlobal);
outputArmatureData.addAnimationData(animationData);
}
return outputArmatureData;
};
DataParser.parseBoneData = function (boneObject) {
var boneData = new dragonBones.BoneData();
boneData.name = boneObject[dragonBones.ConstValues.A_NAME];
boneData.parent = boneObject[dragonBones.ConstValues.A_PARENT];
boneData.length = Number(boneObject[dragonBones.ConstValues.A_LENGTH]) || 0;
boneData.inheritRotation = DataParser.getBoolean(boneObject, dragonBones.ConstValues.A_INHERIT_ROTATION, true);
boneData.inheritScale = DataParser.getBoolean(boneObject, dragonBones.ConstValues.A_INHERIT_SCALE, true);
DataParser.parseTransform(boneObject[dragonBones.ConstValues.TRANSFORM], boneData.transform);
if (DataParser.tempDragonBonesData.isGlobal) {
boneData.global.copy(boneData.transform);
}
return boneData;
};
DataParser.parseSkinData = function (skinObject) {
var skinData = new dragonBones.SkinData();
skinData.name = skinObject[dragonBones.ConstValues.A_NAME];
var slotList = skinObject[dragonBones.ConstValues.SLOT];
for (var i = 0, len = slotList.length; i < len; i++) {
var slotObject = slotList[i];
skinData.addSlotData(DataParser.parseSlotDisplayData(slotObject));
}
return skinData;
};
DataParser.parseSlotData = function (slotObject) {
var slotData = new dragonBones.SlotData();
slotData.name = slotObject[dragonBones.ConstValues.A_NAME];
slotData.parent = slotObject[dragonBones.ConstValues.A_PARENT];
slotData.zOrder = DataParser.getNumber(slotObject, dragonBones.ConstValues.A_Z_ORDER, 0) || 0;
slotData.displayIndex = DataParser.getNumber(slotObject, dragonBones.ConstValues.A_DISPLAY_INDEX, 0);
slotData.blendMode = slotObject[dragonBones.ConstValues.A_BLENDMODE];
return slotData;
};
DataParser.parseSlotDisplayData = function (slotObject) {
var slotData = new dragonBones.SlotData();
slotData.name = slotObject[dragonBones.ConstValues.A_NAME];
slotData.parent = slotObject[dragonBones.ConstValues.A_PARENT];
slotData.zOrder = DataParser.getNumber(slotObject, dragonBones.ConstValues.A_Z_ORDER, 0) || 0;
var displayList = slotObject[dragonBones.ConstValues.DISPLAY];
if (displayList) {
for (var i = 0, len = displayList.length; i < len; i++) {
var displayObject = displayList[i];
slotData.addDisplayData(DataParser.parseDisplayData(displayObject));
}
}
return slotData;
};
DataParser.parseDisplayData = function (displayObject) {
var displayData = new dragonBones.DisplayData();
displayData.name = displayObject[dragonBones.ConstValues.A_NAME];
displayData.type = displayObject[dragonBones.ConstValues.A_TYPE];
DataParser.parseTransform(displayObject[dragonBones.ConstValues.TRANSFORM], displayData.transform, displayData.pivot);
displayData.pivot.x = NaN;
displayData.pivot.y = NaN;
if (DataParser.tempDragonBonesData != null) {
DataParser.tempDragonBonesData.addDisplayData(displayData);
}
return displayData;
};
DataParser.parseAnimationData = function (animationObject, frameRate) {
var animationData = new dragonBones.AnimationData();
animationData.name = animationObject[dragonBones.ConstValues.A_NAME];
animationData.frameRate = frameRate;
animationData.duration = Math.ceil((DataParser.getNumber(animationObject, dragonBones.ConstValues.A_DURATION, 1) || 1) * 1000 / frameRate);
animationData.playTimes = DataParser.getNumber(animationObject, dragonBones.ConstValues.A_PLAY_TIMES, 1);
animationData.playTimes = animationData.playTimes != NaN ? animationData.playTimes : 1;
animationData.fadeTime = DataParser.getNumber(animationObject, dragonBones.ConstValues.A_FADE_IN_TIME, 0) || 0;
animationData.scale = DataParser.getNumber(animationObject, dragonBones.ConstValues.A_SCALE, 1) || 0;
animationData.tweenEasing = DataParser.getNumber(animationObject, dragonBones.ConstValues.A_TWEEN_EASING, NaN);
animationData.autoTween = DataParser.getBoolean(animationObject, dragonBones.ConstValues.A_AUTO_TWEEN, true);
var frameObjectList = animationObject[dragonBones.ConstValues.FRAME];
var i = 0;
var len = 0;
if (frameObjectList) {
for (i = 0, len = frameObjectList.length; i < len; i++) {
var frameObject = frameObjectList[i];
var frame = DataParser.parseTransformFrame(frameObject, frameRate);
animationData.addFrame(frame);
}
}
DataParser.parseTimeline(animationObject, animationData);
var lastFrameDuration = animationData.duration;
var timelineObjectList = animationObject[dragonBones.ConstValues.BONE];
if (timelineObjectList) {
for (i = 0, len = timelineObjectList.length; i < len; i++) {
var timelineObject = timelineObjectList[i];
if (timelineObject) {
var timeline = DataParser.parseTransformTimeline(timelineObject, animationData.duration, frameRate);
if (timeline.frameList.length > 0) {
lastFrameDuration = Math.min(lastFrameDuration, timeline.frameList[timeline.frameList.length - 1].duration);
}
animationData.addTimeline(timeline);
}
}
}
var slotTimelineObjectList = animationObject[dragonBones.ConstValues.SLOT];
if (slotTimelineObjectList) {
for (i = 0, len = slotTimelineObjectList.length; i < len; i++) {
var slotTimelineObject = slotTimelineObjectList[i];
if (slotTimelineObject) {
var slotTimeline = DataParser.parseSlotTimeline(slotTimelineObject, animationData.duration, frameRate);
if (slotTimeline.frameList.length > 0) {
lastFrameDuration = Math.min(lastFrameDuration, slotTimeline.frameList[slotTimeline.frameList.length - 1].duration);
animationData.addSlotTimeline(slotTimeline);
}
}
}
}
if (animationData.frameList.length > 0) {
lastFrameDuration = Math.min(lastFrameDuration, animationData.frameList[animationData.frameList.length - 1].duration);
}
animationData.lastFrameDuration = lastFrameDuration;
return animationData;
};
DataParser.parseTransformTimeline = function (timelineObject, duration, frameRate) {
var outputTimeline = new dragonBones.TransformTimeline();
outputTimeline.name = timelineObject[dragonBones.ConstValues.A_NAME];
outputTimeline.scale = DataParser.getNumber(timelineObject, dragonBones.ConstValues.A_SCALE, 1) || 0;
outputTimeline.offset = DataParser.getNumber(timelineObject, dragonBones.ConstValues.A_OFFSET, 0) || 0;
outputTimeline.originPivot.x = DataParser.getNumber(timelineObject, dragonBones.ConstValues.A_PIVOT_X, 0) || 0;
outputTimeline.originPivot.y = DataParser.getNumber(timelineObject, dragonBones.ConstValues.A_PIVOT_Y, 0) || 0;
outputTimeline.duration = duration;
var frameList = timelineObject[dragonBones.ConstValues.FRAME];
for (var i = 0, len = frameList.length; i < len; i++) {
var frameObject = frameList[i];
var frame = DataParser.parseTransformFrame(frameObject, frameRate);
outputTimeline.addFrame(frame);
}
DataParser.parseTimeline(timelineObject, outputTimeline);
return outputTimeline;
};
DataParser.parseSlotTimeline = function (timelineObject, duration, frameRate) {
var outputTimeline = new dragonBones.SlotTimeline();
outputTimeline.name = timelineObject[dragonBones.ConstValues.A_NAME];
outputTimeline.scale = DataParser.getNumber(timelineObject, dragonBones.ConstValues.A_SCALE, 1) || 0;
outputTimeline.offset = DataParser.getNumber(timelineObject, dragonBones.ConstValues.A_OFFSET, 0) || 0;
outputTimeline.duration = duration;
var frameList = timelineObject[dragonBones.ConstValues.FRAME];
for (var i = 0, len = frameList.length; i < len; i++) {
var frameObject = frameList[i];
var frame = DataParser.parseSlotFrame(frameObject, frameRate);
outputTimeline.addFrame(frame);
}
DataParser.parseTimeline(timelineObject, outputTimeline);
return outputTimeline;
};
DataParser.parseTransformFrame = function (frameObject, frameRate) {
var outputFrame = new dragonBones.TransformFrame();
DataParser.parseFrame(frameObject, outputFrame, frameRate);
outputFrame.visible = !DataParser.getBoolean(frameObject, dragonBones.ConstValues.A_HIDE, false);
outputFrame.tweenEasing = DataParser.getNumber(frameObject, dragonBones.ConstValues.A_TWEEN_EASING, 10);
outputFrame.tweenRotate = Math.floor(DataParser.getNumber(frameObject, dragonBones.ConstValues.A_TWEEN_ROTATE, 0) || 0);
outputFrame.tweenScale = DataParser.getBoolean(frameObject, dragonBones.ConstValues.A_TWEEN_SCALE, true);
outputFrame.displayIndex = Math.floor(DataParser.getNumber(frameObject, dragonBones.ConstValues.A_DISPLAY_INDEX, 0) || 0);
DataParser.parseTransform(frameObject[dragonBones.ConstValues.TRANSFORM], outputFrame.transform, outputFrame.pivot);
if (DataParser.tempDragonBonesData.isGlobal) {
outputFrame.global.copy(outputFrame.transform);
}
outputFrame.scaleOffset.x = DataParser.getNumber(frameObject, dragonBones.ConstValues.A_SCALE_X_OFFSET, 0) || 0;
outputFrame.scaleOffset.y = DataParser.getNumber(frameObject, dragonBones.ConstValues.A_SCALE_Y_OFFSET, 0) || 0;
return outputFrame;
};
DataParser.parseSlotFrame = function (frameObject, frameRate) {
var outputFrame = new dragonBones.SlotFrame();
DataParser.parseFrame(frameObject, outputFrame, frameRate);
outputFrame.visible = !DataParser.getBoolean(frameObject, dragonBones.ConstValues.A_HIDE, false);
outputFrame.tweenEasing = DataParser.getNumber(frameObject, dragonBones.ConstValues.A_TWEEN_EASING, 10);
outputFrame.displayIndex = Math.floor(DataParser.getNumber(frameObject, dragonBones.ConstValues.A_DISPLAY_INDEX, 0) || 0);
outputFrame.zOrder = DataParser.getNumber(frameObject, dragonBones.ConstValues.A_Z_ORDER, DataParser.tempDragonBonesData.isGlobal ? NaN : 0);
var colorTransformObject = frameObject[dragonBones.ConstValues.COLOR];
if (colorTransformObject) {
outputFrame.color = new dragonBones.ColorTransform();
DataParser.parseColorTransform(colorTransformObject, outputFrame.color);
}
return outputFrame;
};
DataParser.parseTimeline = function (timelineObject, outputTimeline) {
var position = 0;
var frame;
var frameList = outputTimeline.frameList;
for (var i = 0, len = frameList.length; i < len; i++) {
frame = frameList[i];
frame.position = position;
position += frame.duration;
}
if (frame) {
frame.duration = outputTimeline.duration - frame.position;
}
};
DataParser.parseFrame = function (frameObject, outputFrame, frameRate) {
if (frameRate === void 0) { frameRate = 0; }
outputFrame.duration = Math.round(((frameObject[dragonBones.ConstValues.A_DURATION]) || 1) * 1000 / frameRate);
outputFrame.action = frameObject[dragonBones.ConstValues.A_ACTION];
outputFrame.event = frameObject[dragonBones.ConstValues.A_EVENT];
outputFrame.sound = frameObject[dragonBones.ConstValues.A_SOUND];
var curve = frameObject[dragonBones.ConstValues.A_CURVE];
if (curve != null && curve.length == 4) {
outputFrame.curve = new dragonBones.CurveData();
outputFrame.curve.pointList = [new dragonBones.Point(curve[0], curve[1]),
new dragonBones.Point(curve[2], curve[3])];
}
};
DataParser.parseTransform = function (transformObject, transform, pivot) {
if (pivot === void 0) { pivot = null; }
if (transformObject) {
if (transform) {
transform.x = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_X, 0) || 0;
transform.y = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_Y, 0) || 0;
transform.skewX = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_SKEW_X, 0) * dragonBones.ConstValues.ANGLE_TO_RADIAN || 0;
transform.skewY = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_SKEW_Y, 0) * dragonBones.ConstValues.ANGLE_TO_RADIAN || 0;
transform.scaleX = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_SCALE_X, 1) || 0;
transform.scaleY = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_SCALE_Y, 1) || 0;
}
if (pivot) {
pivot.x = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_PIVOT_X, 0) || 0;
pivot.y = DataParser.getNumber(transformObject, dragonBones.ConstValues.A_PIVOT_Y, 0) || 0;
}
}
};
DataParser.parseColorTransform = function (colorTransformObject, colorTransform) {
if (colorTransform) {
colorTransform.alphaOffset = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_ALPHA_OFFSET, 0);
colorTransform.redOffset = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_RED_OFFSET, 0);
colorTransform.greenOffset = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_GREEN_OFFSET, 0);
colorTransform.blueOffset = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_BLUE_OFFSET, 0);
colorTransform.alphaMultiplier = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_ALPHA_MULTIPLIER, 100) * 0.01;
colorTransform.redMultiplier = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_RED_MULTIPLIER, 100) * 0.01;
colorTransform.greenMultiplier = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_GREEN_MULTIPLIER, 100) * 0.01;
colorTransform.blueMultiplier = DataParser.getNumber(colorTransformObject, dragonBones.ConstValues.A_BLUE_MULTIPLIER, 100) * 0.01;
}
};
DataParser.getBoolean = function (data, key, defaultValue) {
if (data && key in data) {
switch (String(data[key])) {
case "0":
case "NaN":
case "":
case "false":
case "null":
case "undefined":
return false;
case "1":
case "true":
default:
return true;
}
}
return defaultValue;
};
DataParser.getNumber = function (data, key, defaultValue) {
if (data && key in data) {
switch (String(data[key])) {
case "NaN":
case "":
case "false":
case "null":
case "undefined":
return NaN;
default:
return Number(data[key]);
}
}
return defaultValue;
};
return DataParser;
})();
dragonBones.DataParser = DataParser;
egret.registerClass(DataParser,'dragonBones.DataParser');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Timeline = (function () {
function Timeline() {
this.duration = 0;
this._frameList = [];
this.duration = 0;
this.scale = 1;
}
var d = __define,c=Timeline,p=c.prototype;
p.dispose = function () {
var i = this._frameList.length;
while (i--) {
this._frameList[i].dispose();
}
this._frameList = null;
};
p.addFrame = function (frame) {
if (!frame) {
throw new Error();
}
if (this._frameList.indexOf(frame) < 0) {
this._frameList[this._frameList.length] = frame;
}
else {
throw new Error();
}
};
d(p, "frameList"
,function () {
return this._frameList;
}
);
return Timeline;
})();
dragonBones.Timeline = Timeline;
egret.registerClass(Timeline,'dragonBones.Timeline');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var AnimationData = (function (_super) {
__extends(AnimationData, _super);
function AnimationData() {
_super.call(this);
this.frameRate = 0;
this.playTimes = 0;
this.lastFrameDuration = 0;
this.fadeTime = 0;
this.playTimes = 0;
this.autoTween = true;
this.tweenEasing = NaN;
this.hideTimelineNameMap = [];
this.hideSlotTimelineNameMap = [];
this._timelineList = [];
this._slotTimelineList = [];
}
var d = __define,c=AnimationData,p=c.prototype;
d(p, "timelineList"
,function () {
return this._timelineList;
}
);
d(p, "slotTimelineList"
,function () {
return this._slotTimelineList;
}
);
p.dispose = function () {
_super.prototype.dispose.call(this);
this.hideTimelineNameMap = null;
var i = 0;
var len = 0;
for (i = 0, len = this._timelineList.length; i < len; i++) {
var timeline = this._timelineList[i];
timeline.dispose();
}
this._timelineList = null;
for (i = 0, len = this._slotTimelineList.length; i < len; i++) {
var slotTimeline = this._slotTimelineList[i];
slotTimeline.dispose();
}
this._slotTimelineList = null;
};
p.getTimeline = function (timelineName) {
var i = this._timelineList.length;
while (i--) {
if (this._timelineList[i].name == timelineName) {
return this._timelineList[i];
}
}
return null;
};
p.addTimeline = function (timeline) {
if (!timeline) {
throw new Error();
}
if (this._timelineList.indexOf(timeline) < 0) {
this._timelineList[this._timelineList.length] = timeline;
}
};
p.getSlotTimeline = function (timelineName) {
var i = this._slotTimelineList.length;
while (i--) {
if (this._slotTimelineList[i].name == timelineName) {
return this._slotTimelineList[i];
}
}
return null;
};
p.addSlotTimeline = function (timeline) {
if (!timeline) {
throw new Error();
}
if (this._slotTimelineList.indexOf(timeline) < 0) {
this._slotTimelineList[this._slotTimelineList.length] = timeline;
}
};
return AnimationData;
})(dragonBones.Timeline);
dragonBones.AnimationData = AnimationData;
egret.registerClass(AnimationData,'dragonBones.AnimationData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var ArmatureData = (function () {
function ArmatureData() {
this._boneDataList = [];
this._skinDataList = [];
this._slotDataList = [];
this._animationDataList = [];
}
var d = __define,c=ArmatureData,p=c.prototype;
ArmatureData.sortBoneDataHelpArray = function (object1, object2) {
return object1[0] > object2[0] ? 1 : -1;
};
ArmatureData.sortBoneDataHelpArrayDescending = function (object1, object2) {
return object1[0] > object2[0] ? -1 : 1;
};
p.setSkinData = function (skinName) {
var i = 0;
var len = this._slotDataList.length;
for (i = 0; i < len; i++) {
this._slotDataList[i].dispose();
}
var skinData;
if (!skinName && this._skinDataList.length > 0) {
skinData = this._skinDataList[0];
}
else {
i = 0,
len = this._skinDataList.length;
for (; i < len; i++) {
if (this._skinDataList[i].name == skinName) {
skinData = this._skinDataList[i];
break;
}
}
}
if (skinData) {
var slotData;
i = 0, len = skinData.slotDataList.length;
for (i = 0; i < len; i++) {
slotData = this.getSlotData(skinData.slotDataList[i].name);
if (slotData) {
var j = 0;
var jLen = skinData.slotDataList[i].displayDataList.length;
for (j = 0; j < jLen; j++) {
slotData.addDisplayData(skinData.slotDataList[i].displayDataList[j]);
}
}
}
}
};
p.dispose = function () {
var i = this._boneDataList.length;
while (i--) {
this._boneDataList[i].dispose();
}
i = this._skinDataList.length;
while (i--) {
this._skinDataList[i].dispose();
}
i = this._slotDataList.length;
while (i--) {
this._slotDataList[i].dispose();
}
i = this._animationDataList.length;
while (i--) {
this._animationDataList[i].dispose();
}
this._boneDataList = null;
this._slotDataList = null;
this._skinDataList = null;
this._animationDataList = null;
};
p.getBoneData = function (boneName) {
var i = this._boneDataList.length;
while (i--) {
if (this._boneDataList[i].name == boneName) {
return this._boneDataList[i];
}
}
return null;
};
p.getSlotData = function (slotName) {
var i = this._slotDataList.length;
while (i--) {
if (this._slotDataList[i].name == slotName) {
return this._slotDataList[i];
}
}
return null;
};
p.getSkinData = function (skinName) {
if (!skinName && this._skinDataList.length > 0) {
return this._skinDataList[0];
}
var i = this._skinDataList.length;
while (i--) {
if (this._skinDataList[i].name == skinName) {
return this._skinDataList[i];
}
}
return null;
};
p.getAnimationData = function (animationName) {
var i = this._animationDataList.length;
while (i--) {
if (this._animationDataList[i].name == animationName) {
return this._animationDataList[i];
}
}
return null;
};
p.addBoneData = function (boneData) {
if (!boneData) {
throw new Error();
}
if (this._boneDataList.indexOf(boneData) < 0) {
this._boneDataList[this._boneDataList.length] = boneData;
}
else {
throw new Error();
}
};
p.addSlotData = function (slotData) {
if (!slotData) {
throw new Error();
}
if (this._slotDataList.indexOf(slotData) < 0) {
this._slotDataList[this._slotDataList.length] = slotData;
}
else {
throw new Error();
}
};
p.addSkinData = function (skinData) {
if (!skinData) {
throw new Error();
}
if (this._skinDataList.indexOf(skinData) < 0) {
this._skinDataList[this._skinDataList.length] = skinData;
}
else {
throw new Error();
}
};
p.addAnimationData = function (animationData) {
if (!animationData) {
throw new Error();
}
if (this._animationDataList.indexOf(animationData) < 0) {
this._animationDataList[this._animationDataList.length] = animationData;
}
};
p.sortBoneDataList = function () {
var i = this._boneDataList.length;
if (i == 0) {
return;
}
var helpArray = [];
while (i--) {
var boneData = this._boneDataList[i];
var level = 0;
var parentData = boneData;
while (parentData) {
level++;
parentData = this.getBoneData(parentData.parent);
}
helpArray[i] = [level, boneData];
}
helpArray.sort(ArmatureData.sortBoneDataHelpArray);
i = helpArray.length;
while (i--) {
this._boneDataList[i] = helpArray[i][1];
}
};
d(p, "boneDataList"
,function () {
return this._boneDataList;
}
);
d(p, "slotDataList"
,function () {
return this._slotDataList;
}
);
d(p, "skinDataList"
,function () {
return this._skinDataList;
}
);
d(p, "animationDataList"
,function () {
return this._animationDataList;
}
);
return ArmatureData;
})();
dragonBones.ArmatureData = ArmatureData;
egret.registerClass(ArmatureData,'dragonBones.ArmatureData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var BoneData = (function () {
function BoneData() {
this.length = 0;
this.global = new dragonBones.DBTransform();
this.transform = new dragonBones.DBTransform();
this.inheritRotation = true;
this.inheritScale = false;
}
var d = __define,c=BoneData,p=c.prototype;
p.dispose = function () {
this.global = null;
this.transform = null;
};
return BoneData;
})();
dragonBones.BoneData = BoneData;
egret.registerClass(BoneData,'dragonBones.BoneData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var ColorTransform = (function () {
function ColorTransform() {
this.alphaMultiplier = 1;
this.alphaOffset = 0;
this.blueMultiplier = 1;
this.blueOffset = 0;
this.greenMultiplier = 1;
this.greenOffset = 0;
this.redMultiplier = 1;
this.redOffset = 0;
}
var d = __define,c=ColorTransform,p=c.prototype;
return ColorTransform;
})();
dragonBones.ColorTransform = ColorTransform;
egret.registerClass(ColorTransform,'dragonBones.ColorTransform');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var CurveData = (function () {
function CurveData() {
this._dataChanged = false;
this._pointList = [];
this.sampling = new Array(CurveData.SamplingTimes);
for (var i = 0; i < CurveData.SamplingTimes - 1; i++) {
this.sampling[i] = new dragonBones.Point();
}
}
var d = __define,c=CurveData,p=c.prototype;
p.getValueByProgress = function (progress) {
if (this._dataChanged) {
this.refreshSampling();
}
for (var i = 0; i < CurveData.SamplingTimes - 1; i++) {
var point = this.sampling[i];
if (point.x >= progress) {
if (i == 0) {
return point.y * progress / point.x;
}
else {
var prevPoint = this.sampling[i - 1];
return prevPoint.y + (point.y - prevPoint.y) * (progress - prevPoint.x) / (point.x - prevPoint.x);
}
}
}
return point.y + (1 - point.y) * (progress - point.x) / (1 - point.x);
};
p.refreshSampling = function () {
for (var i = 0; i < CurveData.SamplingTimes - 1; i++) {
this.bezierCurve(CurveData.SamplingStep * (i + 1), this.sampling[i]);
}
this._dataChanged = false;
};
p.bezierCurve = function (t, outputPoint) {
var l_t = 1 - t;
outputPoint.x = 3 * this.point1.x * t * l_t * l_t + 3 * this.point2.x * t * t * l_t + Math.pow(t, 3);
outputPoint.y = 3 * this.point1.y * t * l_t * l_t + 3 * this.point2.y * t * t * l_t + Math.pow(t, 3);
};
d(p, "pointList"
,function () {
return this._pointList;
}
,function (value) {
this._pointList = value;
this._dataChanged = true;
}
);
p.isCurve = function () {
return this.point1.x != 0 || this.point1.y != 0 || this.point2.x != 1 || this.point2.y != 1;
};
d(p, "point1"
,function () {
return this.pointList[0];
}
);
d(p, "point2"
,function () {
return this.pointList[1];
}
);
CurveData.SamplingTimes = 20;
CurveData.SamplingStep = 0.05;
return CurveData;
})();
dragonBones.CurveData = CurveData;
egret.registerClass(CurveData,'dragonBones.CurveData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var DisplayData = (function () {
function DisplayData() {
this.transform = new dragonBones.DBTransform();
this.pivot = new dragonBones.Point();
}
var d = __define,c=DisplayData,p=c.prototype;
p.dispose = function () {
this.transform = null;
this.pivot = null;
};
DisplayData.ARMATURE = "armature";
DisplayData.IMAGE = "image";
return DisplayData;
})();
dragonBones.DisplayData = DisplayData;
egret.registerClass(DisplayData,'dragonBones.DisplayData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var DragonBonesData = (function () {
function DragonBonesData() {
this._armatureDataList = [];
this._displayDataDictionary = {};
}
var d = __define,c=DragonBonesData,p=c.prototype;
p.dispose = function () {
for (var i = 0, len = this._armatureDataList.length; i < len; i++) {
var armatureData = this._armatureDataList[i];
armatureData.dispose();
}
this._armatureDataList = null;
this.removeAllDisplayData();
this._displayDataDictionary = null;
};
d(p, "armatureDataList"
,function () {
return this._armatureDataList;
}
);
p.getArmatureDataByName = function (armatureName) {
var i = this._armatureDataList.length;
while (i--) {
if (this._armatureDataList[i].name == armatureName) {
return this._armatureDataList[i];
}
}
return null;
};
p.addArmatureData = function (armatureData) {
if (!armatureData) {
throw new Error();
}
if (this._armatureDataList.indexOf(armatureData) < 0) {
this._armatureDataList[this._armatureDataList.length] = armatureData;
}
else {
throw new Error();
}
};
p.removeArmatureData = function (armatureData) {
var index = this._armatureDataList.indexOf(armatureData);
if (index >= 0) {
this._armatureDataList.splice(index, 1);
}
};
p.removeArmatureDataByName = function (armatureName) {
var i = this._armatureDataList.length;
while (i--) {
if (this._armatureDataList[i].name == armatureName) {
this._armatureDataList.splice(i, 1);
}
}
};
p.getDisplayDataByName = function (name) {
return this._displayDataDictionary[name];
};
p.addDisplayData = function (displayData) {
this._displayDataDictionary[displayData.name] = displayData;
};
p.removeDisplayDataByName = function (name) {
delete this._displayDataDictionary[name];
};
p.removeAllDisplayData = function () {
for (var name in this._displayDataDictionary) {
delete this._displayDataDictionary[name];
}
};
return DragonBonesData;
})();
dragonBones.DragonBonesData = DragonBonesData;
egret.registerClass(DragonBonesData,'dragonBones.DragonBonesData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var Frame = (function () {
function Frame() {
this.position = 0;
this.duration = 0;
this.position = 0;
this.duration = 0;
}
var d = __define,c=Frame,p=c.prototype;
p.dispose = function () {
};
return Frame;
})();
dragonBones.Frame = Frame;
egret.registerClass(Frame,'dragonBones.Frame');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SkinData = (function () {
function SkinData() {
this._slotDataList = [];
}
var d = __define,c=SkinData,p=c.prototype;
p.dispose = function () {
var i = this._slotDataList.length;
while (i--) {
this._slotDataList[i].dispose();
}
this._slotDataList = null;
};
p.getSlotData = function (slotName) {
var i = this._slotDataList.length;
while (i--) {
if (this._slotDataList[i].name == slotName) {
return this._slotDataList[i];
}
}
return null;
};
p.addSlotData = function (slotData) {
if (!slotData) {
throw new Error();
}
if (this._slotDataList.indexOf(slotData) < 0) {
this._slotDataList[this._slotDataList.length] = slotData;
}
else {
throw new Error();
}
};
d(p, "slotDataList"
,function () {
return this._slotDataList;
}
);
return SkinData;
})();
dragonBones.SkinData = SkinData;
egret.registerClass(SkinData,'dragonBones.SkinData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SlotData = (function () {
function SlotData() {
this._displayDataList = [];
this.zOrder = 0;
}
var d = __define,c=SlotData,p=c.prototype;
p.dispose = function () {
this._displayDataList.length = 0;
};
p.addDisplayData = function (displayData) {
if (!displayData) {
throw new Error();
}
if (this._displayDataList.indexOf(displayData) < 0) {
this._displayDataList[this._displayDataList.length] = displayData;
}
else {
throw new Error();
}
};
p.getDisplayData = function (displayName) {
var i = this._displayDataList.length;
while (i--) {
if (this._displayDataList[i].name == displayName) {
return this._displayDataList[i];
}
}
return null;
};
d(p, "displayDataList"
,function () {
return this._displayDataList;
}
);
return SlotData;
})();
dragonBones.SlotData = SlotData;
egret.registerClass(SlotData,'dragonBones.SlotData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SlotFrame = (function (_super) {
__extends(SlotFrame, _super);
function SlotFrame() {
_super.call(this);
this.displayIndex = 0;
this.tweenEasing = 10;
this.displayIndex = 0;
this.visible = true;
this.zOrder = NaN;
}
var d = __define,c=SlotFrame,p=c.prototype;
p.dispose = function () {
_super.prototype.dispose.call(this);
this.color = null;
};
return SlotFrame;
})(dragonBones.Frame);
dragonBones.SlotFrame = SlotFrame;
egret.registerClass(SlotFrame,'dragonBones.SlotFrame');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var SlotTimeline = (function (_super) {
__extends(SlotTimeline, _super);
function SlotTimeline() {
_super.call(this);
this.offset = 0;
}
var d = __define,c=SlotTimeline,p=c.prototype;
p.dispose = function () {
_super.prototype.dispose.call(this);
};
return SlotTimeline;
})(dragonBones.Timeline);
dragonBones.SlotTimeline = SlotTimeline;
egret.registerClass(SlotTimeline,'dragonBones.SlotTimeline');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var TransformFrame = (function (_super) {
__extends(TransformFrame, _super);
function TransformFrame() {
_super.call(this);
this.tweenRotate = 0;
this.displayIndex = 0;
this.tweenEasing = 10;
this.tweenRotate = 0;
this.tweenScale = true;
this.displayIndex = 0;
this.visible = true;
this.zOrder = NaN;
this.global = new dragonBones.DBTransform();
this.transform = new dragonBones.DBTransform();
this.pivot = new dragonBones.Point();
this.scaleOffset = new dragonBones.Point();
}
var d = __define,c=TransformFrame,p=c.prototype;
p.dispose = function () {
_super.prototype.dispose.call(this);
this.global = null;
this.transform = null;
this.pivot = null;
this.scaleOffset = null;
this.color = null;
};
return TransformFrame;
})(dragonBones.Frame);
dragonBones.TransformFrame = TransformFrame;
egret.registerClass(TransformFrame,'dragonBones.TransformFrame');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var TransformTimeline = (function (_super) {
__extends(TransformTimeline, _super);
function TransformTimeline() {
_super.call(this);
this.originTransform = new dragonBones.DBTransform();
this.originTransform.scaleX = 1;
this.originTransform.scaleY = 1;
this.originPivot = new dragonBones.Point();
this.offset = 0;
}
var d = __define,c=TransformTimeline,p=c.prototype;
p.dispose = function () {
_super.prototype.dispose.call(this);
this.originTransform = null;
this.originPivot = null;
};
return TransformTimeline;
})(dragonBones.Timeline);
dragonBones.TransformTimeline = TransformTimeline;
egret.registerClass(TransformTimeline,'dragonBones.TransformTimeline');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var TextureData = (function () {
function TextureData(region, frame, rotated) {
this.region = region;
this.frame = frame;
this.rotated = rotated;
}
var d = __define,c=TextureData,p=c.prototype;
return TextureData;
})();
dragonBones.TextureData = TextureData;
egret.registerClass(TextureData,'dragonBones.TextureData');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var ColorTransformUtil = (function () {
function ColorTransformUtil() {
}
var d = __define,c=ColorTransformUtil,p=c.prototype;
ColorTransformUtil.cloneColor = function (color) {
var c = new dragonBones.ColorTransform();
c.redMultiplier = color.redMultiplier;
c.greenMultiplier = color.greenMultiplier;
c.blueMultiplier = color.blueMultiplier;
c.alphaMultiplier = color.alphaMultiplier;
c.redOffset = color.redOffset;
c.greenOffset = color.greenOffset;
c.blueOffset = color.blueOffset;
c.alphaOffset = color.alphaOffset;
return c;
};
ColorTransformUtil.isEqual = function (color1, color2) {
return color1.alphaOffset == color2.alphaOffset &&
color1.redOffset == color2.redOffset &&
color1.greenOffset == color2.greenOffset &&
color1.blueOffset == color2.blueOffset &&
color1.alphaMultiplier == color2.alphaMultiplier &&
color1.redMultiplier == color2.redMultiplier &&
color1.greenMultiplier == color2.greenMultiplier &&
color1.blueMultiplier == color2.blueMultiplier;
};
ColorTransformUtil.minus = function (color1, color2, outputColor) {
outputColor.alphaOffset = color1.alphaOffset - color2.alphaOffset;
outputColor.redOffset = color1.redOffset - color2.redOffset;
outputColor.greenOffset = color1.greenOffset - color2.greenOffset;
outputColor.blueOffset = color1.blueOffset - color2.blueOffset;
outputColor.alphaMultiplier = color1.alphaMultiplier - color2.alphaMultiplier;
outputColor.redMultiplier = color1.redMultiplier - color2.redMultiplier;
outputColor.greenMultiplier = color1.greenMultiplier - color2.greenMultiplier;
outputColor.blueMultiplier = color1.blueMultiplier - color2.blueMultiplier;
};
ColorTransformUtil.originalColor = new dragonBones.ColorTransform();
return ColorTransformUtil;
})();
dragonBones.ColorTransformUtil = ColorTransformUtil;
egret.registerClass(ColorTransformUtil,'dragonBones.ColorTransformUtil');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var ConstValues = (function () {
function ConstValues() {
}
var d = __define,c=ConstValues,p=c.prototype;
ConstValues.ANGLE_TO_RADIAN = Math.PI / 180;
ConstValues.RADIAN_TO_ANGLE = 180 / Math.PI;
ConstValues.DRAGON_BONES = "dragonBones";
ConstValues.ARMATURE = "armature";
ConstValues.SKIN = "skin";
ConstValues.BONE = "bone";
ConstValues.SLOT = "slot";
ConstValues.DISPLAY = "display";
ConstValues.ANIMATION = "animation";
ConstValues.TIMELINE = "timeline";
ConstValues.FRAME = "frame";
ConstValues.TRANSFORM = "transform";
ConstValues.COLOR_TRANSFORM = "colorTransform";
ConstValues.COLOR = "color";
ConstValues.RECTANGLE = "rectangle";
ConstValues.ELLIPSE = "ellipse";
ConstValues.TEXTURE_ATLAS = "TextureAtlas";
ConstValues.SUB_TEXTURE = "SubTexture";
ConstValues.A_ROTATED = "rotated";
ConstValues.A_FRAME_X = "frameX";
ConstValues.A_FRAME_Y = "frameY";
ConstValues.A_FRAME_WIDTH = "frameWidth";
ConstValues.A_FRAME_HEIGHT = "frameHeight";
ConstValues.A_VERSION = "version";
ConstValues.A_IMAGE_PATH = "imagePath";
ConstValues.A_FRAME_RATE = "frameRate";
ConstValues.A_NAME = "name";
ConstValues.A_IS_GLOBAL = "isGlobal";
ConstValues.A_PARENT = "parent";
ConstValues.A_LENGTH = "length";
ConstValues.A_TYPE = "type";
ConstValues.A_FADE_IN_TIME = "fadeInTime";
ConstValues.A_DURATION = "duration";
ConstValues.A_SCALE = "scale";
ConstValues.A_OFFSET = "offset";
ConstValues.A_LOOP = "loop";
ConstValues.A_PLAY_TIMES = "playTimes";
ConstValues.A_EVENT = "event";
ConstValues.A_EVENT_PARAMETERS = "eventParameters";
ConstValues.A_SOUND = "sound";
ConstValues.A_ACTION = "action";
ConstValues.A_HIDE = "hide";
ConstValues.A_AUTO_TWEEN = "autoTween";
ConstValues.A_TWEEN_EASING = "tweenEasing";
ConstValues.A_TWEEN_ROTATE = "tweenRotate";
ConstValues.A_TWEEN_SCALE = "tweenScale";
ConstValues.A_DISPLAY_INDEX = "displayIndex";
ConstValues.A_Z_ORDER = "z";
ConstValues.A_BLENDMODE = "blendMode";
ConstValues.A_WIDTH = "width";
ConstValues.A_HEIGHT = "height";
ConstValues.A_INHERIT_SCALE = "inheritScale";
ConstValues.A_INHERIT_ROTATION = "inheritRotation";
ConstValues.A_X = "x";
ConstValues.A_Y = "y";
ConstValues.A_SKEW_X = "skX";
ConstValues.A_SKEW_Y = "skY";
ConstValues.A_SCALE_X = "scX";
ConstValues.A_SCALE_Y = "scY";
ConstValues.A_PIVOT_X = "pX";
ConstValues.A_PIVOT_Y = "pY";
ConstValues.A_ALPHA_OFFSET = "aO";
ConstValues.A_RED_OFFSET = "rO";
ConstValues.A_GREEN_OFFSET = "gO";
ConstValues.A_BLUE_OFFSET = "bO";
ConstValues.A_ALPHA_MULTIPLIER = "aM";
ConstValues.A_RED_MULTIPLIER = "rM";
ConstValues.A_GREEN_MULTIPLIER = "gM";
ConstValues.A_BLUE_MULTIPLIER = "bM";
ConstValues.A_CURVE = "curve";
ConstValues.A_SCALE_X_OFFSET = "scXOffset";
ConstValues.A_SCALE_Y_OFFSET = "scYOffset";
ConstValues.A_SCALE_MODE = "scaleMode";
ConstValues.A_FIXED_ROTATION = "fixedRotation";
return ConstValues;
})();
dragonBones.ConstValues = ConstValues;
egret.registerClass(ConstValues,'dragonBones.ConstValues');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var DBDataUtil = (function () {
function DBDataUtil() {
}
var d = __define,c=DBDataUtil,p=c.prototype;
DBDataUtil.transformArmatureData = function (armatureData) {
var boneDataList = armatureData.boneDataList;
var i = boneDataList.length;
while (i--) {
var boneData = boneDataList[i];
if (boneData.parent) {
var parentBoneData = armatureData.getBoneData(boneData.parent);
if (parentBoneData) {
boneData.transform.copy(boneData.global);
dragonBones.TransformUtil.globalToLocal(boneData.transform, parentBoneData.global);
}
}
}
};
DBDataUtil.transformArmatureDataAnimations = function (armatureData) {
var animationDataList = armatureData.animationDataList;
var i = animationDataList.length;
while (i--) {
DBDataUtil.transformAnimationData(animationDataList[i], armatureData, false);
}
};
DBDataUtil.transformRelativeAnimationData = function (animationData, armatureData) {
};
DBDataUtil.transformAnimationData = function (animationData, armatureData, isGlobalData) {
if (!isGlobalData) {
DBDataUtil.transformRelativeAnimationData(animationData, armatureData);
return;
}
var skinData = armatureData.getSkinData(null);
var boneDataList = armatureData.boneDataList;
var slotDataList;
if (skinData) {
slotDataList = skinData.slotDataList;
}
for (var i = 0; i < boneDataList.length; i++) {
var boneData = boneDataList[i];
var timeline = animationData.getTimeline(boneData.name);
var slotTimeline = animationData.getSlotTimeline(boneData.name);
if (!timeline && !slotTimeline) {
continue;
}
var slotData = null;
if (slotDataList) {
for (var j = 0, jLen = slotDataList.length; j < jLen; j++) {
slotData = slotDataList[j];
if (slotData.parent == boneData.name) {
break;
}
}
}
var frameList = timeline.frameList;
if (slotTimeline) {
var slotFrameList = slotTimeline.frameList;
}
var originTransform = null;
var originPivot = null;
var prevFrame = null;
var frameListLength = frameList.length;
for (var j = 0; j < frameListLength; j++) {
var frame = (frameList[j]);
DBDataUtil.setFrameTransform(animationData, armatureData, boneData, frame);
frame.transform.x -= boneData.transform.x;
frame.transform.y -= boneData.transform.y;
frame.transform.skewX -= boneData.transform.skewX;
frame.transform.skewY -= boneData.transform.skewY;
frame.transform.scaleX /= boneData.transform.scaleX;
frame.transform.scaleY /= boneData.transform.scaleY;
if (prevFrame) {
var dLX = frame.transform.skewX - prevFrame.transform.skewX;
if (prevFrame.tweenRotate) {
if (prevFrame.tweenRotate > 0) {
if (dLX < 0) {
frame.transform.skewX += Math.PI * 2;
frame.transform.skewY += Math.PI * 2;
}
if (prevFrame.tweenRotate > 1) {
frame.transform.skewX += Math.PI * 2 * (prevFrame.tweenRotate - 1);
frame.transform.skewY += Math.PI * 2 * (prevFrame.tweenRotate - 1);
}
}
else {
if (dLX > 0) {
frame.transform.skewX -= Math.PI * 2;
frame.transform.skewY -= Math.PI * 2;
}
if (prevFrame.tweenRotate < 1) {
frame.transform.skewX += Math.PI * 2 * (prevFrame.tweenRotate + 1);
frame.transform.skewY += Math.PI * 2 * (prevFrame.tweenRotate + 1);
}
}
}
else {
frame.transform.skewX = prevFrame.transform.skewX + dragonBones.TransformUtil.formatRadian(frame.transform.skewX - prevFrame.transform.skewX);
frame.transform.skewY = prevFrame.transform.skewY + dragonBones.TransformUtil.formatRadian(frame.transform.skewY - prevFrame.transform.skewY);
}
}
prevFrame = frame;
}
if (slotTimeline && slotFrameList) {
frameListLength = slotFrameList.length;
for (var j = 0; j < frameListLength; j++) {
var slotFrame = slotFrameList[j];
if (!slotTimeline.transformed) {
if (slotData) {
slotFrame.zOrder -= slotData.zOrder;
}
}
}
slotTimeline.transformed = true;
}
timeline.transformed = true;
}
};
DBDataUtil.setFrameTransform = function (animationData, armatureData, boneData, frame) {
frame.transform.copy(frame.global);
var parentData = armatureData.getBoneData(boneData.parent);
if (parentData) {
var parentTimeline = animationData.getTimeline(parentData.name);
if (parentTimeline) {
var parentTimelineList = [];
var parentDataList = [];
while (parentTimeline) {
parentTimelineList.push(parentTimeline);
parentDataList.push(parentData);
parentData = armatureData.getBoneData(parentData.parent);
if (parentData) {
parentTimeline = animationData.getTimeline(parentData.name);
}
else {
parentTimeline = null;
}
}
var i = parentTimelineList.length;
var globalTransform;
var globalTransformMatrix = new dragonBones.Matrix();
var currentTransform = new dragonBones.DBTransform();
var currentTransformMatrix = new dragonBones.Matrix();
while (i--) {
parentTimeline = parentTimelineList[i];
parentData = parentDataList[i];
DBDataUtil.getTimelineTransform(parentTimeline, frame.position, currentTransform, !globalTransform);
if (!globalTransform) {
globalTransform = new dragonBones.DBTransform();
globalTransform.copy(currentTransform);
}
else {
currentTransform.x += parentTimeline.originTransform.x + parentData.transform.x;
currentTransform.y += parentTimeline.originTransform.y + parentData.transform.y;
currentTransform.skewX += parentTimeline.originTransform.skewX + parentData.transform.skewX;
currentTransform.skewY += parentTimeline.originTransform.skewY + parentData.transform.skewY;
currentTransform.scaleX *= parentTimeline.originTransform.scaleX * parentData.transform.scaleX;
currentTransform.scaleY *= parentTimeline.originTransform.scaleY * parentData.transform.scaleY;
dragonBones.TransformUtil.transformToMatrix(currentTransform, currentTransformMatrix, true);
currentTransformMatrix.concat(globalTransformMatrix);
dragonBones.TransformUtil.matrixToTransform(currentTransformMatrix, globalTransform, currentTransform.scaleX * globalTransform.scaleX >= 0, currentTransform.scaleY * globalTransform.scaleY >= 0);
}
dragonBones.TransformUtil.transformToMatrix(globalTransform, globalTransformMatrix, true);
}
dragonBones.TransformUtil.globalToLocal(frame.transform, globalTransform);
}
}
};
DBDataUtil.getTimelineTransform = function (timeline, position, retult, isGlobal) {
var frameList = timeline.frameList;
var i = frameList.length;
while (i--) {
var currentFrame = (frameList[i]);
if (currentFrame.position <= position && currentFrame.position + currentFrame.duration > position) {
if (i == frameList.length - 1 || position == currentFrame.position) {
retult.copy(isGlobal ? currentFrame.global : currentFrame.transform);
}
else {
var tweenEasing = currentFrame.tweenEasing;
var progress = (position - currentFrame.position) / currentFrame.duration;
if (tweenEasing && tweenEasing != 10) {
progress = dragonBones.MathUtil.getEaseValue(progress, tweenEasing);
}
var nextFrame = frameList[i + 1];
var currentTransform = isGlobal ? currentFrame.global : currentFrame.transform;
var nextTransform = isGlobal ? nextFrame.global : nextFrame.transform;
retult.x = currentTransform.x + (nextTransform.x - currentTransform.x) * progress;
retult.y = currentTransform.y + (nextTransform.y - currentTransform.y) * progress;
retult.skewX = dragonBones.TransformUtil.formatRadian(currentTransform.skewX + (nextTransform.skewX - currentTransform.skewX) * progress);
retult.skewY = dragonBones.TransformUtil.formatRadian(currentTransform.skewY + (nextTransform.skewY - currentTransform.skewY) * progress);
retult.scaleX = currentTransform.scaleX + (nextTransform.scaleX - currentTransform.scaleX) * progress;
retult.scaleY = currentTransform.scaleY + (nextTransform.scaleY - currentTransform.scaleY) * progress;
}
break;
}
}
};
DBDataUtil.addHideTimeline = function (animationData, armatureData, addHideSlot) {
if (addHideSlot === void 0) { addHideSlot = false; }
var boneDataList = armatureData.boneDataList;
var slotDataList = armatureData.slotDataList;
var i = boneDataList.length;
while (i--) {
var boneData = boneDataList[i];
var boneName = boneData.name;
if (!animationData.getTimeline(boneName)) {
if (animationData.hideTimelineNameMap.indexOf(boneName) < 0) {
animationData.hideTimelineNameMap.push(boneName);
}
}
}
if (addHideSlot) {
i = slotDataList.length;
var slotData;
var slotName;
while (i--) {
slotData = slotDataList[i];
slotName = slotData.name;
if (!animationData.getSlotTimeline(slotName)) {
if (animationData.hideSlotTimelineNameMap.indexOf(slotName) < 0) {
animationData.hideSlotTimelineNameMap.push(slotName);
}
}
}
}
};
return DBDataUtil;
})();
dragonBones.DBDataUtil = DBDataUtil;
egret.registerClass(DBDataUtil,'dragonBones.DBDataUtil');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var MathUtil = (function () {
function MathUtil() {
}
var d = __define,c=MathUtil,p=c.prototype;
MathUtil.getEaseValue = function (value, easing) {
var valueEase = 1;
if (easing > 1) {
valueEase = 0.5 * (1 - MathUtil.cos(value * Math.PI));
easing -= 1;
}
else if (easing > 0) {
valueEase = 1 - Math.pow(1 - value, 2);
}
else if (easing < 0) {
easing *= -1;
valueEase = Math.pow(value, 2);
}
return (valueEase - value) * easing + value;
};
MathUtil.isNumber = function (value) {
return typeof (value) === "number" && !isNaN(value);
};
MathUtil.sin = function (value) {
value *= MathUtil.RADIAN_TO_ANGLE;
var valueFloor = Math.floor(value);
var valueCeil = valueFloor + 1;
var resultFloor = MathUtil.sinInt(valueFloor);
var resultCeil = MathUtil.sinInt(valueCeil);
return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor;
};
MathUtil.sinInt = function (value) {
value = value % 360;
if (value < 0) {
value += 360;
}
if (value < 90) {
return db_sin_map[value];
}
if (value < 180) {
return db_sin_map[180 - value];
}
if (value < 270) {
return -db_sin_map[value - 180];
}
return -db_sin_map[360 - value];
};
MathUtil.cos = function (value) {
return MathUtil.sin(Math.PI / 2 - value);
};
MathUtil.ANGLE_TO_RADIAN = Math.PI / 180;
MathUtil.RADIAN_TO_ANGLE = 180 / Math.PI;
return MathUtil;
})();
dragonBones.MathUtil = MathUtil;
egret.registerClass(MathUtil,'dragonBones.MathUtil');
})(dragonBones || (dragonBones = {}));
var db_sin_map = {};
for (var dbMathIndex = 0; dbMathIndex <= 90; dbMathIndex++) {
db_sin_map[dbMathIndex] = Math.sin(dbMathIndex * dragonBones.MathUtil.ANGLE_TO_RADIAN);
}
var dragonBones;
(function (dragonBones) {
var TransformUtil = (function () {
function TransformUtil() {
}
var d = __define,c=TransformUtil,p=c.prototype;
TransformUtil.globalToLocal = function (transform, parent) {
TransformUtil.transformToMatrix(transform, TransformUtil._helpTransformMatrix, true);
TransformUtil.transformToMatrix(parent, TransformUtil._helpParentTransformMatrix, true);
TransformUtil._helpParentTransformMatrix.invert();
TransformUtil._helpTransformMatrix.concat(TransformUtil._helpParentTransformMatrix);
TransformUtil.matrixToTransform(TransformUtil._helpTransformMatrix, transform, transform.scaleX * parent.scaleX >= 0, transform.scaleY * parent.scaleY >= 0);
};
TransformUtil.transformToMatrix = function (transform, matrix, keepScale) {
if (keepScale === void 0) { keepScale = false; }
if (keepScale) {
matrix.a = transform.scaleX * dragonBones.MathUtil.cos(transform.skewY);
matrix.b = transform.scaleX * dragonBones.MathUtil.sin(transform.skewY);
matrix.c = -transform.scaleY * dragonBones.MathUtil.sin(transform.skewX);
matrix.d = transform.scaleY * dragonBones.MathUtil.cos(transform.skewX);
matrix.tx = transform.x;
matrix.ty = transform.y;
}
else {
matrix.a = dragonBones.MathUtil.cos(transform.skewY);
matrix.b = dragonBones.MathUtil.sin(transform.skewY);
matrix.c = -dragonBones.MathUtil.sin(transform.skewX);
matrix.d = dragonBones.MathUtil.cos(transform.skewX);
matrix.tx = transform.x;
matrix.ty = transform.y;
}
};
TransformUtil.matrixToTransform = function (matrix, transform, scaleXF, scaleYF) {
transform.x = matrix.tx;
transform.y = matrix.ty;
transform.scaleX = Math.sqrt(matrix.a * matrix.a + matrix.b * matrix.b) * (scaleXF ? 1 : -1);
transform.scaleY = Math.sqrt(matrix.d * matrix.d + matrix.c * matrix.c) * (scaleYF ? 1 : -1);
var skewXArray = [];
skewXArray[0] = Math.acos(matrix.d / transform.scaleY);
skewXArray[1] = -skewXArray[0];
skewXArray[2] = Math.asin(-matrix.c / transform.scaleY);
skewXArray[3] = skewXArray[2] >= 0 ? Math.PI - skewXArray[2] : skewXArray[2] - Math.PI;
if (Number(skewXArray[0]).toFixed(4) == Number(skewXArray[2]).toFixed(4) || Number(skewXArray[0]).toFixed(4) == Number(skewXArray[3]).toFixed(4)) {
transform.skewX = skewXArray[0];
}
else {
transform.skewX = skewXArray[1];
}
var skewYArray = [];
skewYArray[0] = Math.acos(matrix.a / transform.scaleX);
skewYArray[1] = -skewYArray[0];
skewYArray[2] = Math.asin(matrix.b / transform.scaleX);
skewYArray[3] = skewYArray[2] >= 0 ? Math.PI - skewYArray[2] : skewYArray[2] - Math.PI;
if (Number(skewYArray[0]).toFixed(4) == Number(skewYArray[2]).toFixed(4) || Number(skewYArray[0]).toFixed(4) == Number(skewYArray[3]).toFixed(4)) {
transform.skewY = skewYArray[0];
}
else {
transform.skewY = skewYArray[1];
}
};
TransformUtil.formatRadian = function (radian) {
if (radian > Math.PI) {
radian -= TransformUtil.DOUBLE_PI;
}
if (radian < -Math.PI) {
radian += TransformUtil.DOUBLE_PI;
}
return radian;
};
TransformUtil.normalizeRotation = function (rotation) {
rotation = (rotation + Math.PI) % (2 * Math.PI);
rotation = rotation > 0 ? rotation : 2 * Math.PI + rotation;
return rotation - Math.PI;
};
TransformUtil.HALF_PI = Math.PI * 0.5;
TransformUtil.DOUBLE_PI = Math.PI * 2;
TransformUtil._helpTransformMatrix = new dragonBones.Matrix();
TransformUtil._helpParentTransformMatrix = new dragonBones.Matrix();
return TransformUtil;
})();
dragonBones.TransformUtil = TransformUtil;
egret.registerClass(TransformUtil,'dragonBones.TransformUtil');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastAnimation = (function () {
function FastAnimation(armature) {
this.animationState = new dragonBones.FastAnimationState();
this._armature = armature;
this.animationState._armature = armature;
this.animationList = [];
this._animationDataObj = {};
this._isPlaying = false;
this._timeScale = 1;
}
var d = __define,c=FastAnimation,p=c.prototype;
p.dispose = function () {
if (!this._armature) {
return;
}
this._armature = null;
this._animationDataList = null;
this.animationList = null;
this.animationState = null;
};
p.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes) {
if (fadeInTime === void 0) { fadeInTime = -1; }
if (duration === void 0) { duration = -1; }
if (playTimes === void 0) { playTimes = NaN; }
if (!this._animationDataList) {
return null;
}
var animationData = this._animationDataObj[animationName];
if (!animationData) {
return null;
}
this._isPlaying = true;
fadeInTime = fadeInTime < 0 ? (animationData.fadeTime < 0 ? 0.3 : animationData.fadeTime) : fadeInTime;
var durationScale;
if (duration < 0) {
durationScale = animationData.scale < 0 ? 1 : animationData.scale;
}
else {
durationScale = duration * 1000 / animationData.duration;
}
playTimes = isNaN(playTimes) ? animationData.playTimes : playTimes;
this.animationState._fadeIn(animationData, playTimes, 1 / durationScale, fadeInTime);
if (this._armature.enableCache && this.animationCacheManager) {
this.animationState.animationCache = this.animationCacheManager.getAnimationCache(animationName);
}
var i = this._armature.slotHasChildArmatureList.length;
while (i--) {
var slot = this._armature.slotHasChildArmatureList[i];
var childArmature = slot.childArmature;
if (childArmature) {
childArmature.getAnimation().gotoAndPlay(animationName);
}
}
return this.animationState;
};
p.gotoAndStop = function (animationName, time, normalizedTime, fadeInTime, duration) {
if (normalizedTime === void 0) { normalizedTime = -1; }
if (fadeInTime === void 0) { fadeInTime = 0; }
if (duration === void 0) { duration = -1; }
if (this.animationState.name != animationName) {
this.gotoAndPlay(animationName, fadeInTime, duration);
}
if (normalizedTime >= 0) {
this.animationState.setCurrentTime(this.animationState.totalTime * normalizedTime);
}
else {
this.animationState.setCurrentTime(time);
}
this.animationState.stop();
return this.animationState;
};
p.play = function () {
if (!this._animationDataList) {
return;
}
if (!this.animationState.name) {
this.gotoAndPlay(this._animationDataList[0].name);
}
else if (!this._isPlaying) {
this._isPlaying = true;
}
else {
this.gotoAndPlay(this.animationState.name);
}
};
p.stop = function () {
this._isPlaying = false;
};
p.advanceTime = function (passedTime) {
if (!this._isPlaying) {
return;
}
this.animationState._advanceTime(passedTime * this._timeScale);
};
p.hasAnimation = function (animationName) {
return this._animationDataObj[animationName] != null;
};
d(p, "timeScale"
,function () {
return this._timeScale;
}
,function (value) {
if (isNaN(value) || value < 0) {
value = 1;
}
this._timeScale = value;
}
);
d(p, "animationDataList"
,function () {
return this._animationDataList;
}
,function (value) {
this._animationDataList = value;
this.animationList.length = 0;
var length = this._animationDataList.length;
for (var i = 0; i < length; i++) {
var animationData = this._animationDataList[i];
this.animationList.push(animationData.name);
this._animationDataObj[animationData.name] = animationData;
}
}
);
d(p, "movementList"
,function () {
return this.animationList;
}
);
d(p, "movementID"
,function () {
return this.lastAnimationName;
}
);
p.isPlaying = function () {
return this._isPlaying && !this.isComplete;
};
d(p, "isComplete"
,function () {
return this.animationState.isComplete;
}
);
d(p, "lastAnimationState"
,function () {
return this.animationState;
}
);
d(p, "lastAnimationName"
,function () {
return this.animationState ? this.animationState.name : null;
}
);
return FastAnimation;
})();
dragonBones.FastAnimation = FastAnimation;
egret.registerClass(FastAnimation,'dragonBones.FastAnimation');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastAnimationState = (function () {
function FastAnimationState() {
this._boneTimelineStateList = [];
this._slotTimelineStateList = [];
this._currentFrameIndex = 0;
this._currentFramePosition = 0;
this._currentFrameDuration = 0;
this._currentPlayTimes = 0;
this._totalTime = 0;
this._currentTime = 0;
this._lastTime = 0;
this._playTimes = 0;
this._fading = false;
}
var d = __define,c=FastAnimationState,p=c.prototype;
p.dispose = function () {
this._resetTimelineStateList();
this._armature = null;
};
p.play = function () {
this._isPlaying = true;
return this;
};
p.stop = function () {
this._isPlaying = false;
return this;
};
p.setCurrentTime = function (value) {
if (value < 0 || isNaN(value)) {
value = 0;
}
this._time = value;
this._currentTime = this._time * 1000;
return this;
};
p._resetTimelineStateList = function () {
var i = this._boneTimelineStateList.length;
while (i--) {
dragonBones.FastBoneTimelineState.returnObject(this._boneTimelineStateList[i]);
}
this._boneTimelineStateList.length = 0;
i = this._slotTimelineStateList.length;
while (i--) {
dragonBones.FastSlotTimelineState.returnObject(this._slotTimelineStateList[i]);
}
this._slotTimelineStateList.length = 0;
this.name = null;
};
p._fadeIn = function (aniData, playTimes, timeScale, fadeTotalTime) {
this.animationData = aniData;
this.name = this.animationData.name;
this._totalTime = this.animationData.duration;
this.autoTween = aniData.autoTween;
this.setTimeScale(timeScale);
this.setPlayTimes(playTimes);
this._isComplete = false;
this._currentFrameIndex = -1;
this._currentPlayTimes = -1;
if (Math.round(this._totalTime * this.animationData.frameRate * 0.001) < 2) {
this._currentTime = this._totalTime;
}
else {
this._currentTime = -1;
}
this._fadeTotalTime = fadeTotalTime * this._timeScale;
this._fading = this._fadeTotalTime > 0;
this._isPlaying = true;
if (this._armature.enableCache && this.animationCache && this._fading && this._boneTimelineStateList) {
this.updateTransformTimeline(this.progress);
}
this._time = 0;
this._progress = 0;
this._updateTimelineStateList();
this.hideBones();
return;
};
p._updateTimelineStateList = function () {
this._resetTimelineStateList();
var timelineName;
var length = this.animationData.timelineList.length;
for (var i = 0; i < length; i++) {
var boneTimeline = this.animationData.timelineList[i];
timelineName = boneTimeline.name;
var bone = this._armature.getBone(timelineName);
if (bone) {
var boneTimelineState = dragonBones.FastBoneTimelineState.borrowObject();
boneTimelineState.fadeIn(bone, this, boneTimeline);
this._boneTimelineStateList.push(boneTimelineState);
}
}
var length1 = this.animationData.slotTimelineList.length;
for (var i1 = 0; i1 < length1; i1++) {
var slotTimeline = this.animationData.slotTimelineList[i1];
timelineName = slotTimeline.name;
var slot = this._armature.getSlot(timelineName);
if (slot && slot.displayList.length > 0) {
var slotTimelineState = dragonBones.FastSlotTimelineState.borrowObject();
slotTimelineState.fadeIn(slot, this, slotTimeline);
this._slotTimelineStateList.push(slotTimelineState);
}
}
};
p._advanceTime = function (passedTime) {
passedTime *= this._timeScale;
if (this._fading) {
this._time += passedTime;
this._progress = this._time / this._fadeTotalTime;
if (this._progress >= 1) {
this._progress = 0;
this._time = 0;
this._fading = false;
}
}
if (this._fading) {
var length = this._boneTimelineStateList.length;
for (var i = 0; i < length; i++) {
var timeline = this._boneTimelineStateList[i];
timeline.updateFade(this.progress);
}
var length1 = this._slotTimelineStateList.length;
for (var i1 = 0; i1 < length1; i1++) {
var slotTimeline = this._slotTimelineStateList[i1];
slotTimeline.updateFade(this.progress);
}
}
else {
this.advanceTimelinesTime(passedTime);
}
};
p.advanceTimelinesTime = function (passedTime) {
if (this._isPlaying) {
this._time += passedTime;
}
var startFlg = false;
var loopCompleteFlg = false;
var completeFlg = false;
var isThisComplete = false;
var currentPlayTimes = 0;
var currentTime = this._time * 1000;
if (this._playTimes == 0 ||
currentTime < this._playTimes * this._totalTime) {
isThisComplete = false;
this._progress = currentTime / this._totalTime;
currentPlayTimes = Math.ceil(this.progress) || 1;
this._progress -= Math.floor(this.progress);
currentTime %= this._totalTime;
}
else {
currentPlayTimes = this._playTimes;
currentTime = this._totalTime;
isThisComplete = true;
this._progress = 1;
}
this._isComplete = isThisComplete;
if (this.isUseCache()) {
this.animationCache.update(this.progress);
}
else {
this.updateTransformTimeline(this.progress);
}
if (this._currentTime != currentTime) {
if (this._currentPlayTimes != currentPlayTimes) {
if (this._currentPlayTimes > 0 && currentPlayTimes > 1) {
loopCompleteFlg = true;
}
this._currentPlayTimes = currentPlayTimes;
}
if (this._currentTime < 0) {
startFlg = true;
}
if (this._isComplete) {
completeFlg = true;
}
this._lastTime = this._currentTime;
this._currentTime = currentTime;
this.updateMainTimeline(isThisComplete);
}
var event;
if (startFlg) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.START)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.START);
event.animationState = this;
this._armature._addEvent(event);
}
}
if (completeFlg) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.COMPLETE)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.COMPLETE);
event.animationState = this;
this._armature._addEvent(event);
}
}
else if (loopCompleteFlg) {
if (this._armature.hasEventListener(dragonBones.AnimationEvent.LOOP_COMPLETE)) {
event = new dragonBones.AnimationEvent(dragonBones.AnimationEvent.LOOP_COMPLETE);
event.animationState = this;
this._armature._addEvent(event);
}
}
};
p.updateTransformTimeline = function (progress) {
var i = this._boneTimelineStateList.length;
var boneTimeline;
var slotTimeline;
if (this._isComplete) {
while (i--) {
boneTimeline = this._boneTimelineStateList[i];
boneTimeline.update(progress);
this._isComplete = boneTimeline._isComplete && this._isComplete;
}
i = this._slotTimelineStateList.length;
while (i--) {
slotTimeline = this._slotTimelineStateList[i];
slotTimeline.update(progress);
this._isComplete = slotTimeline._isComplete && this._isComplete;
}
}
else {
while (i--) {
boneTimeline = this._boneTimelineStateList[i];
boneTimeline.update(progress);
}
i = this._slotTimelineStateList.length;
while (i--) {
slotTimeline = this._slotTimelineStateList[i];
slotTimeline.update(progress);
}
}
};
p.updateMainTimeline = function (isThisComplete) {
var frameList = this.animationData.frameList;
if (frameList.length > 0) {
var prevFrame;
var currentFrame;
for (var i = 0, l = this.animationData.frameList.length; i < l; ++i) {
if (this._currentFrameIndex < 0) {
this._currentFrameIndex = 0;
}
else if (this._currentTime < this._currentFramePosition || this._currentTime >= this._currentFramePosition + this._currentFrameDuration || this._currentTime < this._lastTime) {
this._lastTime = this._currentTime;
this._currentFrameIndex++;
if (this._currentFrameIndex >= frameList.length) {
if (isThisComplete) {
this._currentFrameIndex--;
break;
}
else {
this._currentFrameIndex = 0;
}
}
}
else {
break;
}
currentFrame = frameList[this._currentFrameIndex];
if (prevFrame) {
this._armature.arriveAtFrame(prevFrame, this);
}
this._currentFrameDuration = currentFrame.duration;
this._currentFramePosition = currentFrame.position;
prevFrame = currentFrame;
}
if (currentFrame) {
this._armature.arriveAtFrame(currentFrame, this);
}
}
};
p.setTimeScale = function (value) {
if (isNaN(value) || value == Infinity) {
value = 1;
}
this._timeScale = value;
return this;
};
p.setPlayTimes = function (value) {
if (value === void 0) { value = 0; }
if (Math.round(this._totalTime * 0.001 * this.animationData.frameRate) < 2) {
this._playTimes = 1;
}
else {
this._playTimes = value;
}
return this;
};
d(p, "playTimes"
,function () {
return this._playTimes;
}
);
d(p, "currentPlayTimes"
,function () {
return this._currentPlayTimes < 0 ? 0 : this._currentPlayTimes;
}
);
d(p, "isComplete"
,function () {
return this._isComplete;
}
);
d(p, "isPlaying"
,function () {
return (this._isPlaying && !this._isComplete);
}
);
d(p, "totalTime"
,function () {
return this._totalTime * 0.001;
}
);
d(p, "currentTime"
,function () {
return this._currentTime < 0 ? 0 : this._currentTime * 0.001;
}
);
p.isUseCache = function () {
return this._armature.enableCache && this.animationCache && !this._fading;
};
p.hideBones = function () {
var length = this.animationData.hideTimelineNameMap.length;
for (var i = 0; i < length; i++) {
var timelineName = this.animationData.hideTimelineNameMap[i];
var bone = this._armature.getBone(timelineName);
if (bone) {
bone._hideSlots();
}
}
var slotTimelineName;
for (i = 0, length = this.animationData.hideSlotTimelineNameMap.length; i < length; i++) {
slotTimelineName = this.animationData.hideSlotTimelineNameMap[i];
var slot = this._armature.getSlot(slotTimelineName);
if (slot) {
slot._resetToOrigin();
}
}
};
d(p, "progress"
,function () {
return this._progress;
}
);
return FastAnimationState;
})();
dragonBones.FastAnimationState = FastAnimationState;
egret.registerClass(FastAnimationState,'dragonBones.FastAnimationState',["dragonBones.IAnimationState"]);
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastBoneTimelineState = (function () {
function FastBoneTimelineState() {
this._totalTime = 0;
this._currentTime = 0;
this._lastTime = 0;
this._currentFrameIndex = 0;
this._currentFramePosition = 0;
this._currentFrameDuration = 0;
this._updateMode = 0;
this._transform = new dragonBones.DBTransform();
this._durationTransform = new dragonBones.DBTransform();
this._transformToFadein = new dragonBones.DBTransform();
this._pivot = new dragonBones.Point();
this._durationPivot = new dragonBones.Point();
}
var d = __define,c=FastBoneTimelineState,p=c.prototype;
FastBoneTimelineState.borrowObject = function () {
if (FastBoneTimelineState._pool.length == 0) {
return new FastBoneTimelineState();
}
return FastBoneTimelineState._pool.pop();
};
FastBoneTimelineState.returnObject = function (timeline) {
if (FastBoneTimelineState._pool.indexOf(timeline) < 0) {
FastBoneTimelineState._pool[FastBoneTimelineState._pool.length] = timeline;
}
timeline.clear();
};
FastBoneTimelineState.clear = function () {
var i = FastBoneTimelineState._pool.length;
while (i--) {
FastBoneTimelineState._pool[i].clear();
}
FastBoneTimelineState._pool.length = 0;
};
p.clear = function () {
if (this._bone) {
this._bone._timelineState = null;
this._bone = null;
}
this._animationState = null;
this._timelineData = null;
this._originPivot = null;
};
p.fadeIn = function (bone, animationState, timelineData) {
this._bone = bone;
this._animationState = animationState;
this._timelineData = timelineData;
this.name = timelineData.name;
this._totalTime = this._timelineData.duration;
this._isComplete = false;
this._tweenTransform = false;
this._currentFrameIndex = -1;
this._currentTime = -1;
this._tweenEasing = NaN;
this._durationPivot.x = 0;
this._durationPivot.y = 0;
this._pivot.x = 0;
this._pivot.y = 0;
this._originPivot = this._timelineData.originPivot;
switch (this._timelineData.frameList.length) {
case 0:
this._updateMode = 0;
break;
case 1:
this._updateMode = 1;
break;
default:
this._updateMode = -1;
break;
}
if (animationState._fadeTotalTime > 0) {
var pivotToFadein;
if (this._bone._timelineState) {
this._transformToFadein.copy(this._bone._timelineState._transform);
}
else {
this._transformToFadein = new dragonBones.DBTransform();
}
var firstFrame = (this._timelineData.frameList[0]);
this._durationTransform.copy(firstFrame.transform);
this._durationTransform.minus(this._transformToFadein);
}
this._bone._timelineState = this;
};
p.updateFade = function (progress) {
this._transform.x = this._transformToFadein.x + this._durationTransform.x * progress;
this._transform.y = this._transformToFadein.y + this._durationTransform.y * progress;
this._transform.scaleX = this._transformToFadein.scaleX * (1 + (this._durationTransform.scaleX - 1) * progress);
this._transform.scaleY = this._transformToFadein.scaleX * (1 + (this._durationTransform.scaleY - 1) * progress);
this._transform.rotation = this._transformToFadein.rotation + this._durationTransform.rotation * progress;
this._bone.invalidUpdate();
};
p.update = function (progress) {
if (this._updateMode == 1) {
this._updateMode = 0;
this.updateSingleFrame();
}
else if (this._updateMode == -1) {
this.updateMultipleFrame(progress);
}
};
p.updateSingleFrame = function () {
var currentFrame = (this._timelineData.frameList[0]);
this._bone.arriveAtFrame(currentFrame, this._animationState);
this._isComplete = true;
this._tweenEasing = NaN;
this._tweenTransform = false;
this._pivot.x = this._originPivot.x + currentFrame.pivot.x;
this._pivot.y = this._originPivot.y + currentFrame.pivot.y;
this._transform.copy(currentFrame.transform);
this._bone.invalidUpdate();
};
p.updateMultipleFrame = function (progress) {
var currentPlayTimes = 0;
progress /= this._timelineData.scale;
progress += this._timelineData.offset;
var currentTime = this._totalTime * progress;
var playTimes = this._animationState.playTimes;
if (playTimes == 0) {
this._isComplete = false;
currentPlayTimes = Math.ceil(Math.abs(currentTime) / this._totalTime) || 1;
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
if (currentTime < 0) {
currentTime += this._totalTime;
}
}
else {
var totalTimes = playTimes * this._totalTime;
if (currentTime >= totalTimes) {
currentTime = totalTimes;
this._isComplete = true;
}
else if (currentTime <= -totalTimes) {
currentTime = -totalTimes;
this._isComplete = true;
}
else {
this._isComplete = false;
}
if (currentTime < 0) {
currentTime += totalTimes;
}
currentPlayTimes = Math.ceil(currentTime / this._totalTime) || 1;
if (this._isComplete) {
currentTime = this._totalTime;
}
else {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
}
if (this._currentTime != currentTime) {
this._lastTime = this._currentTime;
this._currentTime = currentTime;
var frameList = this._timelineData.frameList;
var prevFrame;
var currentFrame;
for (var i = 0, l = this._timelineData.frameList.length; i < l; ++i) {
if (this._currentFrameIndex < 0) {
this._currentFrameIndex = 0;
}
else if (this._currentTime < this._currentFramePosition || this._currentTime >= this._currentFramePosition + this._currentFrameDuration || this._currentTime < this._lastTime) {
this._currentFrameIndex++;
this._lastTime = this._currentTime;
if (this._currentFrameIndex >= frameList.length) {
if (this._isComplete) {
this._currentFrameIndex--;
break;
}
else {
this._currentFrameIndex = 0;
}
}
}
else {
break;
}
currentFrame = (frameList[this._currentFrameIndex]);
if (prevFrame) {
this._bone.arriveAtFrame(prevFrame, this._animationState);
}
this._currentFrameDuration = currentFrame.duration;
this._currentFramePosition = currentFrame.position;
prevFrame = currentFrame;
}
if (currentFrame) {
this._bone.arriveAtFrame(currentFrame, this._animationState);
this.updateToNextFrame(currentPlayTimes);
}
if (this._tweenTransform) {
this.updateTween();
}
}
};
p.updateToNextFrame = function (currentPlayTimes) {
if (currentPlayTimes === void 0) { currentPlayTimes = 0; }
var nextFrameIndex = this._currentFrameIndex + 1;
if (nextFrameIndex >= this._timelineData.frameList.length) {
nextFrameIndex = 0;
}
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
var nextFrame = (this._timelineData.frameList[nextFrameIndex]);
var tweenEnabled = false;
if (nextFrameIndex == 0 && (this._animationState.playTimes &&
this._animationState.currentPlayTimes >= this._animationState.playTimes &&
((this._currentFramePosition + this._currentFrameDuration) / this._totalTime + currentPlayTimes - this._timelineData.offset) * this._timelineData.scale > 0.999999)) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else if (this._animationState.autoTween) {
this._tweenEasing = this._animationState.animationData.tweenEasing;
if (isNaN(this._tweenEasing)) {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if (isNaN(this._tweenEasing) && this._tweenCurve == null) {
tweenEnabled = false;
}
else {
if (this._tweenEasing == 10) {
this._tweenEasing = 0;
}
tweenEnabled = true;
}
}
else {
tweenEnabled = true;
}
}
else {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if ((isNaN(this._tweenEasing) || this._tweenEasing == 10) && this._tweenCurve == null) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else {
tweenEnabled = true;
}
}
if (tweenEnabled) {
this._durationTransform.x = nextFrame.transform.x - currentFrame.transform.x;
this._durationTransform.y = nextFrame.transform.y - currentFrame.transform.y;
this._durationTransform.skewX = nextFrame.transform.skewX - currentFrame.transform.skewX;
this._durationTransform.skewY = nextFrame.transform.skewY - currentFrame.transform.skewY;
this._durationTransform.scaleX = nextFrame.transform.scaleX - currentFrame.transform.scaleX + nextFrame.scaleOffset.x;
this._durationTransform.scaleY = nextFrame.transform.scaleY - currentFrame.transform.scaleY + nextFrame.scaleOffset.y;
this._durationPivot.x = nextFrame.pivot.x - currentFrame.pivot.x;
this._durationPivot.y = nextFrame.pivot.y - currentFrame.pivot.y;
this._durationTransform.normalizeRotation();
if (nextFrameIndex == 0) {
this._durationTransform.skewX = dragonBones.TransformUtil.formatRadian(this._durationTransform.skewX);
this._durationTransform.skewY = dragonBones.TransformUtil.formatRadian(this._durationTransform.skewY);
}
if (this._durationTransform.x ||
this._durationTransform.y ||
this._durationTransform.skewX ||
this._durationTransform.skewY ||
this._durationTransform.scaleX != 1 ||
this._durationTransform.scaleY != 1 ||
this._durationPivot.x ||
this._durationPivot.y) {
this._tweenTransform = true;
}
else {
this._tweenTransform = false;
}
}
else {
this._tweenTransform = false;
}
if (!this._tweenTransform) {
this._transform.copy(currentFrame.transform);
this._pivot.x = this._originPivot.x + currentFrame.pivot.x;
this._pivot.y = this._originPivot.y + currentFrame.pivot.y;
this._bone.invalidUpdate();
}
};
p.updateTween = function () {
var progress = (this._currentTime - this._currentFramePosition) / this._currentFrameDuration;
if (this._tweenCurve) {
progress = this._tweenCurve.getValueByProgress(progress);
}
else if (this._tweenEasing) {
progress = dragonBones.MathUtil.getEaseValue(progress, this._tweenEasing);
}
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
var currentTransform = currentFrame.transform;
var currentPivot = currentFrame.pivot;
this._transform.x = currentTransform.x + this._durationTransform.x * progress;
this._transform.y = currentTransform.y + this._durationTransform.y * progress;
this._transform.skewX = currentTransform.skewX + this._durationTransform.skewX * progress;
this._transform.skewY = currentTransform.skewY + this._durationTransform.skewY * progress;
this._transform.scaleX = currentTransform.scaleX + this._durationTransform.scaleX * progress;
this._transform.scaleY = currentTransform.scaleY + this._durationTransform.scaleY * progress;
this._pivot.x = currentPivot.x + this._durationPivot.x * progress;
this._pivot.y = currentPivot.y + this._durationPivot.y * progress;
this._bone.invalidUpdate();
};
FastBoneTimelineState._pool = [];
return FastBoneTimelineState;
})();
dragonBones.FastBoneTimelineState = FastBoneTimelineState;
egret.registerClass(FastBoneTimelineState,'dragonBones.FastBoneTimelineState');
})(dragonBones || (dragonBones = {}));
var dragonBones;
(function (dragonBones) {
var FastSlotTimelineState = (function () {
function FastSlotTimelineState() {
this._totalTime = 0;
this._currentTime = 0;
this._currentFrameIndex = 0;
this._currentFramePosition = 0;
this._currentFrameDuration = 0;
this._updateMode = 0;
this._durationColor = new dragonBones.ColorTransform();
}
var d = __define,c=FastSlotTimelineState,p=c.prototype;
FastSlotTimelineState.borrowObject = function () {
if (FastSlotTimelineState._pool.length == 0) {
return new FastSlotTimelineState();
}
return FastSlotTimelineState._pool.pop();
};
FastSlotTimelineState.returnObject = function (timeline) {
if (FastSlotTimelineState._pool.indexOf(timeline) < 0) {
FastSlotTimelineState._pool[FastSlotTimelineState._pool.length] = timeline;
}
timeline.clear();
};
FastSlotTimelineState.clear = function () {
var i = FastSlotTimelineState._pool.length;
while (i--) {
FastSlotTimelineState._pool[i].clear();
}
FastSlotTimelineState._pool.length = 0;
};
p.clear = function () {
this._slot = null;
this._armature = null;
this._animation = null;
this._animationState = null;
this._timelineData = null;
};
p.fadeIn = function (slot, animationState, timelineData) {
this._slot = slot;
this._armature = this._slot.armature;
this._animation = this._armature.animation;
this._animationState = animationState;
this._timelineData = timelineData;
this.name = timelineData.name;
this._totalTime = this._timelineData.duration;
this._isComplete = false;
this._blendEnabled = false;
this._tweenColor = false;
this._currentFrameIndex = -1;
this._currentTime = -1;
this._tweenEasing = NaN;
this._weight = 1;
switch (this._timelineData.frameList.length) {
case 0:
this._updateMode = 0;
break;
case 1:
this._updateMode = 1;
break;
default:
this._updateMode = -1;
break;
}
};
p.updateFade = function (progress) {
};
p.update = function (progress) {
if (this._updateMode == -1) {
this.updateMultipleFrame(progress);
}
else if (this._updateMode == 1) {
this._updateMode = 0;
this.updateSingleFrame();
}
};
p.updateMultipleFrame = function (progress) {
var currentPlayTimes = 0;
progress /= this._timelineData.scale;
progress += this._timelineData.offset;
var currentTime = this._totalTime * progress;
var playTimes = this._animationState.playTimes;
if (playTimes == 0) {
this._isComplete = false;
currentPlayTimes = Math.ceil(Math.abs(currentTime) / this._totalTime) || 1;
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
if (currentTime < 0) {
currentTime += this._totalTime;
}
}
else {
var totalTimes = playTimes * this._totalTime;
if (currentTime >= totalTimes) {
currentTime = totalTimes;
this._isComplete = true;
}
else if (currentTime <= -totalTimes) {
currentTime = -totalTimes;
this._isComplete = true;
}
else {
this._isComplete = false;
}
if (currentTime < 0) {
currentTime += totalTimes;
}
currentPlayTimes = Math.ceil(currentTime / this._totalTime) || 1;
if (this._isComplete) {
currentTime = this._totalTime;
}
else {
currentTime -= Math.floor(currentTime / this._totalTime) * this._totalTime;
}
}
if (this._currentTime != currentTime) {
this._currentTime = currentTime;
var frameList = this._timelineData.frameList;
var prevFrame;
var currentFrame;
for (var i = 0, l = this._timelineData.frameList.length; i < l; ++i) {
if (this._currentFrameIndex < 0) {
this._currentFrameIndex = 0;
}
else if (this._currentTime < this._currentFramePosition || this._currentTime >= this._currentFramePosition + this._currentFrameDuration) {
this._currentFrameIndex++;
if (this._currentFrameIndex >= frameList.length) {
if (this._isComplete) {
this._currentFrameIndex--;
break;
}
else {
this._currentFrameIndex = 0;
}
}
}
else {
break;
}
currentFrame = (frameList[this._currentFrameIndex]);
if (prevFrame) {
this._slot._arriveAtFrame(prevFrame, this._animationState);
}
this._currentFrameDuration = currentFrame.duration;
this._currentFramePosition = currentFrame.position;
prevFrame = currentFrame;
}
if (currentFrame) {
this._slot._arriveAtFrame(currentFrame, this._animationState);
this._blendEnabled = currentFrame.displayIndex >= 0;
if (this._blendEnabled) {
this.updateToNextFrame(currentPlayTimes);
}
else {
this._tweenEasing = NaN;
this._tweenColor = false;
}
}
if (this._blendEnabled) {
this.updateTween();
}
}
};
p.updateToNextFrame = function (currentPlayTimes) {
if (currentPlayTimes === void 0) { currentPlayTimes = 0; }
var nextFrameIndex = this._currentFrameIndex + 1;
if (nextFrameIndex >= this._timelineData.frameList.length) {
nextFrameIndex = 0;
}
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
var nextFrame = (this._timelineData.frameList[nextFrameIndex]);
var tweenEnabled = false;
if (nextFrameIndex == 0 &&
(this._animationState.playTimes &&
this._animationState.currentPlayTimes >= this._animationState.playTimes &&
((this._currentFramePosition + this._currentFrameDuration) / this._totalTime + currentPlayTimes - this._timelineData.offset) * this._timelineData.scale > 0.999999)) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else if (currentFrame.displayIndex < 0 || nextFrame.displayIndex < 0) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else if (this._animationState.autoTween) {
this._tweenEasing = this._animationState.animationData.tweenEasing;
if (isNaN(this._tweenEasing)) {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if (isNaN(this._tweenEasing) && this._tweenCurve == null) {
tweenEnabled = false;
}
else {
if (this._tweenEasing == 10) {
this._tweenEasing = 0;
}
tweenEnabled = true;
}
}
else {
tweenEnabled = true;
}
}
else {
this._tweenEasing = currentFrame.tweenEasing;
this._tweenCurve = currentFrame.curve;
if ((isNaN(this._tweenEasing) || this._tweenEasing == 10) && this._tweenCurve == null) {
this._tweenEasing = NaN;
tweenEnabled = false;
}
else {
tweenEnabled = true;
}
}
if (tweenEnabled) {
if (currentFrame.color || nextFrame.color) {
dragonBones.ColorTransformUtil.minus(nextFrame.color || dragonBones.ColorTransformUtil.originalColor, currentFrame.color || dragonBones.ColorTransformUtil.originalColor, this._durationColor);
this._tweenColor = this._durationColor.alphaOffset != 0 ||
this._durationColor.redOffset != 0 ||
this._durationColor.greenOffset != 0 ||
this._durationColor.blueOffset != 0 ||
this._durationColor.alphaMultiplier != 0 ||
this._durationColor.redMultiplier != 0 ||
this._durationColor.greenMultiplier != 0 ||
this._durationColor.blueMultiplier != 0;
}
else {
this._tweenColor = false;
}
}
else {
this._tweenColor = false;
}
if (!this._tweenColor) {
var targetColor;
var colorChanged;
if (currentFrame.color) {
targetColor = currentFrame.color;
colorChanged = true;
}
else {
targetColor = dragonBones.ColorTransformUtil.originalColor;
colorChanged = false;
}
if ((this._slot._isColorChanged || colorChanged)) {
if (!dragonBones.ColorTransformUtil.isEqual(this._slot._colorTransform, targetColor)) {
this._slot._updateDisplayColor(targetColor.alphaOffset, targetColor.redOffset, targetColor.greenOffset, targetColor.blueOffset, targetColor.alphaMultiplier, targetColor.redMultiplier, targetColor.greenMultiplier, targetColor.blueMultiplier, colorChanged);
}
}
}
};
p.updateTween = function () {
var currentFrame = (this._timelineData.frameList[this._currentFrameIndex]);
if (this._tweenColor) {
var progress = (this._currentTime - this._currentFramePosition) / this._currentFrameDuration;
if (this._tweenCurve != null) {
progress = this._tweenCurve.getValueByProgress(progress);
}
else if (this._tweenEasing) {
progress = dragonBones.MathUtil.getEaseValue(progress, this._tweenEasing);
}
if (currentFrame.color) {
this._slot._updateDisplayColor(currentFrame.color.alphaOffset + this._durationColor.alphaOffset * progress, currentFrame.color.redOffset + this._durationColor.redOffset * progress, currentFrame.color.greenOffset + this._durationColor.greenOffset * progress, currentFrame.color.blueOffset + this._durationColor.blueOffset * progress, currentFrame.color.alphaMultiplier + this._durationColor.alphaMultiplier * progress, currentFrame.color.redMultiplier + this._durationColor.redMultiplier * progress, currentFrame.color.greenMultiplier + this._durationColor.greenMultiplier * progress, currentFrame.color.blueMultiplier + this._durationColor.blueMultiplier * progress, true);
}
else {
this._slot._updateDisplayColor(this._durationColor.alphaOffset * progress, this._durationColor.redOffset * progress, this._durationColor.greenOffset * progress, this._durationColor.blueOffset * progress, this._durationColor.alphaMultiplier * progress + 1, this._durationColor.redMultiplier * progress + 1, this._durationColor.greenMultiplier * progress + 1, this._durationColor.blueMultiplier * progress + 1, true);
}
}
};
p.updateSingleFrame = function () {
var currentFrame = (this._timelineData.frameList[0]);
this._slot._arriveAtFrame(currentFrame, this._animationState);
this._isComplete = true;
this._tweenEasing = NaN;
this._tweenColor = false;
this._blendEnabled = currentFrame.displayIndex >= 0;
if (this._blendEnabled) {
var targetColor;
var colorChanged;
if (currentFrame.color) {
targetColor = currentFrame.color;
colorChanged = true;
}
else {
targetColor = dragonBones.ColorTransformUtil.originalColor;
colorChanged = false;
}
if ((this._slot._isColorChanged || colorChanged)) {
if (!dragonBones.ColorTransformUtil.isEqual(this._slot._colorTransform, targetColor)) {
this._slot._updateDisplayColor(targetColor.alphaOffset, targetColor.redOffset, targetColor.greenOffset, targetColor.blueOffset, targetColor.alphaMultiplier, targetColor.redMultiplier, targetColor.greenMultiplier, targetColor.blueMultiplier, colorChanged);
}
}
}
};
FastSlotTimelineState.HALF_PI = Math.PI * 0.5;
FastSlotTimelineState.DOUBLE_PI = Math.PI * 2;
FastSlotTimelineState._pool = [];
return FastSlotTimelineState;
})();
dragonBones.FastSlotTimelineState = FastSlotTimelineState;
egret.registerClass(FastSlotTimelineState,'dragonBones.FastSlotTimelineState');
})(dragonBones || (dragonBones = {}));
(function(){
var DataParser = dragonBones.DataParser;
var TextureData = dragonBones.TextureData;
var TextureAtlas = function(texture, textureAtlasRawData, scale){
this._textureDatas = {};
this.scale = scale||1;
this.texture = texture;
this.name = textureAtlasRawData.name;
this.parseData(textureAtlasRawData);
};
TextureAtlas.rotatedDic = {};
TextureAtlas.prototype = {
constructor:TextureAtlas,
getTexture:function(fullName){
var data = this._textureDatas[fullName];
if(data){
data.texture = this.texture;
if(data.rotated)
{
TextureAtlas.rotatedDic[fullName] = 1;
}
}
return data;
},
dispose:function(){
this.texture = null;
this._textureDatas = {};
},
getRegion:function(subTextureName){
var textureData = this._textureDatas[subTextureName];
if(textureData && textureData instanceof TextureData){
return textureData.region;
}
return null;
},
getFrame:function(subTextureName){
var textureData = this._textureDatas[subTextureName];
if(textureData && textureData instanceof TextureData)
{
return textureData.frame;
}
return null;
},
parseData:function(textureAtlasRawData){
this._textureDatas = DataParser.parseTextureAtlasData(textureAtlasRawData, this.scale);
}
};
dragonBones.TextureAtlas = TextureAtlas;
})();
/**
* Hilo
* Copyright 2015 alibaba.com
* Licensed under the MIT License
*/
/**
* HiloSlot
*/
(function(superClass) {
var RAD2DEG = 180 / Math.PI;
var TextureAtlas = dragonBones.TextureAtlas;
var HiloSlot = function() {
superClass.call(this, this);
this._display = null;
};
__extends(HiloSlot, superClass, {
dispose: function() {
if (this._displayList) {
var length = this._displayList.length;
for (var i = 0; i < length; i++) {
var content = this._displayList[i];
if (content instanceof Armature) {
content.dispose();
}
}
}
superClass.prototype.dispose();
this._display = null;
},
_updateDisplay: function(value) {
this._display = value;
},
_getDisplayIndex: function() {
if (this._display && this._display.parent) {
return this._display.parent.getChildIndex(this._display);
}
return -1;
},
_addDisplayToContainer: function(container, index) {
if (this._display && container) {
if (index) {
container.addChildAt(this._display, index);
} else {
container.addChild(this._display);
}
}
},
_removeDisplayFromContainer: function() {
if (this._display && this._display.parent) {
this._display.parent.removeChild(this._display);
}
},
_updateTransform: function() {
if (this._display) {
var pivotX = this._display.pivotX;
var pivotY = this._display.pivotY;
var mat = this._display.transform;
mat.copy(this._globalTransformMatrix);
mat.tx = mat.tx - mat.a * pivotX - mat.c * pivotY;
mat.ty = mat.ty - mat.b * pivotX - mat.d * pivotY;
}
},
_updateDisplayVisible: function(value) {
if (this._display && this._parent) {
this._display.visible = this._parent._visible && this._visible && value;
}
},
_updateDisplayColor: function(aOffset, rOffset, gOffset, bOffset, aMultiplier, rMultiplier, gMultiplier, bMultiplier, colorChange) {
superClass.prototype._updateDisplayColor.call(this, aOffset, rOffset, gOffset, bOffset, aMultiplier, rMultiplier, gMultiplier, bMultiplier, colorChange);
if (this._display) {
this._display.alpha = aMultiplier;
}
},
_updateDisplayBlendMode: function(value) {
// if (this._display && value) {
// this._display.blendMode = value;
// }
},
_calculateRelativeParentTransform: function() {
this._global.scaleX = this._origin.scaleX * this._offset.scaleX;
this._global.scaleY = this._origin.scaleY * this._offset.scaleY;
this._global.skewX = this._origin.skewX + this._offset.skewX;
this._global.skewY = this._origin.skewY + this._offset.skewY;
this._global.x = this._origin.x + this._offset.x + this._parent._tweenPivot.x;
this._global.y = this._origin.y + this._offset.y + this._parent._tweenPivot.y;
if (this._displayDataList &&
this._currentDisplayIndex >= 0 &&
this._displayDataList[this._currentDisplayIndex] &&
TextureAtlas.rotatedDic[this._displayDataList[this._currentDisplayIndex].name] == 1) {
this._global.skewX -= 1.57;
this._global.skewY -= 1.57;
}
}
});
dragonBones.HiloSlot = HiloSlot;
})(dragonBones.Slot);
/**
* HiloFactory
*/
(function(superClass) {
var Armature = dragonBones.Armature;
var HiloSlot = dragonBones.HiloSlot;
var HiloFactory = function() {
superClass.call(this, this);
};
__extends(HiloFactory, superClass, {
_generateArmature: function() {
var armature = new Armature(new Hilo.Container);
return armature;
},
_generateSlot: function() {
var slot = new HiloSlot();
return slot;
},
_generateDisplay: function(textureAtlas, fullName, pivotX, pivotY) {
var texture = textureAtlas.getTexture(fullName);
var region = texture.region;
var bitmap = new Hilo.Bitmap({
image: textureAtlas.texture,
rect: [region.x, region.y, region.width, region.height],
crossOrigin: this.textureCrossOrigin
});
if (isNaN(pivotX) || isNaN(pivotY)) {
var subTextureFrame = textureAtlas.getFrame(fullName);
if (subTextureFrame != null) {
pivotX = (subTextureFrame.width / 2) + subTextureFrame.x;
pivotY = (subTextureFrame.height / 2) + subTextureFrame.y;
} else {
pivotX = texture.region.width / 2;
pivotY = texture.region.height / 2;
}
}
bitmap.pivotX = pivotX;
bitmap.pivotY = pivotY;
bitmap.transform = new Hilo.Matrix().identity();
return bitmap;
}
});
dragonBones.HiloFactory = HiloFactory;
}(dragonBones.BaseFactory));
dragonBones.tick = function(dt) {
dragonBones.WorldClock.clock.advanceTime(dt * 0.001);
};