ballTween = new mx.transitions.Tween(ball_mc, "_x", mx.transitions.easing.Bounce.easeOut, 20, 380, .5, true);
这串代码真难看! 我们最好把它写成一个函数:
function tweenBall() { easeType = mx.transitions.easing.Bounce.easeOut; var begin = 20; var end = 380; var time = .5; var mc = ball_mc; ballTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true); }
代码: myButton_btn.onRelease = function() { tweenBall();//调用Tween }; function tweenBall() { easeType = mx.transitions.easing.Bounce.easeOut; var begin = 20; var end = 380; var time = .5; var mc = ball_mc; ballTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true); }
还不错,不过我们还可以改进一下,把easing类方法设为入口参数,这样我们就可以自定义所执行的运动方式了: myButton_btn.onRelease = function() { tweenBall(mx.transitions.easing.Bounce.easeOut);//注意入口的easing方法参数 }; function tweenBall(easeType) {//加了一个参数. var begin = 20; var end = 380; var time = 20; var mc = ball_mc; ballTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time); }
myButton_btn.onRelease = function() { tweenBall(mx.transitions.easing.Bounce.easeOut); }; function tweenBall(easeType) { var begin = 20; var end = 380; var time = 20; var mc = ball_mc; ballTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time); ballTween.onMotionFinished = function() { this.yoyo(); };//多了一个事件和方法 } rewind()方法把增加了Tween运动的MC重置到初始(未增加Tween前)状态.
他自己所说).*/ } function easeDown(what) { var begin = what._y; var tabDown = new mx.transitions.Tween(what, "_y", mx.transitions.easing.Strong.easeIn, begin, what.