ActionScript 3 Optimizing Performance Text


Rendering text consumes a lot of CPU. Fonts are rendered in a fashion similar to vector graphics and contain many vector points for every character. Altering text frame-by-frame will degrade performance. The "Cache as bitmap" flag is extremely useful if used correctly, meaning you must avoid:

  • Altering the text frequently.
  • Transforming the text field (rotating, scaling).

Simple techniques like wrapping text updates in an if statement will make a major difference:

if (currentScore !== oldScore) {
    field.text = currentScore;

Text can be rendered using the anti-aliased renderer built into Flash, or using "device fonts". Using "device fonts" makes text render much faster, although it makes text appear jagged (aliased). Also, device fonts requires the font to be pre-installed by your end user, or the text may "disappear" on the user's PC although it appears fine on yours.

field.embedFonts = false; // uses "device fonts"