AS3 - 在整数上使用 Tween?
以前没有使用过 Tween 函数,所以我需要一点帮助。
我想在两个整数之间进行补间。
例子: 我缓冲 360 帧(图像)。
我想跳到第 100 帧(从第 1 帧开始),但我想使用缓动使其看起来更好。
我所需要的只是补间一个将用于当前显示图像的整数。
到目前为止一切顺利,但我不知道如何在补间中更新我的图像:
public function timerEvent(event:TimerEvent):void{
TweenLite.to(this, 2, {_currentFrame: 50, ease:Strong.easeOut});
if (_currentFrame>=358) _currentFrame -= 359;
if (_currentFrame<0) _currentFrame += 359;
var myBitmap:Bitmap = new Bitmap(buffer[_currentFrame+1]);
myBitmap.smoothing = true;
imageBuffer.data = myBitmap;
}
Not been using the Tween functions before, so I'd like a little help.
I want to tween between two integers.
Example:
I buffer 360 frames (images).
I want to skip to frame 100 (from frame 1), but I want to use ease to make it look better.
All I need is to tween an integer that I will use for the current image displayed.
So far so good, but I'm not getting how to update my image in the tween:
public function timerEvent(event:TimerEvent):void{
TweenLite.to(this, 2, {_currentFrame: 50, ease:Strong.easeOut});
if (_currentFrame>=358) _currentFrame -= 359;
if (_currentFrame<0) _currentFrame += 359;
var myBitmap:Bitmap = new Bitmap(buffer[_currentFrame+1]);
myBitmap.smoothing = true;
imageBuffer.data = myBitmap;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我强烈建议使用 Greensock 的 TweenLite 和 TweenMax 库,而不是内置的 Tweening 函数。
http://www.greensock.com/tweenmax/
这些的美妙之处在于你可以补间任何对象的数字属性,并应用缓动,您甚至可以使用 TweenMax 中内置的帧插件直接补间 MovieClip 的帧:
要补间计数器值同样简单,因为它不需要您可以使用较轻的 TweenLite 框架插件:
编辑以包含新代码
当补间运行时,您可以捕获更新事件,该事件允许您对参数的当前值执行操作。然后你可以做这样的事情:
I would seriously recommend using Greensock's TweenLite and TweenMax libraries over the built in Tweening functions.
http://www.greensock.com/tweenmax/
The beauty of these is that you can tween any numeric property of an object, and apply easing, and you can even tween frames of a MovieClip directly by using the Frames plug that is built into TweenMax:
To Tween a counter value is just as easy, and because it doesn't require the Frames plugin you can use the lighter TweenLite:
Edit to include new code
As the tween runs you can capture an update event which lets you perform actions on the current values of your parameters. You could then do something like this: