/**
* !#en Removes all actions from all the targets.
* !#zh 移除所有对象的所有动作。
* @method removeAllActions
*/
removeAllActions:function () {
var locTargets = this._arrayTargets;//划重点
for (var i = 0; i < locTargets.length; i++) {
var element = locTargets[i];
if (element)
this.removeAllActionsFromTarget(element.target, true);
}
},
/**
* !#en
* Removes all actions from a certain target. <br/>
* All the actions that belongs to the target will be removed.
* !#zh
* 移除指定对象上的所有动作。<br/>
* 属于该目标的所有的动作将被删除。
* @method removeAllActionsFromTarget
* @param {Node} target
* @param {Boolean} forceDelete
*/
removeAllActionsFromTarget:function (target, forceDelete) {
// explicit null handling
if (target == null)
return;
var element = this._hashTargets[target.__instanceId];
if (element) {
element.actions.length = 0;
this._deleteHashElement(element);
}
},
_deleteHashElement:function (element) {
var ret = false;
if (element && !element.lock) {
if (this._hashTargets[element.target.__instanceId]) {
delete this._hashTargets[element.target.__instanceId];
var targets = this._arrayTargets;//划重点
for (var i = 0, l = targets.length; i < l; i++) {
if (targets[i] === element) {
targets.splice(i, 1);//划重点
break;
}
}
this._putElement(element);
ret = true;
}
}
return ret;
},
当在释放动画的同时 在_deleteHashElement:function 这个函数里面用的是splice导致this._arrayTargets整个数组长度变短 在 removeAllActions 这个函数里面删除不完全 很痛苦