Posts Tagged TextFormat

Difference between TextField and TextBloc (or TextLine)

Ok I have been writing a lot about TLF Framework lately and it is definitely not my favorite topic but I thought people should be aware of this. So here you go : using the new text engine will actually give you better looking text! When I say text engine, I mean using TextBloc and TextLine. Here is a little example I made to show the difference. On the left it is a good old TextField, in the middle we have the new TLFTextField and on the right I am using TextBloc / TextLine (TextBloc for now on).

This movie requires Flash Player 9

As you can see there is nearly no difference between using a TextField and a TLFTextField, the actual code is also the same, the difference is that you need to use a DF4 exported font (some new none-sense setting in Flash CS5). On the other hand, when using TextBloc, it does look better, I agree it is subtle, but it is better. I am writing this post because I was arguing with a colleague that there was no difference, but he showed it to me, I hope this does the same to you.

Using TextBloc

Now when using TextBloc, a lot changed from using the good old TextField. First, you need to use the class ElementFormat instead of TextFormat. Here is an example on how to do so:

var font:AvantGardeGothicStdBook = new AvantGardeGothicStdBook(); //this is a font embedded in a swc
var fontDesc:FontDescription = new FontDescription(font.fontName);
fontDesc.fontLookup = FontLookup.EMBEDDED_CFF;
var style:ElementFormat = new ElementFormat();
style.fontDescription = fontDesc;
style.fontSize = 32;
style.color = 0xf9827f;


When you want to display a single line of text, it is fairly easy to do so. Here is how to do it:

var element:TextElement = new TextElement("TEXTLINE!!!!", style); // we defined style earlier
var textBlock:TextBlock = new TextBlock();			
textBlock.content = element;
var textline:TextLine = textBlock.createTextLine(null, 200);
textline.x = 430;
textline.y = 36;


The things get more complicated when you want to display a paragraph:

var elementPar:TextElement = new TextElement("This is what some normal text in a textline paragraph looks like. The difference is subtle but there is one with the textline stuff.", stylePar);
var textBlockPar:TextBlock = new TextBlock();
textBlockPar.content = elementPar;
var paragraph:Sprite = new Sprite();
var line:TextLine = textBlockPar.createTextLine(null, 200);
var currentY:Number = 0;
	line.y = currentY;
	currentY += line.height;
	line = textBlockPar.createTextLine (line, 200);
paragraph.x = 430;
paragraph.y = 63;


So what now? Should we all start using TextBloc? I don’t know and to be frank it seems like even Adobe doesn’t know. But if you want better looking text, maybe you should.

, , , , , , , ,

No Comments

Parse error: syntax error, unexpected ';' in /homepages/25/d169645162/htdocs/wp-content/themes/fusion/footer.php on line 13