补间动作脚本未运行

发布于 2024-12-21 04:07:35 字数 854 浏览 3 评论 0原文

我刚刚开始使用动作脚本,遇到了有关补间的问题...基本上,我希望我的对象在 5 秒内淡出...

这是我的代码:

import flash.display.Sprite;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.text.TextField;
import flash.events.MouseEvent;

var object:Sprite = new Sprite();
object.graphics.beginFill(0xff00ff);
object.graphics.drawRoundRect(200, 200, 100, 75, 10, 10);

var button:TextField = new TextField();
button.x = 10;
button.y = 10;
button.width = 125;
button.height = 25;
button.text = "Click here to Animate";
button.border = true;

addChild (button);
addChild (object);

button.addEventListener(MouseEvent.CLICK, animate);

function animate (e : MouseEvent)
{
    var myTween:Tween = new Tween(object, "alpha", None.easeIn, 1, 0, 5, true);
}

当我启动影片剪辑并单击文本字段时,它以某种方式获胜不动画... 谁能指出错误??? THX b4...

i've just started actionscript-ing and I encountered problems about tween... Basically, i want my object to fade out in 5 seconds...

here's my code :

import flash.display.Sprite;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.text.TextField;
import flash.events.MouseEvent;

var object:Sprite = new Sprite();
object.graphics.beginFill(0xff00ff);
object.graphics.drawRoundRect(200, 200, 100, 75, 10, 10);

var button:TextField = new TextField();
button.x = 10;
button.y = 10;
button.width = 125;
button.height = 25;
button.text = "Click here to Animate";
button.border = true;

addChild (button);
addChild (object);

button.addEventListener(MouseEvent.CLICK, animate);

function animate (e : MouseEvent)
{
    var myTween:Tween = new Tween(object, "alpha", None.easeIn, 1, 0, 5, true);
}

When i started the movie clip and clicked the textfield, it somehow won't animate...
can anyone point out the mistake??? THX b4...

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

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

发布评论

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

评论(1

治碍 2024-12-28 04:07:35

它正在运行补间,你只是看不到它。在你的 animate 函数中更改:

var myTween:Tween = new Tween(object, "alpha", None.easeIn, 1, 0, 5, true);

to

var myTween:Tween = new Tween(object, "alpha", None.easeIn, 0, 1, 5, true);

你可以看到它触发得很好。

编辑

至于使其在 5 秒内淡出,在我使用原始代码进行的测试中似乎工作正常,只需确保在 5 秒内不要再次单击它,否则它将重置补间。根据您的用途,您可以在函数中设置 button.mouseEnabled = false;以防止额外的点击。

It is running the tween, you just can't see it. In your animate function change:

var myTween:Tween = new Tween(object, "alpha", None.easeIn, 1, 0, 5, true);

to

var myTween:Tween = new Tween(object, "alpha", None.easeIn, 0, 1, 5, true);

And you can see it fires just fine.

Edit

As far as making it fade out in 5 seconds it seems to work fine in my tests with your original code, just make sure not to click it again within the 5 seconds or it will reset the tween. Depending on what you are using it for, within your function you can set button.mouseEnabled = false; to prevent additional clicks.

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