Agenda
● Overview of Actionscript 3.0
● Variables and data types
● Conditionals
● Loops
● Functions
● Binding to variables
Flash Platform
Actionscript
Flash Flex Framework
.swf .swf
Overview of Actionscript 3.0
● While MXML is sufficient for drawing the user interface on screen, embedding user interactions and changing application behaviour requires executing scripts (similar to the role Javascript plays in HTML documents).
● Why Actionscript 3.0 (AS3) was introduced?
● Needed a Object-oriented Programming Language to support large-scaled application development
● An attempt to bring developers on board onto the Flash platform, which was traditionally regarded as a playground for designers
● AS3 is based on ECMAScript, the same scripting engine of Java, hence, Java developers will find it easier to learn AS3.
P.S. Many products from Adobe are Java-based. (e.g. Coldfusion, BlazeDS, LiveCycle ES)
Overview of Actionscript 3.0
● Syntax:
● e.g.
● Common data types
Variables and Data Types
● In many cases, the program needs to behave differently or execute different codes based on certain scenarios.
● The most common conditional statement is the if-else statement.
● Syntax:
Conditionals – if-else statement
● If more than 2 test cases, include else-if statements.
● Syntax:
Conditionals – if-else statement
● Conditional operators are used to validate the test cases in the if clause.
Conditionals – Conditional Operators
● To include more than one test cases within a if or else-if clause.
Conditionals – Compound conditions
● Loops cause a block of codes to execute repeatedly, for as long as its test case holds true.
● All common looping methods are available in AS3:
● while loop● do-while loop● for loop
● for loop:
Loops
● A function is a grouping of a block of codes that can be executed when called.
● Reasons for using function:
● Reusability● Event handling
● e.g.
Functions
● Ensure a property or variable always get the latest value of another property or variable
● e.g.
Binding to Variables