Professional Documents
Culture Documents
Preface
Adobe Flash CS3 is a revolutionary program used to create presentations, applications, and other
content that enables user interaction. ActionScript 3.0 language is used to add interactivity to Flash
applications.
The Scripting with Flash book is designed to introduce students to Flash ActionScript 3.0. Using this
book, the students can learn the basic elements of ActionScript 3.0. They will also learn to create
variables and functions, and use ActionScript to control properties and methods of movie clip. The
book also describes the various data types and pre-built components that are used to enhance Flash
projects and debug code.
The ARENA Design team has designed this course keeping in mind that motivation coupled with
relevant training and methodology can bring out the best. The team will be glad to receive your
feedback, suggestions, and recommendations for improvement of the book.
Please feel free to send your feedback to the ARENA Design team at the Head Office, Mumbai.
(Feedback form is attached at the end of the book.)
Table of Contents
Introduction to ActionScript 3.0 and Programming Concept.
Introduction and Programming Fundamentals
Use of Action Panel
Using Trace and Comments
Basic Programming Concepts
Controlling Movie Clips
Basic Event Handling
Data Types
Array
String
Summary
Exercise
Components
Capturing User Inputs
Controlling Mouse
Working with Clips
Using Components
Summary
Exercise
Answer Key
Iconography
: System Requirements
: Note
: Quick Test
: Quick Answers
: Exercise Answers
Se ssi on 1
System Requirements
Windows Operating System
Windows Operating System
Intel Pentium 4 or AMD Athlon 64 processor
Microsoft Windows XP with Service Pack 3 or Windows 7 with Service Pack 1
2 GB of RAM (3 GB recommended)
3.5 GB of available hard-disk
Java Runtime Environment 1.6
Graphics card with at least 64 MB of VRAM
QuickTime 7.6.6 software required for multimedia features
1024768 display (1280800 recommended)
ActionScript is the programming language used for controlling Flash movies and applications. Using
ActionScript, you can create actions to display data on any application. You can also create complex
interactivity in the application and control its playback. While scripting, it is not necessary to
understand every ActionScript element. Using simple actions, you can create scripts.
ActionScript can be added to your application by using the Actions panel, Script window, or any other
external editor. It contains reserved keywords and follows its own rule of syntax.
In ActionScript, variables are used to store and retrieve information. It contains a large library of builtin classes that allow you to create objects to perform many useful tasks. ActionScript is similar to
JavaScript and both are rooted in ECMA-262 standard. It is an international standard for ECMAScript
scripting language.
In this session, you will learn about the programming fundamentals and the basic programming
concept. You will also become familiar with the different data types used.
History of ActionScript
ActionScript was used as a scripting language for Macromedia Flash authoring tool. Flash was
developed by Macromedia. In 2005, Adobe took over Macromedia and thus, Flash was owned by
Adobe. The first three versions of Macromedia Flash authoring tool provided limited interactivity
features. Earlier, Flash developers used to attach a simple action command to a button or a
frame. The set of actions were limited to basic navigation controls, with commands such as play,
stop, get URL, and goto and play.
In Flash 4.0, these simple set of commands are changed to small scripting languages. New
capabilities introduced for Flash 4, included variables, expressions, operators, if statements, and
loops.
ActionScript 2.0 is simpler to learn than ActionScript 3.0. Although Flash Player runs compiled
ActionScript 2.0 code slower than compiled ActionScript 3.0 code, ActionScript 2.0 is still useful for
many kinds of projects.
The earlier versions of ActionScript Virtual Machine (AVM) used ActionScript 1.0 and ActionScript
2.0 code. Flash Player 9.0 supports AVM1 for backward compatibility with existing and legacy
content. Flash supports more than one version of ActionScript. Therefore, it enables you to fulfill
various requirements of the developers.
To display the Actions panel, on the Windows menu, click Actions or press the F9 key. The
Actions panel, as shown in Figure 1.1, will be displayed.
Actions Toolbox
All the elements in this toolbox are categorized. You can access the elements using the
alphabetical index. When you double-click on any element from the categories, it is added to
the Script pane. You can also add an ActionScript element into the Script pane by dragging it
directly to the Script pane.
Script Navigator
Using this navigator, you can quickly swap between the scripts in a Flash document. When you
click any item in the Script navigator, the script related to that item is displayed in the Script
pane and the playhead moves to that position on the Timeline. If you double-click an item in the
Script navigator, the script is pinned.
Script Pane
The Script pane is used to enter the code. You can write the ActionScript directly into the
Script pane, but to reduce the amount of typing, you can also select or drag the actions from
the Actions toolbox to the Script pane. You can also use the Add (+) button to add scripts in
the Script pane.
In the Actions panel, you can drag the vertical bar between the Actions toolbox and Script
pane and resize them. If you double-click the vertical bar, the Actions toolbox will be hidden.
To display it again, double-click the bar. When the Actions toolbox is hidden, you can access
the items available in it using the Add (+) button. You can expand or collapse the Actions
toolbox by clicking the arrow on the vertical bar. You can click the Show/Hide Toolbox button ,
at the top of the Actions panel, to hide or view the ActionScript toolbox.
var james = 5;
var smith = 4;
trace(james);
The output for this piece of code is 5.
Note
The Flash developer can only debug errors that appear in the code. The user can view the
contents of the Output window.
Now, if the trace() statement code is modified to,
trace(james+smith);
The output of the program will be 9. The values assigned to both the variables, James and smith
are added and their sum is displayed in the Output window.
Using comments
Using comments, you can temporarily deactivate a part of the code. By doing this, you can check
the functionality of the various parts of the Flash movie. Comment lines can also be added in the
code in order to explain what it does. Thus, you can comment a code without deleting it for the
future use.
To comment a single line in the code, use two forward slashes (//) in front of the line. For
example,
var james = 5;
//var smith = 4;
trace(james);
To comment multiple lines of code, use a forward slash (/) followed by an asterisk (*) in front of
the first line and asterisk followed by a forward slash at the end of the last line. For example,
/*var james = 5;
var smith = 4;
trace(james);*/
When codes cross more than 100 lines, comments are the best way to write some explanations
that will help you when you return to your code a couple of months later.
For detailed step-by-step procedure, refer demo Using Trace and Comments from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
Actions
Script
None of these
2. The Script Navigator displays all the items of the movie, as well as the movie
structure.
True
False
hide()
display()
trace()
1.4.1 Variables
Variables can be a representation of numbers, string of characters, or some other values. It can be
considered as a container that is used to store information. In ActionScript, the information stored in
variables are known as objects till the program is running. Variables are the important elements and
are used in nearly every aspect of programming.
Now, consider you have two variables, value1 and value2, and each of these variables have a
value assigned to them. You need to add these two numbers. Therefore, the code will be,
value1 + value2;
Now, the output displayed will be the sum of the values stored in these variables.
In ActionScript, a variable should consist of a variable name, the type of data that can be stored in the
variable, and the actual value stored in the computers memory.
While declaring a variable in ActionScript, it is necessary to specify its data type. Once the data type
is specified, the variable will store information or value related to that data type and will not accept any
other type of data. You can also manipulate or modify the value in the variable by using the
characteristics associated with the data type.
1.4.2 Operators
Operators are built-in functions like commands that operate on one or more values. Unlike functions,
operators do not need parentheses to function.
While processing the program, certain mathematical operators are processed first due to the laws of
arithmetic. In general, complex operations will be executed first followed by simpler operations. Thus,
operators follow a certain order of operations.
In ActionScript, operations are executed in the following order:
Expressions within the parentheses are executed first, starting from the complex to simpler
operation. Parentheses can be used to group expressions that have to be evaluated first.
The results of the functions are evaluated assuming all their arguments are evaluated.
The arithmetic operators, such as addition (+), subtraction (-), multiplication (*), and division (/)
along with the modulus (%) operator are given equal weightage and are executed from left to
right.
Arithmetic operators (+, -, *, /): These are the basic operators that you must be familiar
with.
Modulus operator (%): This operator returns the remainder after dividing the first
number with the second. For example,
trace(0 % 3); // Statement 1
trace(5 % 3); // Statement 2
In the above syntax, Statement 1 will display 0 and Statement 2 will display 2.
Increment (++) and decrement ( ) operators: These operators can be used to add or
subtract 1 from a number. As these are unary operators, they require only one argument.
For example,
var x:Number = 5;
x++; // 6
x--; // 5
When the increment or decrement operator is placed before the operand, then 1 is added
immediately before the other variables are processed.
Compound Assignment operators (+=, -=, *=, /=, and %=): These operators can be used to
perform arithmetic on numbers and reassign the answer to the variable on the left. For
example,
x += 1;
In the above syntax, += will add 1 to x and reassign the value to the variable x. Thus, this is
similar to,
x = x + 1;
For detailed step-by-step procedure, refer demo Basic Programming Concepts from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
1.4.3 Functions
A function is a piece of code that has been stored and can be called by writing the function name in
the code. Every program written will rely on functions.
It is more important to understand difference between methods and functions. They are commonly
used to describe a reusable block of code. A method is any function defined within a class. Methods
are associated with the instance of the class and tend to act in conjunction with the object in which
they are defined.
For example, a Kitty class might define a function called meow(). Now, meow() would be a method
of the Kitty class. The term method is a distinction in name only. Thus, it does not have any
additional abilities and there is no method keyword.
The syntax to call a function is:
addElementToGroup(myGroup, myElement);
Now, if the same function had to be called on an object instance then the syntax would be:
myGroup.addElement(myElement);
As you can see, the syntaxes are similar, but the latter is designed to act on the myGroup object
instance.
In ActionScript, both terms are used. Function is used for general usage, but when describing
functionality specific to a function defined within a class, the term method is used. Because almost
all functions in ActionScript are stored within classes and most of them are methods.
Calling a Function
A code being executed within a function or method is called calling or invoking. In
ActionScript, a function is called using the functions name followed by a pair of parentheses
(), which is known as the call operator. Within the parentheses, you can pass additional
functions by adding arguments or parameters. Some functions will have optional or required
arguments. The number and type of values passed should match the function definition, also
called a method signature. Other functions require no arguments and are called by using an
empty pair of parentheses.
The syntax of two valid functions are,
trace(Hello!);
addChild(mySprite);
Load and control external SWF files, including files created for previous Flash Player versions
Build an ActionScript system for creating graphical assets to be loaded and used at run time.
MovieClip()
To create a new movie clip instance, MovieClip() public method can be used. Once the
movie clip is created, call the addChild() or addChild At() method of a display object
container. The syntax to create a new movie clip is,
public function MovieClip()
gotoAndPlay()
To play a SWF file from a specified frame, gotoAndPlay() public method can be used.
However, the frame will be played only when all the actions in that frame are executed. You
can also specify a particular scene you want to play in the frame by specifying a value for the
scene parameter. The syntax for the same is,
public function gotoAndPlay(frame:Object, scene:String = null):void
gotoAndStop()
In a movie clip, to bring the playhead to a specific frame and to stop it at that frame,
gotoAndStop() public methods can be used. However, this method will be executed only
after execution of all the remaining actions in the frame. In this method, you can also specify a
scene parameter. The syntax to bring the playhead to a specific frame and stop it on that
frame is,
public function gotoAndStop(frame:Object, scene:String = null):void
nextFrame()
To send the playhead to the next frame and stop there, nextFrame() public method can be
used. However, this method will be executed only after execution of all the remaining actions
in the frame. The syntax for the same is,
public function nextFrame():void
nextScene()
To move the playhead to the next scene in the movie clip, nextScene() public method can
be used. However, this method also will be executed only after execution of all the remaining
actions in the frame. The syntax for the same is,
public function nextScene():void
play()
To move the playhead in the Timeline of the movie clip, play() public method can be used.
The syntax for the same is,
stop()
To stop the playhead in the movie clip, stop() public method can be used. The syntax for
the same is,
public function stop():void
prevFrame()
To move the playhead to a previous frame and stop it there, prevFrame() public method
can be used. This method too will be executed only after all the actions in the frame are
executed. The syntax for the same is,
public function prevFrame():void
prevScene()
To move the playhead to a previous scene of the movie clip, prevScene() public method
can be used. This method too will be executed only after all the actions in the frame are
executed. The syntax for the same is,
public function prevScene():void
/*This function will be called when the button is clicked. It causes the oval
animation to play.*/
oval.stop();
function stopAnimation(event:MouseEvent):void {
oval.play();
}
function increaseSize(Event:MouseEvent) {
var sWidth = oval.width;
var sHeight = oval.height;
sWidth++;
sHeight++;
oval.width = sWidth;
oval.height =sHeight ;
}
function decreaseSize(Event:MouseEvent) {
var sWidth = oval.width;
var sHeight = oval.height;
sWidth--;
sHeight--;
oval.width = sWidth;
oval.height =sHeight ;
}
/*Register the function as a listener with the button. Handling events are better
explained in next section.*/
startButton.addEventListener(MouseEvent.CLICK, stopAnimation);
small_btn.addEventListener(MouseEvent.CLICK,decreaseSize);
large_btn.addEventListener(MouseEvent.CLICK,increaseSize);
For detailed step-by-step procedure, refer demo Controlling Movie Clips from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
The Event Listener is specified by declaring the function the same way like any other function is
declared in ActionScript. The only difference is that the listener function will have one argument to
represent the event. This event argument can have any identifier as its name.
myObject.addEventListener(Event, eventListenerFunction);
function eventListenerFunction (e:Event):void {
//ActionScript statements to be executed when the event happens.
}
In case, a graphical object is to be placed on Stage to act like a button, you can register an event as
an Event Listener as in the code.
myButton.addEventListener(MouseEvent.CLICK, myClickReaction);
function myClickReaction (e:MouseEvent):void {
trace("I was clicked!");
}
click: This event occurs when the mouse button is pressed and released over the interactive
display object.
doubleClick: This event occurs when the mouse button is pressed and released twice in a
rapid succession over the interactive display object.
mouseDown: This event occurs when the mouse button is pressed over the interactive
display object.
mouseUp: This event occurs when the mouse button is released over the interactive display
object.
mouseOver: This event occurs when the mouse pointer is moved over the interactive display
object.
mouseMove: This event occurs when the mouse pointer is moved within the interactive
display object.
mouseOut: This event occurs when the mouse pointer is moved outside the interactive
display objects.
mouseWheel: This event occurs when the mouse wheel is rotated while the mouse pointer is
over the interactive display object.
These events can be used by calling addEventListener() on the interactive object and defining
an event handler to handle the MouseEvent passed to it.
Data types
Arrays
Strings
2. To control movie clips using ActionScript, you need to use the _______________
class.
MovieClip
Variable
Method
Function
False
of text. If a particular data type is assigned to a variable, then that variable can hold a value within that
data type's set of values. Some of the simple data types used in ActionScript are String, Numeric, and
Boolean.
While debugging a script, it is necessary to determine the data type of an expression or variable. This
can be done with the instanceof and typeof operators.
1.7.1 Boolean
Boolean values are usually used while working with logical operators. In ActionScript, boolean values
can be used in statements that make comparisons to control the flow of a script. The output of a
boolean value is either true or false. ActionScript converts the true value to 1 and false value to 0.
Number
The Number type is an IEEE 754 double-precision 64-bit floating-point number. It can
represent positive and negative numbers both whole and fractional. Number type can be used
for almost any type of measurement. The default value for an unassigned variable of type
Number is NaN. Usually Numbers are assigned by setting them equal to a numeric literal, but
the Number class also has a constructor, which will attempt to convert the object passed into
a number, and assign it to the new number. For example,
var n:Number;
trace(n); // NaN
n = 12;
trace(n); // 12
int
The int type is a signed 32-bit integer. It is a class and has a constructor like Number that is
rarely used. An int can be created by typing a number literal. If a non-whole number is
assigned to an int variable, then the fractional part of the number will be dropped. The
default value for an unassigned int value is 0. The int type is perfect for counters and is
frequently found in for loops. For example,
for (var i:int = 0; i < 1000; i++)
uint
The uint type is an unsigned 32-bit integer. It is a new data type introduced in ActionScript
3.0 and this too is a class and has a rarely used constructor. unit is similar to int except in
its range of values. Like int, its default value is also 0.
1.7.3 Array
Like numbered list, arrays are a type of ordered set of data. Array type can be used to store any
number of individual pieces of data in a single variable. The Array class also provides methods and
properties. In ActionScript, there are two types of arrays, integer-indexed and associative. Both these
types of array group related data, but use different means of accessing the data.
1.7.4 Object
The Object data type is the base class for all class definitions in ActionScript. It is defined by the
Object class. In ActionScript 3.0, Object data type is not the default data type assigned to variables
with no type annotation.
Occasionally, you may need to store a value in a variable without knowing what type of data it will
hold. For this, ActionScript 3.0 allows you to use wildcard (*) data type. The * denotes that the data
type is unknown until runtime (dynamic) or will accept more than one type of data (example, both
strings and numbers). The wildcard is very useful when creating functions that behave differently
depending on the data type of its parameters.
In ActionScript 3.0, the default value assigned to Object instances is null. Only the untyped variables
can be assigned undefined values. This undefined value is then converted by the Flash Player to the
default value of the particular data type it was assigned to. For example, if you assign an undefined
value to an Object instance, the Flash Player converts it to null, which is the default value of the
Object data type.
Note
ActionScript 3.0 considers the variables with no type annotation as untyped.
1.7.5 String
The fundamental textual element of the ActionScript language is known as strings. Strings are
enclosed in single or double quotes depending upon the number of characters. In ActionScript, single
characters and strings are grouped into String data type and thus are not differentiated.
var exampleA:String = ""; // Empty string
var exampleB:String = "x"; // Single character
var exampleF:String; // Defaults to null when no value is assigned
1.8 Array
The functionality of an array is to store multiple values in a single data structure. The integer-indexed
array stores values using fixed ordinal integer indexes and is simple. The associative array stores
values using arbitrary keys and is complex. You can use any of these types. Arrays can also be multidimensional.
An array provides a way of grouping related data together and then organizing and processing that
data. Arrays can be created in multiple ways.
To create an array with the size defined as 10, the syntax is,
var arrayExample:Array = new Array(10);
To create an array with predefined values stored at the declaration Stage itself, the syntax is,
var arrayExample:Array = new Array("Apple","orange","grapes");
ArrayUtilities.findMatchIndex()
ArrayUtilities.findLastMatchIndex()
ArrayUtilities.findMatchIndices()
While searching for the first matching element, the importance of the break statement is twofold. It
saves the processing time.
In the following example, the break statement exits the loop after the second iteration. Also, the
break statement is vital when searching for the first match because it ensures that only the first
element is matched and that subsequent matches are ignored. If the break statement is omitted in
the following example, all matching elements are displayed.
1.9 String
A string in Flash can be a piece of textual data from a letter to a word or several paragraphs. Strings
can also contain numbers or non-letter characters. For example, phone number or email id. In
ActionScript 3.0, several methods are available that can be used to manipulate, search, or convert
strings.
In the following example, the string starts with a double quote ("Yes); therefore, the double quote
character before the Y signals the end of the string to the compiler. Thus, the compiler does not
understand what to do with the remaining characters,
var error:String = "He said, "Yes.""; // Incorrect.
Thus, the solution is to use single quotes to enclose a string literal that contains double quotes, or
double quotes to enclose a string literal that contains single quotes. For example,
var exampleA:String = 'He said, "Yes."';
// This assignment works. The result is: He said, "Yes."
var exampleB:String = "He said, 'Yes.'";
// This assignment also works. The result is: He said, 'Yes.'
Whitespace character
Escape sequence
New line
\n
Tab
\t
Backspace
\b
Form feed
\f
Carriage return
\r
ActionScript 3.0 does not include support for the new line constant. If your code uses new line
anywhere, then replace it with the \\n escape sequence. The result will be the same. For example,
// Generates a compile error replace newline with "\n" to compile
// Compile error: "Access of undefined property 'newline'"
var error:String = "two" + newline + "lines";
Within Flash, the new line, form feed, and carriage return characters all result in the same display.
However, when you load content into Flash from external sources, some values will have new line
characters, some will have form feeds, and some will have carriage returns.
Using toString()
The following syntax displays the current date using an instance of the Date class.
Objects
Boolean values
Strings
Abstract
Matrix
Associative
False
1.10 Summary
In this session, Introduction to ActionScript 3.0 and Programming Concept, you learned that:
ActionScript can be added to your application by using the Actions panel, Script window, or
any other external editor.
A computer program is a series of instructions and steps that are executed using a computer.
The Actions panel allows you to create and edit ActionScript code for an object or a frame.
Movie Explorer is a panel that displays all the items of the movie, as well as the movie
structure.
The trace() statement is used to send specific information to the Output panel.
Operators are built-in function like commands that operate on one or more values.
A function is a piece of code that has been stored and can be called by writing the function
name in the code.
Every Flash document contains a Stage, which consists of text, visual elements, and a main
Timeline.
A movie clip can be controlled across its Timeline using the play() and stop() methods.
Any interaction happening within the Flash environment is known as ActioScript Event.
Data types are used to create variables, object instances, and function definitions in the
programs.
Array type can be used to store any number of individual pieces of data in a single variable.
In ActionScript 3.0, you can search an array for an value using the indexOf() and
lastIndexOf() methods.
A string in Flash can be a piece of textual data from a letter to a word or several paragraphs.
In ActionScript 3.0, you can add whitespace characters, such as tab or new line, with escape
sequence to a string.
1.11 Exercise
1. Using the__________________, you can swap quickly between the scripts in a Flash
document.
Actions Toolbox
Script Navigator
Script Pane
Movie Explorer
2. ______________ are built-in function-like commands that operate on one or more values.
Operators
Variables
Arrays
Functions
3. Each movie clip has its own Timeline and can in turn include other movie clips.
True
False
4. The _____________ method can be used to move the playhead to the next scene in the
movie clip.
nextFrame()
gotoAndStop()
gotoAndPlay()
nextScene()
5. The prevScene() public method can be used to move the playhead to a previous scene of the
movieclip.
True
False
6. The ________________ event occurs when the mouse pointer is moved within the interactive
display object.
mouseOver
mouseOut
mouseMove
mouseWheel
Se ssi on 2
In the previous session, you learned about the programming fundamentals and the basic
programming concept. You also became familiar with the different data types. In this session, you will
learn about the various built-in classes and become familiar with the conditional and loop statements.
You will also be able to work with movie clips and text fields. You will learn to make use of date and
time as per your requirements and also be able to load external files.
if Statement
This is the commonly used statement. An if statement allows you to execute a piece of code
only if a certain condition is met.
trace("that is correct");
}
Note
The brackets {} are optional for statements with only one line. But, for consistency, always
make use of the brackets.
else Statement
If the if condition is false, then the else clause can be used in order to perform alternative
actions. But for the trace() command to have any effect, the SWF file must be compiled
using the Debug, and not Run mode. Call the method named showMessage(). It displays an
appropriate message depending on whether the user got the answer right or wrong.
Note
In place of double quotation mark, single quotation marks can be used.
Switch Case
To test a single expression against several possible conditions, you can use the switch
statement. This statement uses more than one if-else clauses. Instead of testing a
condition for a Boolean value, the switch statement evaluates an expression and uses the
result to determine which block of code to execute. Blocks of code begin with a case
statement and end with a break statement. The break statement tells the conditional
statement or loop to cancel the rest of its operation without going any further.
case "Green":
trace("the color added is green");
break;
default:
trace("there is no color added");
break;
}
For detailed step-by-step procedure, refer demo Using Conditional Statements from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
2.1.2 Loops
Loops can be used when you need to count through a set of data. This control structure performs the
same task multiple times within a single frame. For example,
for (var i:int = 0; i < 10; i++) {
// Display the value of i
trace(i);
}
With the help of the loops, you can perform operations that are difficult to perform manually. The
various loops available are:
for Loop
This is the most common looping structure. Example,
while Loop
This is a basic type of looping. This can be used when you want to meet a particular condition.
For example,
In the above syntax, the action will continue till the condition is true. The while statement can
be used to loop a variable until it reaches a certain value. For example,
var sum:Number = 0;
while (sum < 100) {
trace(sum + " - not there
var randomNumber:Number =
// create a random number
sum += randomNumber;
}
trace(sum + "- surpassed 100.
yet.");
Math.ceil(Math.random() * 10);
between 0 and 10
END");
In the above syntax, the loop adds random numbers together until the result surpasses 100.
do while Loop
In this type of looping, the condition is checked after the loop is complete instead of checking
before. So at least one iteration takes place. For example,
Call the Loader objects load() method by passing the URLRequest instance as a
parameter.
Call the addChild() method on a display object container to add the Loader instance to
the display list.
For example, a dummy.swf file uses the same technique of calling the load() method on a Loader
instance and passing a URL to a .swf instead of an image, the .swf is loaded into the movie.
var request:URLRequest = new URLRequest("dummy.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
You can access an SWF file once it is successfully loaded. It can be accessed through the
Loader.content property. If the external SWF file is published for ActionScript 3.0, it will be either a
movie clip or a sprite, depending on which class it extends.
To delete a movie clip, the removeChild() method can be used. If a duplicate movie clip is deleted,
then the parent movie clip is deleted.
The selection works only if the text field has focus. The syntax to set focus is:
Replacing Text
To replace the selected text in a text field, use the replaceSelectedText() method. To
replace a range of text, the replaceText() method can be used. This method replaces the
text within a text string. You need to mention the start and end index of text. Syntax for both
these methods are as follows:
field.ReplaceSelectedText("new text");
field.replaceText(100, 150, "new text");
The replaceText() method replaces text from index 100 to index 150, with the new string
specified by the third parameter.
This syntax allows the user to enter any of the allowable characters, that is, a, b, c, d, e, f, g, h, I
and j. Other characters are restricted. If the user tries to enter grabs, only gab appears, since the
letters r and s are not in the allowable character set.
Using a StyleSheet object and applying it to the text field's styleSheet property
However, the color of the entire content can be set using the textColor property.
Applying HTML formatting is relatively simple, but it is often difficult to manage different techniques.
Using TextFormat object is complex than formatting via HTML. However, when formatting via
HTML, often it is difficult to manage different techniques. Using CSS with a StyleSheet object
allows you to load a CSS document, which makes it simple to maintain. Thus, you can edit the CSS
document without having to re-export the SWF file.
For quick and simple formatting, HTML tags can be used. For example, the following code displays
bold and underlined text.
field.HTML = true;
field.htmlText = "<b>Bold text</b> <u>Underlined text</u>";
if
elseif
ifthenelse
2. Loops perform the same task multiple times within a single frame.
True
False
day: Specifies the day of the week as an integer from 0 (Sunday) to 6 (Saturday).
hours: Returns the hours value as an integer from 0 (midnight) to 23 (11 p.m.).
Each of these properties have a Coordinated Universal Time (UTC), also known as Greenwich Mean
Time (GMT) correspondent. For example, although the hours property returns the current hours value
based on the client computer's clock, the hoursUTC property returns the current hours value in UTC
time.
the same domain can write to and read from the .sol files by means of ActionScript's
flash.net.SharedObject class.
All the .sol files created are stored in an application data directory for the Flash Player. It is the
standard location for the storage.
The local shared objects are created and opened for reading using the static getLocal() method.
This method requires one parameter, that is, a string that specifies the name of the shared object. For
example,
var example:SharedObject = SharedObject.getLocal("example");
The getLocal() method first tries to locate an existing local shared object by the specified name
with a .sol extension stored on the client computer. If none is found, the Flash Player creates a new
local shared object with that name. In either case, the existing or new local shared object is opened.
event lets you know when the image is loaded. The below shown is an example to create the
loaderlisten for the complete event and begin loading an image.
import flash.display.Sprite;
import flash.display.Loader;
import flash.events.Event;
// For image loading.......
var sLoader:Loader = new Loader();
sLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
sLoader.load(new URLRequest("Sunset.jpg"));
function onLoadingComplete(event:Event):void {
var myImage:Bitmap = Bitmap(sLoader.content);
addChild(myImage);
}
Before publishing the file to see the result, ensure that an image is placed in the root folder. You can
now see that bitmap is loaded in the SWF file.
Similarly, you can load the text file by using the below given script.
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.net.*;
var dataLoader:URLLoader = new URLLoader();
var display_txt:TextField = new TextField();
display_txt.width = stage.stageWidth;
display_txt.height = stage.stageHeight;
addChild(display_txt);
dataLoader.addEventListener(Event.COMPLETE, displayData);
dataLoader.load(new URLRequest("author.html"));
function displayData(event:Event) {
display_txt.htmlText = dataLoader.data;
}
For detailed step-by-step procedure, refer demo Loading External Files from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
date()
day()
systemdatetime()
False
modifyimage()
Callbitmap()
flash.display.loader
2.7 Summary
In this session, Working with Built-in Classes, you learned that:
Conditional statements can be used while making logical decisions for a given situation.
An if statement allows you to execute a piece of code only if a certain condition is met.
If the if condition is false, then the else clause can be used in order to perform alternative
actions.
The switch statement can be used to test a single expression against several possible
conditions.
Loops can be used when you need to count through a set of data.
The while statement can be used to loop a variable until it reaches a certain value.
In do while loop, the condition is checked after the loop is complete instead of checking
before.
To load an external SWF file, the new Loader class can be used.
In ActionScript 3.0, the addChild() method can be used to duplicate the movie.
The flash.text.TextField class is the way in which all text is displayed in Flash Player.
A limited subset of HTML is supported by Flash that can be displayed in the text field.
To replace the selected text in a text field, use the replaceSelectedText() method.
The Date object can be used in order to retrieve the year, month, day of the month, day of
the week, hour, minute, second, or millisecond value.
Shared objects can be used to personalize programs, retain preferences, and improve
experience.
The SharedObject.flush() method can be used to save data in a local shared object to
the client computer.
2.8 Exercise
1. To display an appropriate message depending on whether the user got the answer right or
wrong, you should call the ______________ method.
trace()
showMessage()
displayMessage()
load()
2. To delete a movie clip, ________________ method can be used.
removeChild()
eraseChild()
deleteChild()
duplicateMovieClip()
3. The text components, such as TextArea and TextInput, use the TextField class to display text.
True
False
4. By default, the autoSize property is set to ______________.
CENTER
RIGHT
LEFT
NONE
5. The BeginIndex and EndIndex properties can be used to retrieve the indices of the selected
character range.
True
False
6. The ____________ property specifies the year as a four-digit value, such as 2010.
date
month
fullYear
year
7. The ____________________ method can be used to save data in a local shared object to the
client computer.
SharedObject.flush()
SharedObject.clear()
flash.display()
getLocal()
Se ssi on 3
Define a class
Define a package
Write a class
Set classpath
Describe encapsulation
Describe polymorphism
In the previous session, you learned about the conditions and loop statements. You also learned to
work with movie clips, and text fields. In this session, you will learn about object-oriented concept,
classes, and packages. You will learn to create static methods and properties. You will also become
familiar with terms, such as polymorphism and
encapsulation. In Flash, the MovieClip class
happens to be one of the key classes. You will learn to extend this class.
Defining classes
Creating properties, methods, and get and set accessors (accessor methods)
While working with classes, packages are an important part as they allow you to ensure that your
classes do not conflict with any other classes.
For detailed step-by-step procedure, refer demo Classes and Packages from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
Math Class
This class defines a round() method. The round() method is static and is, therefore,
accessible directly from the class. For example,
trace(Math.round(1.2345));
The Math class consists entirely of static methods and constants. However, a class can have
both static and instance methods.
String Class
This class consists primarily of instance properties and methods. As the method is not associated
with any one string instance, it does not make sense to make the method an instance method.
However, it declares the method as a static method.
You can use the static attribute to declare a property or method as static. The static attribute is
always used in combination with the public, private, protected, or internal attribute. For example,
the following declares a private static property called _example.
static private var _example:String;
Singleton design pattern is one of the important uses of static properties and methods. Single design
pattern means a class having a private static property with single managed instance and public static
method that allows access to the instance.
While creating an object instance, use a new operator with the class name. For example,
var myCar:MovieClip = new MovieClip();
var birthday:Date = new Date(2006, 7, 9);
When an object is created using a new operator, it is called a constructor. The constructor is the part
of a process of creating an instance of a class. When an instance is created in this way, put
parentheses after the class name. The new operator can also be used to create an instance of a
movie clip symbol that is defined in the Library, but is not placed on the Stage.
PHP
CGI
Object-oriented programming
False
String
Math
Var
At the global level, in the Edit menu, click Preferences. The Preferences dialog box will be
displayed. Now, click the ActionScript Settings button. The ActionScript 3.0 Settings dialog box,
as shown in Figure 3.2, will be displayed.
package org.examplelibrary.collection {
public class LibraryItem {
protected var _ddc:String;
protected var _id:String;
protected var _name:String;
public function LibraryItem() {}
public function setDdc(value:String):void {
_ddc = value;
}
public function getDdc():String {
return _ddc;
}
public function setId(value:String):void {
_id = value;
}
public function getId():String {
return _id;
}
public function setName(value:String):void {
_name = value;
}
public function getName():String {
return _name;
}
}
}
Thus, you can say that books and DVDs are both types of LibraryItem.
subclasses to inherit and redefine, or override, methods from the base class. In the following example,
the area() method is redefined by the Circle and Square classes.
class Shape {
public function area():Number {
return NaN;
}
}
class Circle extends Shape {
private var radius:Number = 1;
override public function area():Number {
return (Math.PI * (radius * radius));
}
}
class Square extends Shape {
private var side:Number = 1;
override public function area():Number {
return (side * side);
}
}
var cir:Circle = new Circle();
trace(cir.area()); // output: 3.141592653589793
var sq:Square = new Square();
trace(sq.area()); // output: 1
As each class defines a data type, the use of inheritance creates a special relationship between a
base class and a class that extends it. A subclass is guaranteed to possess all the properties of its
base class, which means that an instance of a subclass can always be substituted for an instance of
the base class. For example, if a method defines a parameter of type Shape, it is legal to pass an
argument of type Circle because Circle extends Shape, as follows,
function draw(shapeToDraw:Shape) {}
var myCircle:Circle = new Circle();
draw(myCircle);
For detailed step-by-step procedure, from Encapsulation and Polymorphism:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
visible objects in the SWF movie. Any object not available in the display list is not drawn by the
renderer. Each SWF movie contains exactly one display list.
The display list consists of three types of elements.
Stage
A single stage object is available in every movie. This stage contains an entire object hierarchy of
everything displayed on the screen. A stage is a container containing the main application class of
the SWF movie and a single child. The stage can be accessed by referring to the stage property
on any display object in the display list.
Display Objects
A display object is a visual element that appears on screen only after it is added into a display
object container. Some classes function as both, display objects and display object containers,
such as MovieClip, while other classes are only display objects, such as a TextField.
Math, Var
Function, String
False
Method
Function
Variable
3.11 Summary
In this session, Object-Oriented Programming with ActionScript 3.0, you learned that:
Using an object-oriented approach to organize a program, you can group particular pieces of
information having common functionality.
A package is a directory that contains one or more class files and it resides in a designated
classpath directory.
A class is a blueprint for an object. It defines the object in full, that is, the data and its
operations.
The class file should be saved in a directory path corresponding to the package.
For Flash, the classpath can be edited either at the project level or globally.
To create a class that inherits from an existing class, write a subclass using the extends
keyword.
The display list consists of three types of elements. They are stage, display object containers,
and display objects.
3.12 Exercise
1. A _____________ is a way of organizing classes into groups.
class
project
package
program
2. The ______________ class consists entirely of static methods and constants.
Math
String
Super
Sub
3. The default Classpath for any Flash project includes the project directory.
True
False
4. A ______________ is a container containing the main application class of the SWF movie
and a single child.
package
display objects
display object containers
stage
5. Creating classes that extend MovieClip can be a very powerful and useful resource.
True
False
Se ssi on 4
Components
Learning Outcomes
In this session, you will learn to:
In the previous session, you learned about object-oriented concept, classes, and packages. You
also learned to create properties, methods, and object instances. You became familiar with
polymorphism and encapsulation. You also learned to extend the MovieClip class. In this
session, you will learn to capture keyboard inputs. You will also learn to control the mouse actions
and become familiar with the user interface components.
display_txt.border = true;
display_txt.type = "input";
display_txt.addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);
display_txt.addEventListener(KeyboardEvent.KEY_UP,reportKeyUp);
function reportKeyDown(event:KeyboardEvent):void {
trace("Key Pressed: " + String.fromCharCode(event.charCode) + " (key code: " +
event.keyCode + " character code: " + event.charCode + ")");
if (event.keyCode == Keyboard.SHIFT) {
display_txt.borderColor = 0xFF0000;
}
}
function reportKeyUp(event:KeyboardEvent):void {
trace("Key Released: " + String.fromCharCode(event.charCode) + " (key code: "
+ event.keyCode + " character code: " + event.charCode + ")");
if (event.keyCode == Keyboard.SHIFT) {
display_txt.borderColor = 0x000000;
}
}
For detailed step-by-step procedure, refer demo Capturing User Inputs from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
Mouse.show();
}
show_btn.addEventListener(MouseEvent.CLICK, showMouse);
On publishing the file you can see that the cursor disappears when clicked on the hide button and
becomes visible when the show button is clicked.
Button
List
TextArea
CheckBox
NumericStepper
TextInput
ColorPicker
RadioButton
TileList
ComboBox
ProgressBar
UILoader
DataGrid
ScrollPane
UIScrollBar
Label
Slider
Buttons
For any Web applications or forms, button is a basic requirement. To add button to a new
Flash file ActionScript 3.0 document, drag the Button component from the Components
panel to the current document's Library panel. Then, open the Actions panel, select Frame
1 in the main Timeline and enter the following code to create a button instance:
import fl.controls.Button;
var myButton:Button = new Button();
addChild(myButton);
myButton.label = "Submit Form";
myButton.toggle = true;
myButton.move(50, 50);
Next, add the following ActionScript to create an event listener and an event handler function.
myButton.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void {
trace("Event type: " + event.type);
}
Now, you can check if the button functions properly by clicking the Control menu and selecting
Test Movie.
CheckBox
A CheckBox component is a square box that can be selected or cleared. It is mostly used to
check user response or while creating assessments. When it is selected a check mark
appears in the box. You can add a text label to the CheckBox component and place it to the
right, left, above, or below it. For example, drag four CheckBox components from the
Components panel to the Stage. Then, in the Property Inspector, enter the instance names
as box_01, box_02, box_03, and box_04. Now, enter the options name in the label
parameter and place a Submit button on Stage to validate the option with an instance name
as submit_btn. Create an empty dynamic text field with an instance name as display_txt.
Then, in the Actions panel, select Frame 1 in the main Timeline, and enter the following
ActionScript code:
Now, on the Control menu, click Test Movie. You can see that a simple check box assessment
is created.
ComboBox
This component allows the user to make a single selection from the drop-down list. To add a
combo box to a new Flash file, drag the ComboBox component to the Stage and give it an
instance name as comb_01.
On the Parameters tab, with the ComboBox component selected on the Stage, click the
DataProvider cell. Then, click the magnifying glass icon. The Values dialog box, as shown in
Figure 4.3, will be displayed.
function disableAll() {
comb_01.enabled = false;
submit_btn.enabled = false;
}
RadioButton
This component can be used when the user has to make a single choice within a set of
choices. It should be used in a group of at least two RadioButton instances. A radio button
is a fundamental part of many form applications on the Web.
To add radio buttons in a new Flash file, drag three RadioButton components from the
Components panel to the Stage and enter the instance names as box_01, box_02, and
box_03. Now, place a Submit button on Stage to validate the option with an instance name
as submit_btn. Create an empty dynamic text field with an instance name as display_txt.
Then, open the Actions panel, select Frame 1 in the main Timeline, and enter the following
code:
var UserOption:String;
var correctAnswer:String = "Three";
box_01.addEventListener(MouseEvent.CLICK,fnUpdateArray);
box_02.addEventListener(MouseEvent.CLICK,fnUpdateArray);
box_03.addEventListener(MouseEvent.CLICK,fnUpdateArray);
submit_btn.addEventListener(MouseEvent.CLICK,quizValidate);
function fnUpdateArray(e:MouseEvent) {
if (e.target.selected == true) {
UserOption =e.target.label;
}
}
function quizValidate(event:MouseEvent) {
if (UserOption == correctAnswer) {
display_txt.htmlText = "<b> That's Correct.</b>";
} else {
display_txt.htmlText = "<b> That's Incorrect. The correct answer is
Three.</b>";
}
disableAll();
}
function disableAll() {
box_01.enabled = false;
box_02.enabled = false;
box_03.enabled = false;
submit_btn.enabled = false;
}
You can see that a radio button assessment is created.
ScrollPane
This component can be used to display content that is too large for the area into which it is
loaded. For example, if you have a large image and only a small space for it in an application,
you could load it into a scroll pane.
To add scroll pane to a new Flash file, drag the ScrollPane component from the
Components panel to the Stage and give it an instance name as myScrollPane. Then, open
the Actions panel, select Frame 1 in the main Timeline, and enter the following ActionScript
code. Ensure that the image called in the scroll pane is placed in the given folder.
import fl.events.ScrollEvent;
myScrollPane.setSize(300, 200);
function scrollListener(event:ScrollEvent):void {
trace("horizontalScPosition: " + myScrollPane.horizontalScrollPosition + ",
verticalScrollPosition = " + myScrollPane.verticalScrollPosition);
};
myScrollPane.addEventListener(ScrollEvent.SCROLL, scrollListener);
function completeListener(event:Event):void {
trace(event.target.source + " has completed loading.");
};
// Add listener
myScrollPane.addEventListener(Event.COMPLETE, completeListener);
myScrollPane.source = " images/image1.jpg";
Now, on the Control menu, click Test Movie to run the application.
For detailed step-by-step procedure, refer demo Components from:
eResources 4 Me>> My Varsity>> Basic Scripting and Interactivity>> Show Me How
FLVPlayback
This component allows you to include a video player in the Flash CS3 Professional
application. It plays progressively downloaded Adobe Flash Video (FLV) files over HTTP or
play streaming FLV files from Adobe's Macromedia Flash Media Server.
To add this component, in the Components panel, click the plus (+) button to open the video
entry and drag the FLVPlayback component to the Stage. With the FLVPlayback component
selected on the Stage, locate the Value cell for the source parameter on the Parameters tab
of the Component Inspector, and enter a string that specifies one of the following:
Now, on the Parameters tab, with the FLVPlayback component selected on the Stage, click
the Value cell for the Skin parameter. Click the Magnifying Glass icon. The Select Skin
dialog box, will be displayed. Refer to Figure 4.4.
Select one of the pre-designed skins to attach a set of playback controls to the component.
Select Custom Skin URL from the pop-up menu if you have created a custom skin. Next,
enter the URL for the SWF file that contains the skin in the URL box.
Select None and drag individual FLV Playback Custom UI components to the Stage to add
playback controls.
Next, click OK to close the Select Skin dialog box. To execute the SWF file and start the video,
on the Control menu, click Test Movie.
In the Content Path dialog box, click the icon folder to browse the exact location.
The Match source FLV dimensions option specifies whether the FLVPlayback instance on
the Stage should match the dimensions of the source FLV file.
The Download FLV for cue points and dimensions check box is enabled only if the
content path is HTTP or RTMP URL, which means the FLV file is not local. This option
specifies whether to download or stream a portion of the FLV file to acquire the FLV file
dimensions and any cue point definitions that are embedded within it. Flash uses the
dimensions to resize the FLVPlayback instance, and it loads the cue point definitions into the
cuePoints parameter in the Component Inspector.
For each instance of the FLVPlayback component, you can set the following parameters in
the Parameters tab. Refer to Figure 4.6.
align: Specifies the video layout when the scaleMode property is set to
VideoScaleMode.MAINTAIN_ASPECT_RATIO. The video dimensions are based on the
registrationX, registrationY, registrationWidth, and registrationHeight properties.
When you set the align property, values come from the VideoAlign class. The default is
VideoAlign.CENTER.
autoPlay: Specifies a boolean value that determines how to play the FLV file. If true, the
component plays the FLV file immediately when it is loaded. If false, the component
loads the first frame and pauses.
cuePoints: Specifies an array that describes ActionScript cue points and disabled
embedded FLV file cue points. This property is created specifically for use by the
Component Inspector and Property Inspector. It does not work if it is set in any other
way. Its value has an effect only on the first FLV file loaded and only if it is loaded by
setting the source property in the Component Inspector or Property Inspector.
scaleMode: Specifies how the video will resize after loading. If set to
VideoScaleMode.MAINTAIN_ASPECT_RATIO, the video aspect ratio within the
rectangle defined by registrationX, registrationY, registrationWidth, and
registrationHeight is maintained.
Skin: Specifies the URL to a skin SWF file. It is a string that contains a file name, a
relative path, such as Custom_Skin.swf, or an absolute URL.
skinAutoHide: It is a boolean value that, if true, hides the component skin when the
mouse is not over the video. This property affects only skins that are loaded by setting the
skin property and not a skin that you create from the FLVPlayback Custom UI
components. When the component is in full-screen takeover mode and the skin is one
that does not lay over the video, then skinAutoHide mode is turned on automatically. If
the property is set to false after entering full-screen mode then it overrides the behavior.
skinBackgroundAlpha: This property works only with SWF files that have skins loaded
by using the skin property and with skins that support setting the color and alpha. You
can set this property to a number between 0.0 and 1.0. The default is .85.
skinBackgroundColor: This property works only with SWF files that have skins loaded
in the components. The skin property contains different settings. The default is the last
value chosen by the user as the default.
Source: Specifies the URL of the FLV file that has to be streamed. The URL could be
HTTP URL to an FLV file, RTMP URL to a stream, or HTTP URL to an XML file.
If this property is set through the Property Inspector, then the FLV file begins loading
and playing at the next "enterFrame" event. The delay provides time to set the isLive,
autoPlay, and cuePoints properties, among others, which affect loading. It also allows
ActionScript that is placed on the first frame to affect the FLVPlayback component before
it starts playing.
If this property is set through ActionScript, then it immediately calls the
VideoPlayer.load() method when the autoPlay property is set to false; else, it calls
the VideoPlayer.play() method. The autoPlay, totalTime, and isLive properties
affect how the new FLV file is loaded, so if you set these properties, you must set them
before setting the source property.
Set the autoPlay property to false to prevent the new FLV file from playing automatically.
Volume: Specifies a number in the range of 0 to 1 indicating the volume control settings.
keyCode
charEvent
keyDown
Mouse call
Mouse hold
ActionScript
False
4.4 Summary
In this session, Components, you learned that:
The ability to react in response to a keyboard action is known as capturing user inputs.
When a user clicks the mouse button, moves the mouse, or scrolls the mouse over an object,
Flash player sends a mouse event to all listeners.
The custom cursor can be made and replaced with default course graphic. This can be
attained with the help of hide() and show() methods.
To create a custom pointer, you can design your own customize pointer movie clip on the
Stage.
To hide the standard pointer, use the hide() method from the built-in Mouse class.
You can begin building user interface components by using the Sprite class as the display
object.
Using components you can quickly and easily build a robust Flash application with consistent
behavior and appearance.
Each component has a unique set of ActionScript methods, properties, and events that make
up its application programming interface.
The ComboBox component allows the user to make a single selection from the drop-down list.
The RadioButton component can be used when the user has to make a single choice
within a set of choices.
The ScrollPane component can be used to display content that is too large for the area into
which it is loaded.
The FLVPlayback component allows you to include a video player in the Flash CS3
Professional application.
For each instance of the FLVPlayback component, the align, autoPlay, cuePoints,
preview, scaleMode, skin, skinAutoHide, skinBackgroundAlpha, skinBackgroundColor,
source, and volume parameters can be set in the Component Inspector or the Property
Inspector.
4.5 Exercise
1. The _______________ property returns the character code value of the key pressed or
released by the user.
keyCode
keyDown
charCode
charEvent
2. To hide the standard pointer, use the hide() method of the built-in Mouse class.
MouseEvent
Mouse
Sprite
InteractiveObject
3. The API allows you to create and manipulate components while the application is running.
True
False
4. The _________________ component allows the user to make a single selection from the
drop-down list.
Check Box
Radio Button
Scroll Pane
Combo Box
5. Which of the following component allows including a video player in the Flash CS3
Professional application?
FLVPlayback
ScrollPane
RadioButton
ComboBox
Answer Key
Quick Answers
Exercise Answers
1. Actions
3. trace()
1. Objects
3. False
2. True
Quick Test 2.2
1. Date()
3. flash.display.loader
1. Script Navigator
2. Operators
3. False
4. nextScene()
5. True
6. mouseMove
7. True
8. sort()
Exercise 2.8
2. Associative
Exercise 1.11
2. False
1. showMessage()
2. removeChild()
3. True
4. NONE
5. False
6. fullYear
7. SharedObject.flush()
Exercise 3.12
2. False
1. package
2. Math
3. True
4. stage
3. Math
5. True
Quick Test 3.2
1. Subclass, super
class
Exercise 4.5
2. True
1. charCode
2. Mouse
3. True
4. Combo Box
3. Movieclip
Quick Test 4.1
1. keyCode
3. False
2. ActionScript
5. FLVPlayback