Animating a TextField horizontally to x-coordinate 300
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class Main extends Sprite {
private var t:TextField = new TextField( );
public function Main ( ) {
t.text = "Hello";
t.autoSize = TextFieldAutoSize.LEFT;
addChild(t);
addEventListener(Event.ENTER_FRAME, moveTextRight);
}
public function moveTextRight (e:Event):void {
if (t.x <= 300) {
t.x += 10;
if (t.x > 300) {
t.x = 300;
}
} else {
removeEventListener(Event.ENTER_FRAME, moveTextRight);
}
}
}
}
Related examples in the same category