...ndid, the somewhat small but happy love child of Nicolás Delfino. A company specialized in interactive websites and rich media applications, knee deep in actionscript and down with jazz...

Posts Tagged ‘fonts’

AS3 Custom anti-alias

Posted on: December 13th, 2010

Ever wanted to change the thickness and sharpness settings through actionscript but didn´t know how?

Flash IDE:

To edit these settings within Flash you just need to click on your textfield and choose “Custom anti-alias” in the Anti-alias dropdown:

The actionscript way:

Doing the same thing in code requires a few steps and it can get a bit repetative, writing a class to handle stuff like this is maybe a good idea, anyway:

	import flash.display.Sprite;
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.GridFitType;
	import flash.text.TextField;
	import flash.text.TextFormat;

	public class CustomAntiAliasExample extends Sprite
		private var _t_format	:TextFormat = new TextFormat();
		private var _tf			:TextField = new TextField();
		private var _customFont	:Font = new ProjectFont();

		public function CustomAntiAliasExample()
			t_format.font 			= _customFont.fontName;
			t_format.size 			= 15;
			t_format.color 			= 0x000000;
			t_format.bold 			= true;

			// -------------------------------------> ANTI ALIAS PART:

			_tf.gridFitType 		= GridFitType.SUBPIXEL;
			_tf.antiAliasType 		= AntiAliasType.ADVANCED;

			// thickness:
			_tf.thickness 			= 50;
			// sharpness:
			_tf.sharpness 			= -200;

			// -------------------------------------------------------

			_tf.embedFonts 			= true;
			_tf.defaultTextFormat 	= t_format;
			_tf.text = "Hello World";


/ Nicolas