ActionScript 
Programming 
Help 
www.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.
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.
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.
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;
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.
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 syntax 
Slash syntax 
17 
“hello” 
-3 
9.4 
Null 
Undefined 
True 
False
14, to the variable sumNumber . 
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
Conditionals 
• ActionScript provides three basic 
conditional statements that you can use to 
control program flow. 
• if..else 
If(x>20) 
{ 
Trace(“x is > 20”); 
} 
else 
{ 
Trace(“x is <= 20”); 
}
if..else if 
If (x > 20) 
{ 
trace(“x is > 20”); 
} 
else if (x < 0) 
{ 
trace(“x is negative”); 
}
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; 
• }
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.
QUERY 
www.myassignmenthelp.net

Learn ActionScript programming myassignmenthelp.net

  • 1.
    ActionScript Programming Help www.myassignmenthelp.net
  • 2.
    Introduction • ActionScriptis 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.
  • 3.
    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.
  • 4.
    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.
  • 5.
    Variables • Variablesallow 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;
  • 6.
    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.
  • 7.
    Syntax The syntaxof a language defines a set of rules that must be followed when writing executable code. • Case sensitivity var num1:int; var Num1:int; Dot syntax Slash syntax 17 “hello” -3 9.4 Null Undefined True False
  • 8.
    14, to thevariable sumNumber . 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
  • 9.
    Conditionals • ActionScriptprovides three basic conditional statements that you can use to control program flow. • if..else If(x>20) { Trace(“x is > 20”); } else { Trace(“x is <= 20”); }
  • 10.
    if..else if If(x > 20) { trace(“x is > 20”); } else if (x < 0) { trace(“x is negative”); }
  • 11.
    Switch • vardayNum: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; • }
  • 12.
    Functions • Functionsare 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.
  • 13.