这适用于Actionscript 3.0
上的CS5
。
我一直遇到fl.transitions.easing.None.easeNone.
的一些问题。我试图动画我的MovieClip角色,而不是放松并停下来。我使用以下代码来停止缓动:
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.RIGHT && var_move == false)
{
var_move = true;
hero.gotoAndStop("Walk");
hero.scaleX = 1;
var tween1:Tween = new Tween(hero, "x", None.easeNone, hero.x, hero.x+75, 15, false)
tween1.addEventListener(TweenEvent.MOTION_FINISH, onMotionFinished);
}
if(evt.keyCode == Keyboard.LEFT && var_move == false)
{
var_move = true;
hero.gotoAndPlay("Walk");
hero.scaleX = -1;
var tween2:Tween = new Tween(hero, "x", None.easeNone, hero.x, hero.x-75, 15, false)
tween2.addEventListener(TweenEvent.MOTION_FINISH, onMotionFinished);
}
}
function onMotionFinished($evt:TweenEvent):void
{
hero.gotoAndPlay("Stand");
var_move = false;
}
它做了但是如果您只点击向右或向左箭头,则MovieClip字符不会在该帧上停止。它一直持续到补间完成。如果我使用以下代码:
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, releaseKey);
function keyPressed(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.RIGHT)
{
var_move = true;
hero.gotoAndPlay("Walk");
hero.scaleX = 1;
hero.x += 5;
}
if(evt.keyCode == Keyboard.LEFT)
{
var_move = true;
hero.gotoAndPlay("Walk");
hero.scaleX = -1;
hero.x -= 5;
}
}
function releaseKey(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.RIGHT || evt.keyCode == Keyboard.LEFT)
{
hero.gotoAndStop("Stand");
}
}
MovieClip角色很容易进入漫步动画,但会停在我想要的位置。如何在我选择的位置停止补间(第一个代码)或如何停止缓动(第二个代码)?
答案 0 :(得分:2)
对于补间,我强烈建议在http://greensock.com使用库...免费的TweenMax / TweenLite将为你节省大量的时间来解决这样的问题...他们已经做了很多困难:)< / p>