下面的代码,使用TweenMax的onUpdate方法
this.detaibaseInfo2 = new Sprite();
with (detaibaseInfo2) {
x = 30;
y = 700;
with (graphics) {
beginFill(0x826b45, 1);
drawRect(0, 0, 240, 20);
endFill();
}
}
addChild(detaibaseInfo2);
TweenMax.to(detaibaseInfo2, 0.2, {y:260, onUpdate:detaibaseInfo2Update,ease:Strong.easeOut});
但是测试了一下:
private function detaibaseInfo2Update():void {
trace("detaibaseInfo2.y="+detaibaseInfo2.y);
if (detaibaseInfo2.y < 270) {
other code ...
}
}
输出的结果是:
[trace] detaibaseInfo2.y=399.7
[trace] detaibaseInfo2.y=399.7
[trace] detaibaseInfo2.y=399.7
[trace] detaibaseInfo2.y=399.7
[trace] detaibaseInfo2.y=399.7
[trace] detaibaseInfo2.y=291.45
[trace] detaibaseInfo2.y=263.25
[trace] detaibaseInfo2.y=260.05
[trace] detaibaseInfo2.y=260
有个疑惑: 为什么 detaibaseInfo2 的 y 属性数值不是从 700 到 260 的递减呢?