C.1 Best Practices in Flash 6 ActionScript

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Appendix C.  Backward Compatibility and Player Build Updates

Very little of Flash 5 ActionScript was formally deprecated in Flash 6. The following formal changes to the language were introduced in Flash 6:

  • The eval( ) function cannot be used on the left side of an assignment operation.

  • Function scope is defined permanently at declaration time instead of at invocation time. See Section 9.7.

The following list presents new features that are preferred over previous Flash 5 alternatives:

  • Global variables should be defined on _global, not _root or Object.

  • Superclass constructors should be executed via the super operator, not a manual reference to the superclass constructor function.

  • All imported text should be in Unicode, not Latin 1 or Shift-JIS.

  • Movie clip and button event handlers should be assigned as object properties, not with the onClipEvent(event) or on(event) syntax. See the ActionScript Language Reference for specific exceptions for individual events.

  • Text field content must be accessed via the TextField.text property, not the text field's variable name.

  • JPEG files should be loaded directly using loadMovie( ), not wrapped in .swf files.

  • Often, timeline and onEnterFrame( ) loops can be replaced with setInterval( ).

  • A local SharedObject should be used in favor of a JavaScript cookie.

  • System.capabilities.version is preferred over getVersion( ) (though getVersion( ) must still be used in movies displayed in Flash Player 5).

  • The Key and Mouse object events onKeyDown( ), onKeyUp( ), onMouseDown( ), and onMouseUp( ) should be used in place of analogous MovieClip events, except when updateAfterEvent( ) is required.

  • The LoadVars class supercedes the loadVariables( ) function.

  • Stage.scaleMode and Stage.showMenu replace fscommand("allowscale") and fscommand("showmenu").

For more best practices in Flash 6 ActionScript, see:

http://www.macromedia.com/desdev/mx/flash/whitepapers/actionscript_standards.pdf

As a rule, the new objects, classes, statements, and operators introduced in Flash 6 (as listed in the Preface) cannot be used when exporting to Flash 5 format. Three exceptions are the switch statement and the strict equality and inequality operators (= = = and !==), which are all available when exporting from the Flash MX authoring tool to Flash 5 format. When a movie is set to export as version 5, the Flash MX Output window reports any incompatibility warnings at export time.

     


    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net