Randomize Everything

Icon

And create the perfect world

Quicktip #6: Fixing the cut off character on embedded-font-textfields

As we all know, Flash has these crazy bugs nobody ever understands. One of those is the fact that the last character of a dynamic textfield (which has been set to “AutoSize”) gets cut off when you’re using an embedded font. Up till now I still don’t understand what kind of situation leads to this exceptional behavior. The only thing I can say is that Flash Player fails to determine the correct text length which screws up the textfield width to be shorter than it has to be.

Example:

Blurred/Cut Off Characters

Blurred/Cut Off Characters





A quicktip post wouldn’t be a quicktip post without a solution. So, here’s one of the tricks you might give a go: increase the rightMargin property of the TextField to a small value like 1 or 2.

var textFormat:TextFormat = new TextFormat();
textFormat.rightMargin = 1;
 
textField.antiAliasType = AntiAliasType.ADVANCED;
textField.gridFitType = GridFitType.SUBPIXEL;
textField.embedFonts = true;
textField.autoSize = TextFieldAutoSize.CENTER;
textField.defaultTextFormat = textFormat;
textField.setTextFormat(textFormat);

Hope this helps!

Category: ActionScript 3, Flash, Flex, QuickTips

Tagged: , , ,

7 Responses

  1. You made my day (actually, night). Thanks!!

  2. Hardik says:

    Excellent! I was wondering how to solve this. This little solution was a lot of help. Thanks!

  3. EllTheDog says:

    Thanks a load!! Been trying to sort this for ages. I hate flash sometimes.

  4. Chris says:

    Lol! I’ve been figuring out this problem (on my own) for years when i’ve decided just now, “Why not search it on Google?”

    Thanks!

  5. Craig says:

    Thanks dude. Very helpful, was pulling my hair out all afternoon even though my client didn’t care.

  6. Naagas says:

    Thank you so much. Your quick tip is really quick!

  7. andy sandru says:

    thanks dude. finally fixed the stupid chopped text.

Leave a Reply