ActionScript 3 - 使用 Tween 类补间数字

发布于 2024-09-06 16:44:33 字数 281 浏览 9 评论 0原文

目前,我正在使用 Tween 类补间数字,方法是将其值添加到对象的项目数组中:

var tweenObject:Object = {value:20};
distanceTween = new Tween(tweenObject, "value", None.easeNone, 0, tweenObject.value, 5, true);

这是使用 Tween 类补间数字的最常见、最简单的方法吗?

我知道其他补间类有更简单的解决方案,但我只关心默认的补间类。

currently i'm tweening numbers with the Tween class by adding their value to an object's items array:

var tweenObject:Object = {value:20};
distanceTween = new Tween(tweenObject, "value", None.easeNone, 0, tweenObject.value, 5, true);

is this the most common, simple way to tween numbers with the Tween class?

i'm aware there are more simple solutions with other tween classes, but i'm only concerned with the default Tween class.

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

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

发布评论

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

评论(1

小霸王臭丫头 2024-09-13 16:44:33

Tween 应该与对象的任何公共变量一起使用,以便您可以在类上定义公共属性并使其工作。默认情况下,时间轴上的变量是公共的,因此如果您不在班级中,您只需按名称引用这些变量即可。我也认为你所做的事情没有问题,所以如果你对此感到满意,那么就不要太担心。

所以在主时间线上:

import fl.transitions.Tween;
import fl.transitions.easing.None;

var val:Number = 100;
var distanceTween:Tween = new Tween(this, "val", None.easeNone, 0, this.val, 5, true);

或者在课堂上:

package
{
import fl.transitions.Tween;
import fl.transitions.easing.None;

import flash.display.Sprite;

public class ClassTweenTest extends Sprite
{
    public var val:Number;

    private var distanceTween:Tween

    public function ClassTweenTest()
    {
        val = 100;
        distanceTween = new Tween(this, "val", None.easeNone, 0, this.val, 5, true);
    }
}
}

我强烈建议你学习使用一个好的补间引擎,比如 TweenTweenLitegTween 因为它们可以在更清晰的界面中为您提供更大的灵活性。

Tween should work with any public variables of an object so you can define a public property on your class and have it work. By default variables on the timeline are public so you can just refer to those by name if you aren't inside a class. I also see no problem with what you are doing so if you are happy with it then don't worry too much about it.

So on the main timeline:

import fl.transitions.Tween;
import fl.transitions.easing.None;

var val:Number = 100;
var distanceTween:Tween = new Tween(this, "val", None.easeNone, 0, this.val, 5, true);

Or insides a class:

package
{
import fl.transitions.Tween;
import fl.transitions.easing.None;

import flash.display.Sprite;

public class ClassTweenTest extends Sprite
{
    public var val:Number;

    private var distanceTween:Tween

    public function ClassTweenTest()
    {
        val = 100;
        distanceTween = new Tween(this, "val", None.easeNone, 0, this.val, 5, true);
    }
}
}

I'd strongly urge you to learn to use a good tween engine like Tweener, TweenLite or gTween since they can give you a lot more flexibility within a much saner interface.

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