O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Warnings for Missing Type Annotations

As we've seen over the past several sections, ActionScript's strict compilation mode provides a valuable way to detect program errors as early as possible. Not surprisingly, in an effort to write problem-free code, many developers rely heavily on strict mode's compile-time type checking. However, as we learned in the earlier section "Untyped Variables, Parameters, Return Values, and Expressions," strict-mode's type-mismatch errors are reported for typed variables, parameters, and return values only. Any time a type annotation is accidentally omitted, the programmer loses the benefit of strict mode's compile-time type checking.

Luckily, Adobe's ActionScript compilers offer a warning mode in which missing type annotations are reported at compiletime. Developers can use those warnings to help locate accidentally omitted type annotations. In Flex Builder 2 and mxmlc, warnings for missing type annotations are enabled by default. In the Flash authoring tool, type annotation warnings must be enabled manually, using the following steps:

  1. Using a text editor, in the Flash CS3 installation folder, under /en/Configuration/ActionScript 3.0/, open EnabledWarnings.xml.

  2. Locate the following line:

    <warning id="1008" enabled="false" label="kWarning_NoTypeDecl">
      Missing type declaration.</warning>
  3. Change enabled="false" to enabled="true".

  4. Save EnabledWarnings.xml.

Note that missing type-annotation warnings are issued for implicitly untyped variables, parameters, and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required