简体   繁体   English

在Flex中动态更改动画片段的速度

[英]Change speed of movieclip dynamically in flex

I have a movieclip created of a wheel that needs to roll on the ground. 我有一个需要在地面上滚动的轮子制成的动画片段。 The speed of lateral movement of the wheel, is provided by the user and the wheel needs to rotate such that, it looks like rolling vs slipping on the ground 轮子的横向运动速度由用户提供,轮子需要旋转,以便看起来像在地面上滚动还是打滑

I essentially need the wheel to rotate faster/ slower based on user input- how can this be achieved 我本质上需要根据用户输入使轮子更快/更慢地旋转-如何实现

using actionscript, not frame based animation. 使用动作脚本,而不是基于帧的动画。

import flash.events.MouseEvent;
import flash.events.Event;

var moveBy:Number = 2;
var rotateBy:Number = 2;

// enter frame loop
this.addEventListener(Event.ENTER_FRAME, function(e:Event)
{
    wheel.x += moveBy; 
    wheel.rotation += rotateBy;
});

I did this sample in flash with a movieclip on the stage named wheel. 我在名为wheel的舞台上用动画片段在Flash中进行了此示例。 But you can load an image or sprite and use the same actions on it. 但是您可以加载图像或精灵并对其执行相同的操作。 Adjust the moveBy, rotateBy to speed up or slow down the animation. 调整moveBy,rotateBy可以加快或减慢动画。 To reverse it's direction and rotation use negative numbers. 要反转其方向和旋转,请使用负数。

Don't let the clip play at all. 根本不要播放剪辑。 Control it with gotoAndStop() based on input. 根据输入,使用gotoAndStop()对其进行控制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM