Adobe Flex 计时器事件
我只是有一个关于 Adobe Flex 的 Timer 和 TimerEvent (flash.events.TimerEvent & flash.utils.Timer) 的简单问题。
我目前正在开发一个项目,其中我需要偶尔改变速度、停止和播放 swf 动画(加载到加载器并实例化为 ByteArray)。
例如,我有一辆以 40 公里/小时的速度行驶的移动汽车(swf 动画)。然后我有一个按钮,可以按 40 公里/小时的增量更改速度。所以基本上,每当我按下按钮时,游戏车就应该按增量改变速度。困难的部分是,我已经在 Adobe Flex 中进行了此操作,但它还没有改变速度。我的意思是,它仅按照我在 Flash 上创建 swf 文件时设置的关键帧间隔移动(也就是说,每个关键帧 30 帧间隔)。
简而言之,我只需要根据我要求改变的增量来改变速度。一位同事告诉我使用 Flex 的 Timer 和 TimeEvent,但我似乎不太掌握它的窍门,因为我对 ActionScript 世界还是个新手。
我希望有人能帮助我。谢谢 :)
I just have a one quick question on Timer and TimerEvent (flash.events.TimerEvent & flash.utils.Timer) of Adobe Flex.
I am currently working on a project wherein I need to occasionally change speed, stop and play an swf animation (loaded to a loader and instantiated as a ByteArray).
Example, I have a moving car (swf animation) running at 40kph. Then I have a button which will change the speed by increments of 40kph. SO basically, whenever I hit the button, the playing car should change speed by the increment. The difficult part is, I already had this working in Adobe Flex but it doesn't change the speed yet. I mean, it only moves by the keyframe interval I set when I created the swf file on flash (which is, to say, 30 frame interval per keyframe).
So in short, I just need to make the speed change depending on how many increments I asked it to change. A colleague told me to use Timer and TimeEvent of Flex but I can't seem to quite get the hang of it since I'm still new to the ActionScript world.
I hope someone can help me. Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要通过代码为汽车设置动画。以下代码将车轮加速到 120 km/h:
这个想法是“即时”计算每个新帧的动画参数。
You need to animate the car from the code. The following code speeds up wheels until 120 km/h:
The idea is to calculate animation parameters for every new frame "on the fly".