all groups > flash actionscript > september 2007 >
You're in the

flash actionscript

group:

Animating TextFields - Converting textField to a Bitmap


Animating TextFields - Converting textField to a Bitmap MScherzer
9/5/2007 11:30:59 PM
flash actionscript:
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
Re: Animating TextFields - Converting textField to a Bitmap kglad
9/6/2007 3:06:39 AM
i don't see a problem:



var mc:MovieClip=new MovieClip();
var mctf:TextField=mc.tf=new TextField();
mctf.text="this is a test";
addChild(mctf);
mc.cacheAsBitmap=true;
var t:Timer=new Timer(1,0);
t.addEventListener(TimerEvent.TIMER,f);
function f(evt:TimerEvent) {
mctf.x+=.4;
if(mctf.x>stage.stageWidth){
mctf.x=0;
}
}
t.start();
Re: Animating TextFields - Converting textField to a Bitmap MScherzer
9/6/2007 6:10:34 PM
Hi thanks for the feedback / code snippet. Incrementing by fractions helps
somewhat like you suggessted, but there is still a distinct flicker. Maybe we
are just being to picky but our consensus here is that the scrolling has a
light flicker, also the scrolling sometimes jerks.

Changing the background color to black on white aliviates the problem
somewhat, so that we could live with it but the result is really not what we
expected.

I will do some testing to see if the results are the same on other operating
systems.

cheers

Marcel
Re: Animating TextFields - Converting textField to a Bitmap SymTsb
9/6/2007 6:16:24 PM
Have you looked at simply adjusting the horizontal scroll of the text field?
Have you tried using the Tween class or Transition Manager to move the
movieclip containing the text field? I'd try the second option with the Tween
class first.
AddThis Social Bookmark Button