DOC PREVIEW
CU-Boulder CSCI 5448 - Actionscript

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

W A R R E N F E R N A N D E SA P R I L 1 , 2 0 1 1ActionScript 3.0Outline About Usage AVM Goals Features Language and Syntax Object-oriented programming principles2About ActionScript 3.0 Object-Oriented Programming Language Originally developed by Macromedia Inc.  Currently owned by Adobe Systems Dialect of the ECMAScript, Supports 3rdedition (ECMA-262) Supports functionality in 4thedition (ECMA for XML or E4X)3ECMAScript ActionScript 3.0 International scripting language standardization Used for client-side scripting on the web JavaScript, JScript, and ActionScript 4Usage ActionScript 3.0 Enhances the web experience through rapid development of rich internet applications Used in software targeting Adobe Flash Player, Adobe Flex, and AIR platform Goes beyond scripting capabilities by supporting creation of complex applications with large data sets and object-oriented, reusable code bases Click on buttons for examples ActionScript is executed by the AVM5Tour de Flex Flex StoreAVM ActionScript 3.0 ActionScript Virtual Machine or AVM Built into the Flash Player ActionScript is compiled and run on AVM Versions: AVM1 – executes legacy ActionScript code AVM2 – executes ActionScript 3.0 code6AVM2 ActionScript 3.0 Built from scratch just for ActionScript 3.0 Highly optimized and improves performance by 10 times compared to previous versions Supported in Flash Player 9.0 and higher These flash players also support AVM1 for backward compatibility7Design Goals ActionScript 3.0 Safety Supports type safety. Simplicity Intuitive for developers to be able to read and write programs. Performance Allows complex programs to perform efficiently and responsively. 10 times increase in performance. Compatibility Backward compatibility. AVM1 and legacy AS code Forward compatibility. ECMAScript for XML (E4X) 8Features ActionScript 3.0 ActionScript 3.0 has two main features The core language Flash Player API Core Language Statements, conditions, expressions, loops, types Flash Player API Classes that represent and provide access to Flash Player specific functionality9Language Basics ActionScript 3.0 Packages Allows bundling of class definitions together to facilitate code sharing and avoid naming conflicts Namespaces Allow control over visibility of individual properties and methods Variables To declare a variable, the var statement must be used with the variable name and assign a type using the colon (:) operatorvar i: int; Untyped variables are declared as var i:*; or var i;They hold the value undefined10Language Basics ActionScript 3.0 Data Types The primitive data types include Boolean, int, Null, Number, String, uint, and void Other data types are Object, Array, Date, Error, Function, RegExp, XML, and XMLList Number is used to store integers larger than int and uint and for floating point numbers void type contains the value undefined. This can only be assigned to untyped variables. This is usually used as a return type. Undefined type was added into the language based on ECMAScriptcompliance11Language Basics ActionScript 3.0 Objects Collections of properties These properties are containers that hold data as well as functions or other objects. If a function is attached to an object like this, it is called a method Loops – for..in This is a new loop in addition to the other standard loops This loop iterates through the properties of an object, or the elements of an array.var myObj: Object = {id: 2002, fname: “Warren”};for (var i:String in myObj){trace (i +”: ” + myObj[i]);}12Output:id: 2002fname: WarrenLanguage Basics ActionScript 3.0 Functions Functions are defined in two ways: function statements and function expression Function Statements are the standard, preferred technique in defining functionsfunction myFunc(param:String){// function body} Function expressions are more dynamic and define anonymous functions. It is used with an assignment statementvar tp:Function = function (param:String){// function body};13Classes OOP Principles Classes Represented by class objects that store the class properties and methodspublic class Shape{var visible:Boolean = true;}var myCircle: Shape = new Shape(); Other attributes, access modifiers, variables, and methods are similar to other OOP languages such as Java. Class attributes – final, dynamic, internal (default), public Class access modifiers – internal(default), private, protected, public, static14Interfaces OOP Principles15 Interface is a collection of method declarations that allows unrelated objects to communicate with one another To define an interface we use the interface keyword Only the public and internal modifiers can be used within an interface Interface definitions cannot be placed within a class or another interface A class uses an interface by using the implementskeywordInterfaces OOP Principles Example,public interface IAlpha{function foo(str:String):String;}public interface IBeta{function bar():void;}class Alpha implements IAlpha, IBeta{public function foo(param:String):String{}public function bar():void{}}16Multiple interfacesmay be implementedBy convention, we use „I‟ in the beginning of the interface nameInheritance OOP Principles Inheritance is a form of code reuse that allows us to develop new classes based on existing classes Key advantage is to reuse code from the base class while defining separate implementations for the subclass A subclass inherits a base class by using the keyword extends Subclass has an “IS-A” relationship with the base class17Inheritance OOP Principlespublic class Shape { public function area():Number { return NaN; } } public class Circle extends Shape { private var radius:Number = 1; public override function area():Number { return (Math.PI * (radius * radius)); } } public class Square extends Shape { private var side:Number = 1; public override function area():Number { return (side * side); } } var cir:Circle = new Circle(); trace(cir.area()); var sq:Square = new Square(); trace(sq.area()); 18Output: 3.141592653589793Output: 1Subclass Circle inherits properties from Base class Shape by using the keyword extendsEncapsulation OOP Principles Encapsulation is the ability to hide and protect data It is implemented by applying


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?