开发者

How to move an object along a spline or sine function in Flex 3

I am trying to create a similar effect to what is used in CityVille for dropping coins and experience icons, they do a custom move animation 开发者_开发知识库and it first moves a little bit up and then down. It looks like it is following a spline or a sine function.

The Move effect in flex 3 only moves linearly.

Any help?


Use a tweening library such as Actuate http://code.google.com/p/actuate/ It lets you animate an object along a bezier curve or custom motion path like this:

var xPath:MotionPath = MotionPath.bezier (200, 20).line (400);
var yPath:MotionPath = MotionPath.bezier (0, 300).line (0);

Actuate.motionPath (MySprite, 1, { x: xPath, y: yPath } );

A very similar library is eaze http://code.google.com/p/eaze-tween/ and it's mxml friendly wrapper: http://code.google.com/p/eazefx/


You should be looking at Tweens instead of Moves. An example could be:

import mx.transitions.easing.*;
import mx.transitions.Tween;

new Tween(myMC, ‘_x’, Regular.easeOut, myMC._x, myMC._x + 300, 30);
new Tween(myMC, ‘_y’, Regular.easeIn, myMC._y, myMC._y + 300, 30);

Code is random Google result, so I post no guarantees. Also for myself I would prefer a tween engine like TweenLite: http://www.greensock.com/tweenlite/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜