FlxTween can be used to change values over time following a number of available curve functions.

There are multiple motion tween functions available, but they all work roughly the same way.

Using color allows you to change the x and y values of a FlxObject over time.

// create a linear motion tween
FlxTween.linearMotion(myObject, fromX, fromY, toX, toY, duration, useDuration, {type: tweenType, easing: FlxEase: easeFunction});



import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;

class PlayState extends FlxState
	override public function create()
		var linearSprite:FlxSprite = new FlxSprite("assets/sprite.png");
		linearSprite.x = linearSprite.y = 50;

		bgColor = 0;


		FlxTween.linearMotion(linearSprite, 50, 50, FlxG.width - linearSprite.width - 50,
			FlxG.height - linearSprite.height - 50, 3, true, {
				type: FlxTweenType.PINGPONG,
				ease: FlxEase.elasticInOut