- how t开发者_如何学Co make one object move to a specific point with animation in Actionscript ( not MXML code ) ? ( Flex 4.5 )
Built in animation effects will do the trick (this moves is to 200,200):
<s:Move id="myMoveEffect" xTo="200" yTo="200" target="{objectToMove}"/>
Then you can play it with a call like so:
myMoveEffect.play();
So, here's a button that plays it, for example :
<s:Button label="move now!" click="myMoveEffect.play()"/>
Use effects. You probably want the Spark Move effect.
Tweening? Its a great way to move around objects smoothly. TweenLite, just one of the many Tweening Engines that do similar functions, is designed to wrap that all nicely for you so you see and use practically no code.
In relation to other comments on other answers, Tweenling enables multiple properties of an object (or even many objects!) to be changed simultaneously.
DisplayObject.x = 5;
DisplayObject.x = 6;
DisplayObject.x = 7;
DisplayObject.x = 8;
Etc...
Ps: Try using a time interval or a loop.
精彩评论