Skip to main content
A_Shiyaz
Known Participant
November 30, 2010
Question

TLFTextField or TLF, which is better to use in CS5?

  • November 30, 2010
  • 1 reply
  • 1615 views

Hi,

I have been developing content using TLF with CS4 and in Flash Builder. Recently when I switched to CS5, there was this cool TLFTextField. So now I wonder, TLFTextField or TLF, which is better to use in CS5? Almost all of my text will be dynamically generated. Please share your thoughts - possibly with pros and cons.

~ Shiyaz

This topic has been closed for replies.

1 reply

November 30, 2010

I assume you've found TLFTextField in Flash Pro (I can't remember if Flash Builder made a TLFTextField class or not). Anyway, if you're considering using Flash Pro, here's some background on the TLFTextField class:

This class was created primarily for backwards compatibility with Classic Text coding. If you used Flash Pro CS 4 or earlier versions, and you wrote ActionScript for your text objects, you were using TextField objects. So, when you upgraded to CS 5, and you decided to convert all your old Classic text objects to the new TLF objects, all your code would have broken were it not for TLFTextField class. TLFTextField implements the TextField API so that your existing TextField code can be used in the TLF environment.

So, if you're an ActionScript programmer who is already comfortable programming using the TextField API, it certainly makes sense to continue doing so but using TLFTextField objects. However, if you want to take advantage of the new TLF features, the old API doesn't really give you the ability to do that. So, the TLFTextField provided a new API:

function get textFlow():TextFlow;

The TextFlow class is the top level class of the TLF model objects. Using that object, you can then set attributes on your text just as if you were working with TextFlow in Flash Builder. So, in essence, TLFTextField provides backwards compatibility, continued use of the familiar API set, and access to the TextFlow model class.

Another nuance to be aware of is that if you choose to embed fonts, TLF requires the newer "DF4" (for DefineFont4, based on the SWF Tag name) vs. the older "DF3" fonts that TextField requires. For text on the stage, Flash Pro will do all the tricky work for deciding when to embed DF3 and when to embed DF4 fonts, but just be aware that mixing Classic text and TLF text when using embedded fonts can cause a "double tax" on your SWF size because it may embed the same font both as DF3 and DF4.

Good Luck!

Rusty

A_Shiyaz
A_ShiyazAuthor
Known Participant
December 1, 2010

Thanks for the perspective Rusty, that was helpful. Yes, I did find TLFTextField in Flash Pro. I have both types of code - one that uses TLF and one that uses TextField. Of late, I have been porting all those to use pure TLF, so that all the cool features of TLF could be utilized. Knowing about the 'double tax' with fonts, was helpful too.

I would go ahead by using TLF rather than TLFTextField, it would suit my applications.

Thanks,

Shiyaz