MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 79

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

The ActionScript MovieClip object has methods that let you control movie clip symbol
instances on the Stage. This example uses the
and
methods:
play()
nextFrame()
mcInstanceName.play();
mc2InstanceName.nextFrame();
You can also create custom objects to organize information in your Flash application. To add
interactivity to an application with ActionScript, you need many pieces of information: for
example, you might need a user's name, age, and phone number; the speed of a ball; the
names of items in a shopping cart; the number of frames loaded; or the key that the user
pressed last. Creating custom objects lets you organize this information into groups, simplify
your scripting, and reuse your scripts.
The following ActionScript code shows an example of using custom objects to organize
information. It creates a new object called
and creates three properties,
,
and
user
name
age,
which are String and Numeric data types.
phone,
var user:Object = new Object();
user.name = "Irving";
user.age = 32;
user.phone = "555-1234";
For more information, see
"Example: Writing custom classes" on page
263.
String data type
A string is a sequence of characters such as letters, numbers, and punctuation marks. You
enter strings in an ActionScript statement by enclosing them in single (') or double (")
quotation marks.
A common way that you use the string type is to assign a string to a variable. For example, in
the following statement,
is a string assigned to the variable
:
"L7"
favoriteBand_str
var favoriteBand_str:String = "L7";
You can use the addition (+) operator to concatenate, or join, two strings. ActionScript treats
spaces at the beginning or end of a string as a literal part of the string. The following
expression includes a space after the comma:
var greeting_str:String = "Welcome, " + firstName;
About data types
79

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents