MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manuel d'utilisateur Page 28

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 184
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 27
28 ActionScript 2.0 to 3.0
Using external files
This section describes changes to embedding, including, and importing external resources
with ActionScript in your Flex applications.
include
In ActionScript 2.0, the include keyword was preceded by an octothorp: #include. You now
use the keyword without the octothorp, and end the line with a semi-colon. For example:
ActionScript 2.0:
#include "../scripts/thescript.as"
ActionScript 3.0:
include "../scripts/thescript.as";
import
The import keyword lets you reference classes from other packages in your application. For
example, to use a
trace() statement in your custom ActionScript class, you import the
flash.util.trace class. The
import syntax is as follows:
import class;
For example:
import flash.util.trace;
You can optionally import entire packages using the wildcard syntax, as the following example
shows:
import flash.util.*;
However, best practices dictate that you only import the classes you need and not the entire
package. Doing so is better for performance and debugging.
ActionScript 3.0 uses a number of implicit imports to provide direct access to common global
functions such as
trace(). In ActionScript 3.0, the number of implicit imports has been
reduced. For more information, see “Explicit imports” on page 34.
It is important to understand that you should import classes with an import statement rather
than use the full classname in your code. For example, do this:
import mx.formatters.*;
public var f:NumberFormatter = new NumberFormatter();
Rather than this:
public var f:mx.formatters.NumberFormatter = new
mx.formatters.NumberFormatter();
Vue de la page 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 ... 183 184

Commentaires sur ces manuels

Pas de commentaire