is supported in part by

April 04, 2007

Chapter 15, Paragraphs 1-6, Essential ActionScript 3.0

Here are the first 6 paragraphs of Chapter 15 of Essential ActionScript 3.0

15. Dynamic ActionScript

ActionScript was originally conceived of as a language for adding basic programmatic behavior to content created manually in the Flash authoring tool. In early versions of ActionScript, most code was intended to be written in short scripts that implemented limited functionality compared with the code required to create a complex desktop application. As such, ActionScript’s original feature set stressed flexibility and simplicity over formality and sophistication.

ActionScript originally allowed the structure of all classes and even all individual objects to be modified dynamically at runtime. For example, at runtime, a program could:

* Add new instance methods or instance variables to any class
* Add new instance methods or instance variables to any single, specific object
* Create a new class entirely from scratch
* Change a given class’s superclass

With the advent of ActionScript 3.0, Flash Player 9, Apollo, and Flex, the Flash platform has evolved to a stage where the complexity of an ActionScript-based program may well rival the complexity of a full-featured desktop application. Accordingly, as a language, ActionScript has taken on many of the formal structures required for large-scale application development—structures such as a formal class keyword an inheritance syntax, formal datatypes, a built-in event framework, exception handling, and built-in XML support. Nevertheless, ActionScript’s dynamic features remain available in the language, and still constitute an important part of ActionScript’s internal makeup.

This chapter explores ActionScript’s dynamic programming techniques. Note, however, that the flexibility inherent in dynamic ActionScript programming limits or removes most of the benefits of type checking we studied in Chapter 8. As a result, most complex programs use the features described in this chapter only sparingly, if at all. For example, in the over 700 classes defined by the Flex framework, there are approximately only 10 uses of dynamic programming techniques. That said, even if you never intend to use dynamic programming in your code, the information presented in this chapter will improve your understanding ActionScript’s internal workings.

For our first dynamic programming technique, we’ll study dynamic instance variables—instance variables added to an individual object at runtime.

Posted by moock at April 4, 2007 10:57 PM