About data types
79
The ActionScript MovieClip object has methods that let you control movie clip symbol
instances on the Stage. This example uses the
play()
and
nextFrame()
methods:
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
user
and creates three properties,
name
,
age,
and
phone,
which are String and Numeric data types.
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,
"L7"
is a string assigned to the variable
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;
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...