ActionScript - 使用 TweenLite 和 TweenLite 时出现严重的性能问题鼠标移动事件

发布于 2024-10-20 15:52:17 字数 1105 浏览 5 评论 0原文

当使用 TweenLite 在拖动时补间滤镜时,我收到了非常明显的性能影响。

private function mouseMoveEventHandler(evt:MouseEvent):void
    {
    evt.stopImmediatePropagation();

    startDrag();

    zoomTween = new TweenLite(this, 1.0, {dropShadowAmount: ZOOM_SHADOW, scaleX: 1.5, scaleY: 1.5, rotation: 10, onUpdate: updateDropShadow, onComplete: completeDropShadow, onCompleteParams: [ZOOM_SHADOW]});

    removeEventListener(MouseEvent.CLICK, mouseClickEventHandler);
    addEventListener(MouseEvent.MOUSE_UP, mouseUpEventHandler);
    addEventListener(MouseEvent.MOUSE_OUT, mouseUpEventHandler);
    }

private function updateDropShadow():void
    {
    filters = [new DropShadowFilter(dropShadowAmount, 90, 0x000000, 1.0, dropShadowAmount * 2, dropShadowAmount * 2, 1.0, 3)];
    }

private function completeDropShadow(dropShadowAmount:Number):void
    {
    this.dropShadowAmount = dropShadowAmount;
    }

我知道 TweenLite 有一个 Drop Shadow Plusing,但它只能打开和关闭滤镜,而不能更改始终可见的阴影的距离或模糊量。

另外,我不是在手机上测试这个,我是在 Flash CS5 和外部调试器中的快速桌面上进行测试 - 两者都滞后于显示对象,这只是一个简单的正方形,即使在 ZoomTween 之后完全的。

有什么想法吗?

i'm receiving a very noticeable performance hit when using TweenLite to tween a filter while dragging.

private function mouseMoveEventHandler(evt:MouseEvent):void
    {
    evt.stopImmediatePropagation();

    startDrag();

    zoomTween = new TweenLite(this, 1.0, {dropShadowAmount: ZOOM_SHADOW, scaleX: 1.5, scaleY: 1.5, rotation: 10, onUpdate: updateDropShadow, onComplete: completeDropShadow, onCompleteParams: [ZOOM_SHADOW]});

    removeEventListener(MouseEvent.CLICK, mouseClickEventHandler);
    addEventListener(MouseEvent.MOUSE_UP, mouseUpEventHandler);
    addEventListener(MouseEvent.MOUSE_OUT, mouseUpEventHandler);
    }

private function updateDropShadow():void
    {
    filters = [new DropShadowFilter(dropShadowAmount, 90, 0x000000, 1.0, dropShadowAmount * 2, dropShadowAmount * 2, 1.0, 3)];
    }

private function completeDropShadow(dropShadowAmount:Number):void
    {
    this.dropShadowAmount = dropShadowAmount;
    }

i understand there is a Drop Shadow Plusing with TweenLite, but that only has the ability to tween the filter on and off, rather than change the distance or blur amount of an always visible drop shadow.

also, i'm not testing this on a mobile phone, i'm testing on my fast desktop in both Flash CS5 and the external debugger - both are lagging the display object, which is just a simple square shape, even after the zoomTween has completed.

any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烈酒灼喉 2024-10-27 15:52:17

您将在每次 mousemove 更新时实例化一个新的 TweenLite。您可能会在单个 Enter_frame 间隔的空间内发生数十次这样的情况。这可能是很多的 TweenLite 实例,所有实例都试图同时移动同一对象一秒钟。只需“短距离”的鼠标移动就可以想象数百个。数千人提出延长动议。

特别是对于移动设备,您需要避免 mousemove 事件,因为它们绝对会淹没系统。这是数据过载。也许您可以在 Enter_frame 或计时器事件处理程序中跟踪增量随时间的变化?这样做,然后确保一次只有一个 tweenlite 存在(杀死旧的,或者在分配新的之前让旧的完成)。

另请注意,过滤器在您的移动设备上将非常困难。您可以在桌面上安装并运行它,但如果它在移动设备上运行,我会感到惊讶。

You're instantiating a new TweenLite on every mousemove update. You can potentially have dozens of those happen all within the space of a single enter_frame interval. That's potentially a lot of TweenLite instances, all trying to move the same object at the same time for one second. Think hundreds of them for just a "short" mouse movement. Thousands for extended motions.

For mobile especially, you need to avoid mousemove events, as they absolutely flood the system. It's data overload. Perhaps instead you could track the change in delta over time in an enter_frame or timer event handler? Do that, and then assure that only one tweenlite exists at a time (kill the old one, or just let the old one finish before assigning a new one).

Also note that filters are going to be really hard on your mobile device. You may get this up and running on desktop, but I'd be surprised if it works out on mobile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文