开发者

Change speed of movieclip dynamically in flex

I have开发者_Go百科 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. 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. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜