learn actionscript programming myassignmenthelp.net

13
ActionScrip t Programming Help www.myassignmenthelp.net

Upload: wwwmyassignmenthelpnet

Post on 09-Jun-2015

122 views

Category:

Education


0 download

DESCRIPTION

ActionScript is a object oriented scripting language. Like ECMAScript the Actionscript is similar to the java script. Actionscript provides the interactive functionalitry to the the web site. Actionscript is mostly used in the flash software developer can set and control the actions of the Flash objects. Actionscript provide the additional features to the animation with flash and to create advance interactive animations and applications for the users. Actionscript is used for the kids tutorials and games so that kids can understand the lessons more easily. This is used by many advertisement companies to create the advertisements banners with flash and small animations http://www.myassignmenthelp.net/programming-assignment-help.php

TRANSCRIPT

Page 1: Learn ActionScript programming myassignmenthelp.net

ActionScriptProgrammin

gHelp

www.myassignmenthelp.net

Page 2: Learn ActionScript programming myassignmenthelp.net

Introduction• ActionScript is an object-oriented programming language originally developed by Macromedia Inc. (now owned by Adobe Systems). It is a dialect of ECMAScript (meaning it is a superset of the syntax and semantics of the language more widely known as JavaScript), and is used primarily for the development of websites and software targeting the Adobe Flash Player platform, used on Web pages in the form of embedded SWF files.

Page 3: Learn ActionScript programming myassignmenthelp.net

Advantages of ActionScript

• ActionScript goes beyond the scripting capabilities of previous versions of ActionScript. It is designed to facilitate the creation of highly complex applications with large data sets and object oriented, reusable code bases. ActionScript is not required for content that runs in Adobe Flash Player, it opens the door to performance improvements that are only available with the AVM2, the new virtual machine.

Page 4: Learn ActionScript programming myassignmenthelp.net

Objects And Classes

• In ActionScript, every object is defined by a class. A class can be thought of as a template or a blueprint for a type of object. Class definitions can include variables and constants, which hold data values, and methods, which are functions that encapsulate behavior bound to the class. The values stored in properties can be primitive values or other objects. Primitive values are numbers, strings, or Boolean values.

• ActionScript contains a number of built-in classes that are part of the core language. Some of these built-in classes, such as Number, Boolean and String, represent the primitive values available in ActionScript. Others, such as the Array, Math, and XML classes, define more complex objects.

Page 5: Learn ActionScript programming myassignmenthelp.net

Variables

• Variables allow you to store values that use in your program. To declare a variable, you must use the var statement with the variable name.

var i; To associate a variable with data type you must do so when you declare a variable without designating the variable’s type is legal, but will generate a compiler warning in strict mode. You designate a variable’s type by appending the variable name with a colon(;) followed by the variable’s type.

var i:int;

Page 6: Learn ActionScript programming myassignmenthelp.net

Data types

• A data type defines a set of value. For example, the Boolean data type is the set of exactly two values: true and false. In addition to the Boolean data type, ActionScript defines several more commonly used data types, such as String, Number and Array. You can define your own data types by using classes or interfaces to define a custom set of values. All values in ActionScript 3.0, whether they are primitive or complex , are objects.

• A primitive value is a value that belongs to one of the following data types: Boolean, int, Number, String, and uint. Working with primitive values is usually faster than working with complex values, because ActionScript stores primitive values in a special way that makes memory and speed optimizations possible.

Page 7: Learn ActionScript programming myassignmenthelp.net

Syntax The syntax of a language defines a set of rules that must be followed when writing executable code.

• Case sensitivity

var num1:int;

var Num1:int;Dot syntaxSlash syntax

17

“hello”

-3

9.4

Null

Undefined

True

False

Page 8: Learn ActionScript programming myassignmenthelp.net

Operators

• Operators are special functions that take one or more operands and return a value. An operand is a value—usually a literal, a variable, or an expression—that an op

• For example,  in the following code, the addition(+) and multiplication(*) operators are used with three literal operands(2, 3 and 4) to return a value. This value is then used by the assignment(=) operator to assign the returned value, 14, to the variable sumNumber.

var sumNumber:unit = 2+3*4; // unit=14

14, to the variable sumNumber .

Page 9: Learn ActionScript programming myassignmenthelp.net

Conditionals• ActionScript provides

three basic conditional statements that you can use to control program flow.

• if..elseIf(x>20){Trace(“x is > 20”);}else{Trace(“x is <= 20”);}

Page 10: Learn ActionScript programming myassignmenthelp.net

if..else if

If (x > 20){

trace(“x is > 20”);}else if (x < 0){

trace(“x is negative”);}

Page 11: Learn ActionScript programming myassignmenthelp.net

Switch• var dayNum:uint = someDate.getDay(); • switch(dayNum)• { • case 0: • trace("Sunday"); • break; • { • case 1: • trace(“Monday"); • break; • { • case 2: • trace(“Tuesday"); • break; • default: • trace("Out of range"); • break;• }

Page 12: Learn ActionScript programming myassignmenthelp.net

Functions

• Functions are blocks of code that carry out specific tasks and can be reused in your program. There are two types of functions in ActionScript 3.0: methods and function closures . Whether a function is a called a method or a function closure depends on the context in which the function is defined. A function is called a method if you define it as part of a class definition or attach it to an instance of an object. A function is called a function closure if it is defined in any other way.

• Functions have always been extremely important in ActionScript. In ActionScript for example, the class keyword did not exist, so “classes” were defined by constructor functions.