Archive

Archive for April, 2008

Setting antiAliasType for Flash CS3 Components

April 10th, 2008 Randy 1 comment

In a previous post on custom cellrenders in Flash CS3 I discussed my trials with replacing the cell contents of a List control with my own creation.

Recently I came up against a problem with using a stock List control. The problem is that the default setting for the textfield antiAliasType is NORMAL which means the type renders in a pre-Flash 8 manner. I want the antiAliasType to be set to ADVANCED to take advantage of the Saffron Type System.

There is a method to style the renderer in a list control:

Actionscript:
  1. list.setRendererStyle("embedFonts", true);
  2. list.setRendererStyle("textFormat", myTextFormat);

The word is that they didn't have time to add "antiAliasType" to this API. The answer to my problem was to use another method that allows a crafty developer to extend CellRenderer and then tell the List to use this class with this line (note: be sure to import your CustomCellRenderer class):

Actionscript:
  1. list.setStyle("cellRenderer", CustomCellRenderer);

Then in your custom class you need to manually set the anitAliasType of the property "textField"

Actionscript:
  1. package ca.nait.d3.controls.video {
  2.     import fl.controls.listClasses.CellRenderer;
  3.     import flash.text.AntiAliasType;
  4.  
  5.     public class CustomCellRenderer extends CellRenderer{
  6.         public function CustomCellRenderer(){
  7.             textField.antiAliasType = AntiAliasType.ADVANCED;
  8.         }
  9.     }
  10. }

Categories: Flash development Tags: