Day # 3 – Introduction to ActionScript – Part 1
- ActionScript 3.0 is compliant with ECMA-262 specification & leverages parts of ECMAScript edition 4 spec
- There are 3 tiers of ActionScript APIs

- Ways ActionScript could be used in Flex
- Inline within MXML tags
- Nested within MXML tags
- In MXML scripts
- Within ActionScript classes
- Since ActionScript may use special characters otherwise interpreted by MXML compiler, we use CDATA block
<mx:Script> <![CDATA [ ----- - - - - ]]> </mx:Script>
- ActionScript class files are text files that use the file extension .as
- MXML gets converted into ActionScript during compilation
- MXML tag === equivalent to === creating a component instance.
<mx:Button id="button"/> === var button:Button = new Button();
- MXML component tags correspond to ActionScript classes
- MXML document themselves are essentially ActionScript classes
- An Application document is a class that extends mx.core.Application
- Code within MXML script === placing code in the class body
- Variable declaration within MXML scripts === properties of class
- Function within MXML scripts === methods of class
- Packages groups together classes so that you can ensure uniqueness of scope.

- ActionScript allows you to reference a class by the shorthand notation if you first add an import statement
- ActionScript class consists of -
Class Package declaration
Class declaration
- Each ActionScript class must be defined in it’s own file.
- Name of the file should be same as class name
- A package name in ActionScript corresponds to the directory structure within which the file is stored
- Class names start with a capital letter by ‘Convention’
- It’s possible to declare a variable without a datatype. (Remember Javascript?)
- Flex applications provide both runtime & compile time type checking
- Variables defined within a function inside a class are ONLY available within the function
- Variables defined in a class but outside any functions become properties of that class. They are available throughout the class
- Access Modifiers

- In addition to this we also have ’static’ modifier which says that a property is directly accessible from the class rather than the instances.