ActionScript - 使用 TweenLite 和 TweenLite 时出现严重的性能问题鼠标移动事件
当使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将在每次 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.