Skip to main content
Known Participant
June 9, 2009
Answered

Tweening with action script +/- from a set location

  • June 9, 2009
  • 1 reply
  • 981 views

I know the basics of tweening with action script but I have a picture set in the center of the stage at x = 50.  On a click I would like that picture move - 10 x from that position so it will end the tween at 40.  On a different button I would like to do the oppositie, + 10 x to its current position so if it was at 40 it would be back to the start and if it was at the start it would be at 60.

Thanks

This topic has been closed for replies.
Correct answer kglad

prevTX.onRelease = function (){
nextTX._visible = true;
prevTX.enabled = false;
nextTX.enabled = false;

var addition:Number = 100 + thTX._x;
var myTween1:Tween = new Tween(thTX, "_x", Strong.easeOut, thTX._x, addition, 3, true);
myTween1.onMotionFinished = function(){
prevTX.enabled = true;
nextTX.enabled = true;

}

onMotionFinished is not enabled?  Did I not call it correctly?


you can use:


prevTX.onRelease = function (){

this.useHandCursor=false;

nextTX._visible = true;
prevTX.enabled = false;
nextTX.enabled = false;

var addition:Number = 100 + thTX._x;
var myTween1:Tween = new Tween(thTX, "_x", Strong.easeOut, thTX._x, addition, 3, true);
myTween1.onMotionFinished = function(){

prevTX.useHandCursor=true;
prevTX.enabled = true;
nextTX.enabled = true;

}

}

1 reply

kglad
Community Expert
Community Expert
June 9, 2009

use the flash tween class (or one of the well-known 3rd party tween classes like tweenlite or tweener).

chewbearsAuthor
Known Participant
June 9, 2009

btn.onRelease = function(){
var addition:Number = 20 + target_mc._x;
var myTween:Tween = new Tween(target_mc, "_x", Strong.easeOut, target_mc._x, addition, 20, true);
};

figured it out.

Thanks for the proper words to google kglad : P

chewbearsAuthor
Known Participant
June 9, 2009

kglad side question for you.

Whats a good way to disable someone not wanting to wait for the tween to finish.  IE button spamming the next button?


I want them to click it and not be able to click it until its done loading.  Any thoughts?