Hi guys… I’m new to actionscript 3, and I was hoping someone might point me in the right direction. I’m trying to store the y position of an event.target on mouse roll over so that i can recall it after a tween has played to reset the target movie position back to original. At the moment, if I roll off and back on quickly (before the tween has finished playing) the y value is changed in the variable and so the target movie gets ‘pushed’ up the stage.
I think there must be an easier way of doing this but I’ve been round the houses, and ended up with this- (the function that plays on roll over-)
function onOver(event:MouseEvent):void{
var position:Point = new Point(event.target.x, event.target.y);
var pos1:Number = (event.target.y);
var pos2:Number = (event.target.y -= 3);
inTween = new Tween(event.target,"y",Bounce.easeOut,pos1,pos2,1,true);
outTween = new Tween(event.target,"y",Bounce.easeOut,pos2,pos1,1,true);
outTween.addEventListener(TweenEvent.MOTION_FINISH,tweenfinished);
function tweenfinished():void{
event.target.x = position.x;
event.target.y = position.y;
outTween.removeEventListener(TweenEvent.MOTION_FINISH,tweenfinished);
}
}