补间动作脚本未运行
我刚刚开始使用动作脚本,遇到了有关补间的问题...基本上,我希望我的对象在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它正在运行补间,你只是看不到它。在你的 animate 函数中更改:
to
你可以看到它触发得很好。
编辑
至于使其在 5 秒内淡出,在我使用原始代码进行的测试中似乎工作正常,只需确保在 5 秒内不要再次单击它,否则它将重置补间。根据您的用途,您可以在函数中设置 button.mouseEnabled = false;以防止额外的点击。
It is running the tween, you just can't see it. In your animate function change:
to
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.