To eliminate unnecessary function calls, we unregister moveTextRight( ) for Event.ENTER_FRAME events. : Animation : TextField Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » TextField » Animation »

 

To eliminate unnecessary function calls, we unregister moveTextRight( ) for Event.ENTER_FRAME events.


 

package{
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    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);
          }
    
      }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo TextField
» Animation