mercoledì, giugno 18, 2008

DataGrid Text - Now You See It, Now You Don't

This problem was frustrating me this morning, and I thought it might be worth jotting down the solution. Have you ever tried applying an alpha effect to a Flash CS3 DataGrid component? (Or, perhaps any symbol/component that utilizes a dynamic text field?) You will notice that the text does not react to alpha properties. For example, consider this data grid:


If I set the alpha to zero in ActionScript 3 (myDataGrid.alpha = 0) I get the following result:



Now, it turns out there are two methods to make the text completely invisible.

  1. Set the visibility of the data grid to false: myDataGrid.visible = false. This is fine if the only goal is to toggle whether it is able to be seen. However, if any cool alpha transitions are desired (and why wouldn’t they be?), the next method is preferred.
  2. The key is to embed fonts! This is the case with all dynamic text. However, it’s a little trickier when using a component, such as a datagrid. Luckily, Peter deHaan has this excellent article on his blog: “Using embedded fonts with the Flash CS3 DataGrid component.”
    Note: you might also want to make note of this article if you wish to manipulate the font used in a data grid.