Unformatted text preview:

- Pallav Gala ACTIONSCRIPT 3.0What‟s ActionScript?  A programming language, developed by Macromedia Inc. (taken over by Adobe Systems)  Used for websites and applications based on Adobe Flash Player and Adobe AIR run-time environments  Compliant to ECMAScript, syntactically similar to JavaScript  Executes in the ActionScript Virtual Machine (AVM)A brief history…  ActionScript 1.0 - Introduced in 2000 - Provided prototype-based programming and loose type system feature  ActionScript 2.0 - Introduced in 2003 - Provided class-based programming, compile time type checking and cross compilation to ActionScript 1.0 codeActionScript 3.0  Introduced in 2006 with release of Adobe Flash Player 9 and Adobe Flex 2.0  Executes up to 10 times faster than the legacy ActionScript code on the new highly optimized ActionScript Virtual Machine(AVM2)  Provide a true object oriented model for programmers  Enables creation of applications with large data sets and object oriented reusable codeFeatures of ActionScript 3.0  Since ActionScript 3.0 is fundamentally and architecturally different from AS 2.0, it provides many new features that increase performance and control over low-level objects  Core Language Features  API FeaturesCore Language Features  Defines the fundamentals of the programming language such as data types, expressions, loops, etc.  ActionScript 3.0 provides: - Run-time exceptions (reports more error conditions) - Run-time types (provides perform run-time type checking) - ECMAScript for XML (E4X) (AS3 implements E4X) - Sealed classes (includes the concept of sealed classes) - Method closures (to remember object instance, useful in event handling)Flash API Features  ActionScript 3.0 includes the following new APIs that give the user a better control over objects at a lower level - DOM3 event model (provides a standard way of generating and handling events) - Display list API (provides a set of classes for working with the visual primitives in Flash) - Working with text (provides a flash.text package for all text-related APIs)Let‟s Get Started  With this basic idea of what ActionScript is, lets learn some basic programming concepts and then move on to some advance topicsBasic Programming Concepts ActionScript, like other programming languages provides basic features to users, such as:  Variables  Constants  Data Types  Operators  Conditional Statements  Looping StatementsVariables and constants  A variable represent a piece of DATA to be used in the program  Declaring and initializing a variable  A constant represents a piece of DATA that can be assigned a value only once during the course of program execution var xyz:Number = 10; Keyword Data Type Variable Name const xyz:Number = 10;Data Types Complex Data Types Represent a set of values in a container Examples: - MovieClip: a movie clip symbol - SimpleButton: a button symbol - Date: information about a single moment in time - TextField: a dynamic or input text field Simple Data Types Represent a single piece of data Examples: - String: A text, or array of characters - Number: Any numeric value - Int: Only integer values - Boolean: True or False valueOperators  Special functions that use one or more operands and return a specific value Examples: - Arithmetic : +, -, *, /, % - Logical : &, !, ^, |, &&, || - Relational : >, <, >=, <=, ==, != - Assignment : =, +=, -= - Primary : [], new, ., @, :: - Unary : ++, --, typeof, voidConditional and Looping Statements  Conditional Used to execute certain statements based on the condition Example: - if..else - If..else if - switch  Looping Used to execute a block of code repeatedly, a certain number of times Example: - for - for..in - whileObject Oriented Programming in ActionScript  OOP is basically a way to organize our code with the help of objects  ActionScript 1.0 and 2.0 provided support for OOP, but was limited  ActionScript 1.0 used Function Objects, to create constructs similar to classes  ActionScript 2.0 introduced the concept of classes by adding the keywords „class‟ and „extends‟  ActionScript 3.0 extends over the previous versions and provides better functionalities to developersClasses(I)  The heart of all object-oriented code development  An abstract representation of object  ActionScript classes have three types of characteristics - Properties - Methods - Events public class Hello { public var string:String = "Hello World"; public function Hello() { trace(string); } }Classes(II)  Properties - Like variables, represent one piece of data - Example: Defines a property „string‟ of the type „String‟ and initializes it to “Hello World”  Methods - Functions or behaviors that the object performs or exhibits - Example: Defines a method Hello(), which displays the content of „string‟. This method is a constructor public var string:String = "Hello World"; public function Hello() { trace(string); }Classes(III)  Events - Mechanisms that determine which statements need to executed and when - Events are things that occur and need to be responded to - For example, a mouse click by user or a key typed in by user - Following shows the ActionScript code to handle an event function eventResponse(eventObject:EventType):void { // Actions performed in response to the event } eventSource.addEventListener(EventType.EVENT_NAME, eventResponse);Class Object  For every class, ActionScript creates a special class object that allows sharing of both behavior and state  Though it may not have practical implications for many applications  The block diagram below represents the structure of a class object, of a class A CA-Contains references to other objects TA-Stores the instance properties PA-Represents the class object it was attached through constructor TCA-Represents static properties defined by the classMy First Program: „Hello World‟  ActionScript code can be compiled and run in any Flash Authoring environment  I used Adobe Flash Professional CS5 to run my code  Flash Professional CS5 provides two tools for writing ActionScript code: - Action Window: Allows to write ActionScript code attached to frames on a timeline - Script window: Dedicated text


View Full Document

CU-Boulder CSCI 5448 - Actionscript

Documents in this Course
Django

Django

42 pages

ENRS

ENRS

30 pages

PhoneGap

PhoneGap

22 pages

Load more
Download Actionscript
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Actionscript and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Actionscript 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?