3 Replies Latest reply on Sep 6, 2007 11:16 AM by SymTsb

    Animating TextFields - Converting textField to a Bitmap

    MScherzer
      Hi,
      I am just starting to get my feet wet with ActionScript and have run into a bit of a problem. As a learning project I am trying to port some newsticker code I have previously built with Java to Flash. The Java code was built over 7 years ago and runs super smooth, even on hardware back in the day. Try as I might I just can not get text to scroll smoothly and without flickering in Flash on far superior hardware. (Note: I am using the FLEX SDK to compile my code.)

      Here are some of the things I tried:

      Attempt 1:
      - I created a textField object. Then I start listening for ENTER_FRAME events. On each frame event I change the x co-ordinate of the textField object. - When the text scrolls it flickers badly, also the scrolling stops now and again (seems like flash is waiting to complete other tasks before resuming my code.)
      - I tried playing with frame rates this just changes the speed but has no effect on the fickering / stuttering.

      Attempt 2:
      - Similar to 1 except now I tried a timer event. Same problem

      Attempt 3:
      - Convert the textField to a BitMap. Try to animate the BitMap as in Attempt 1 and 2. Same problem.

      Attempt 4:
      Now I am thinking that I will have to do the animation using a double buffering technique with two bitmaps. Seems a shame to have to do this. Anyways before persuing this method I need to solve the issue of converting a textField to a bitmap object. The results I am getting are not acceptable as the bitmap representation I am getting is very blocky, if i enable smotthing the resulting bitmap text is way too blurry.

      This is the code I am using (without smoothing):

      var textField:TextField = new TextField();
      textField.text = 'I had this smooth using Amos in the day!';
      textField.autoSize = TextFieldAutoSize.LEFT;

      var bitmapData:BitmapData = new BitmapData(textField.width,textField.height);
      bitmapData.draw(textField);

      var bitmap:Bitmap = new Bitmap(bitmapData,'auto',false);

      addChild(bitmap);

      textField.x = 0;
      textField.y = 15;
      addChild(textField);


      I need some pointers for:
      a) Best way for scrolling a display object horizontaly.
      b) Converting a textField Object to a bitmap that looks identically.
      c) If a Guru knows it can't be done, please let me know.

      Cheers

      Marcel

      http://www.cfavatar.com