kill
kill(target:Object, propertiesList:String):self
根据参数完全或部分终止动画。杀死意味着立即停止动画,将其从父时间线中移除,并释放它以便垃圾回收。
参数
目标对象: 对象
(默认值 =
null
) - 如需仅终止与特定目标(或多个目标)相关的动画部分,请在此处引用该目标。例如,要仅终止与myObject
有关的部分,执行kill(myObject)
或者如需仅终止与myObject1
和myObject2
有关的部分,执行kill([myObject1, myObject2])
。如果没有定义目标,所有的所有目标都将受影响。propertiesList:字符串
(默认值 =
"all"
) - 一个以逗号分隔的属性名称列表,这些属性将不再由此 Tween 动画处理。如果没有定义对象(或者null
或者"all"
),所有所有属性都将被终止。
返回值:self
self(便于链式调用)
细节
根据参数不同,完全或部分终止动画。直接调用kill()
(省略参数)将立即停止动画,从其父时间轴中移除,清除所有属性动画,并释放供垃圾回收。
// kill the entire animation:
animation.kill();
// set to null so the reference is removed
animation = null;
如需从此动画中仅终止某个特定目标(或多个目标),请使用第一个参数。如需终止动画中的特定补间属性,请使用第二个参数,即一个以逗号分隔的属性名列表。
// kill all parts of the animation related to the target "myObject" (if the tween has multiple targets, the others will not be affected):
animation.kill(myObject);
// kill only the "x" and "y" properties of the animation (all targets):
animation.kill(null, "x,y");
// kill only the "x" and "y" properties of animations of the target "myObject":
animation.kill(myObject, "x,y");
// kill only the "opacity" properties of animations of the targets "myObject1" and "myObject2":
animation.kill([myObject1, myObject2], "opacity"); //you could use selector text instead, like ".class1, .class2"
警告
如果你稍后还想再次使用动画,请不要使用 kill() - 如果你想重复使用它,可以改用 pause()。