使用 Event.ENTER_FRAME 时如何使用 removeEventListener 停止 TweenMax?

How to stop TweenMax with removeEventListener when using Event.ENTER_FRAME?

我有一个 Circle() class,当影片剪辑进入帧时,我需要在其尾部绘制一条长度随机的线。正如预期的那样,它应该是这样的:

然而,由于 removeEventListener 不起作用,圆圈和直线一直在摇晃。如何通过只画一次线来停止影片剪辑?请帮忙!!!

package {
    import com.greensock.*;
    import flash.display.MovieClip;
    import flash.display.Shape;
    import flash.events.Event;
    import flash.events.MouseEvent;

    public class Circle extends MovieClip {

        var _line: Shape = new Shape();

        public function Circle() {
            addEventListener(Event.ENTER_FRAME, animate);
        }

        function animate(e: Event): void {
            _line.graphics.clear();
            _line.graphics.lineStyle(2, 0x00AEEF);
            _line.graphics.moveTo(this.circle.x, this.circle.y);
            addChild(_line);

            TweenMax.to(this.circle, randomNumber(0.5, 2), {
                x: randomNumber(100, 500),
                onUpdate: updateHandler
            });
        }

        function updateHandler(): void {
            _line.graphics.lineTo(this.circle.x, this.circle.y);
            _line.graphics.moveTo(this.circle.x, this.circle.y);
            removeEventListener(Event.ENTER_FRAME, updateHandler);
        }

        function randomNumber(low: Number = NaN, high: Number = NaN): Number {
            var low: Number = low;
            var high: Number = high;
            if (isNaN(low)) {
                throw new Error("no low number");
            }
            if (isNaN(high)) {
                throw new Error("no high number");
            }
            return Math.round(Math.random() * (high - low)) + low;
        }
    }
}

在框架中,我有:

var mc: Circle = new Circle();
mc.x = 50;
mc.y = 50;
addChild(mc);

可以试试这个

function Circle() {
    _line.graphics.lineStyle(2, 0x00AEEF);
    _line.graphics.moveTo(circle.x, circle.y);
    addChild(_line)
    TweenMax.to(this.circle, randomNumber(0.5, 2), {
        x: randomNumber(100, 500),
        onUpdate: updateHandler
    });

}
function updateHandler(): void {
    _line.graphics.lineTo(this.circle.x, this.circle.y);
    _line.graphics.moveTo(this.circle.x, this.circle.y);
}