Here is some code on how to get a TextField (or any other display object) to marquee/scroll across the stage smoothly. When it has scrolled out completely of the viewfield, it restarts from the right side of the stage.
If the animation is rough, try increasing the document’s FPS to get a smoother movement.
This function calls itself when it’s complete and passes itself as a variable back to the function, so it repeats continuously.
var movementSpeed:Number = 1.5;
var speed:int = 100;
var stageWidth:int = 1920;
private function moveMarquee(obj:DisplayObject):void {
TweenMax.to(obj, movementSpeed, {x:obj.x - speed, ease: Linear.easeNone, onComplete:moveMarquee, onCompleteParams:[obj]});
if(obj.x < -obj.width) {
TweenMax.killTweensOf(obj);
obj.x = stageWidth;
TweenMax.to(obj, movementSpeed, {x:obj.x - speed, ease: Linear.easeNone, onComplete:moveMarquee, onCompleteParams:[obj]});
}
}
To initialize the first start, use this:
moveMarquee(marqueeText);
And to kill it, use this:
TweenMax.killTweensOf(marqueeText);