Created
July 21, 2013 07:00
-
-
Save RKAN/6047774 to your computer and use it in GitHub Desktop.
Tweening to a Relative Position using a Variable in TweenMax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Your everyday absolute tween that moves movieclip_mc | |
// to 100 on the x axis, taking one second to do so | |
TweenMax.to(movieclip_mc, 1, {x:100}); | |
// A relative tween that moves movieclip_mc to a | |
// position on the x axis 100 units/pixels greater | |
// than movieclip_mc's current position | |
TweenMax.to(movieclip_mc, 1, {x:"100"}); | |
// An absolute tween like the first, but passing in | |
// the new value with a variable | |
TweenMax.to(movieclip_mc, 1, {x:newX}); | |
// A tween that casts the variable as a string, | |
// thus making it a relative tween | |
TweenMax.to(movieclip_mc, 1, {x:String(newX)}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment