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.
精彩评论