PDA

View Full Version : Turning off Anti Alias for bitmap text.


crackhead
08-08-2007, 12:18 PM
Another Question from me :D

How does one remove AA via AS3 code?

For example, im using a fontsforflash font in a menu and i seen that you have

AntiAliasType.ADVANCED
AntiAliasType.NORMAL

however, why is there no AntiAliasType.NONE ?

The reason im asking in a forum is because i did google this yesterday, and i found something on flashkit about how you cannot turn AA off at runtime, and recommended was to use bitmaps instead.

I refuse to believe this.

Any ideas?

thanks in advance

Rezmason
08-08-2007, 02:09 PM
I've gotten it to work by doing the following:


Add your pixel font to the Library. You can do this by clicking the Library's option button and choosing "New Font..." in the menu that appears.
In the font's Properties dialog box, check the option "Bitmap Text". Pick its size (which is in pixels), and remember this number.
In the embedded font's Linkage dialog box, check the option "Export for ActionScript".
Back in your code, set the font of your bitmapped text format to the String literal "[fontname]_[size]pt_st", where [fontname] is the name of your font and [size] is the size you gave it in the Properties box. Also make the bitmapped text format's size equal to [size].
Set the destination TextField's embedFonts property to true.


EDIT: And whoever suggested using straight-up bitmaps in the Flashkit forum is just silly. Which is a polite way for me to say, they're idiotic. When an obstacle like this reveals itself while you're coding, and there's not much documentation, a programmer has to do some sleuthing as you have in order to find an adequate solution. It comes with the territory.

Dan0
08-08-2007, 05:52 PM
OK here is my "better" way which is in-fact "worse" but will give you more freedom (and personally more trust that it will damn work) ;

- Add your font to the library, set whatever size you want *don't check the bitmap font box*.
- reference to it in AS3 like this : "<font name>" where <font name> is the exact name of the font as it showed up in the dialog box where you embeded it.
- You can then use a TextFormat object to set up your format with whatever size you want your text.
- If your text field is called myTextField then do this:
myTextField.antiAliasType=AntiAliasType.ADVANCED;
myTextField.sharpness = 400;- Play around with the sharpness, its between -400 to +400;
- This will allow your font to render at any rotation/scale
- I am using this currently as using that "bitmap font" checkbox is a bad idea in my experience of the new flash.

If you set the stage quality to low it turns AA of in the whole flash file and probably all the children flash files you load in (I assume).
stage.quality = StageQuality.LOW;

One last thing, don't trust the font rendering in Flash 9, it has mysterious ways about it... :evil::pa::ex:

scoult01
08-08-2007, 07:59 PM
How did you manage to embed it using AS? I was unable to get the [Embed] to work, and was forced back to importing it into the library and then referencing it through there :(

EDIT:
http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/

Follow what Rezmason suggested and add:
ActionScript Code:
label.antiAliasType = AntiAliasType.NORMAL;

Rezmason
08-09-2007, 12:51 AM
Another idea that just came to me is using an authored DynamicText object as a reference.

The biggest disadvantage to doing all this font stuff in AS3 is there's no WYSIWYG. Use Flash's existing font system to make your font look right in a DynamicText object, and then use AS3 to poll it for the proper font names and settings. That way, you get rid of all the mystery. Just remember, text in the authoring environment (even pre-made stuff) won't look exactly like what's onscreen when you compile. So test your movie in order to fine-tune your text appearance.

mathew.er
08-09-2007, 04:50 AM
Quite nice solution is also to use bitmap fonts, that work even with anti-aliasing on (and often only with anti-aliasing). Look here, for example, http://www.fontsforflash.com/

Dan0
08-09-2007, 10:33 AM
Heh, FFF doesn't solve the problem, somtimes you can't make the font .x and .y properties always rounded, creating AA problems. Currently I actually have quality set to LOW as I don't want AA anywhere in my site. I also used the sharpness thing, that I posted above, before turning the quality to LOW and it worked perfectly.