750
Chapter 12: ActionScript Dictionary
The
object
parameter becomes the context in which the properties, variables, and functions in
the
statement(s)
parameter are read. For example, if
object
is
my_array
, and two of the
properties specified are
length
and
concat
, those properties are automatically read as
my_array
.
length
and
my_array.concat
. In another example, if
object
is
state.california
,
any actions or statements inside the
with
action are called from inside the
california
instance.
To find the value of an identifier in the
statement(s)
parameter, ActionScript starts at the
beginning of the scope chain specified by the
object
and searches for the identifier at each level
of the scope chain, in a specific order.
The scope chain used by the
with
action to resolve identifiers starts with the first item in the
following list and continues to the last item:
•
The object specified in the
object
parameter in the innermost
with
action.
•
The object specified in the
object
parameter in the outermost
with
action.
•
The Activation object. (A temporary object that is automatically created when a function is
called that holds the local variables called in the function.)
•
The movie clip containing the currently executing script.
•
The Global object (built-in objects such as Math and String).
To set a variable inside a
with
action, the variable must have been declared outside the
with
action or you must enter the full path to the Timeline on which you want the variable to live. If
you set a variable in a
with
action without declaring it, the
with
action will look for the value
according to the scope chain. If the variable doesn’t already exist, the new value will be set on the
Timeline from which the
with
action was called.
In Flash 5 or later, the
with
action replaces the deprecated
tellTarget
action. You
are encouraged to use
with
instead of
tellTarget
because it is a standard ActionScript extension
to the ECMA-262 standard. The principal difference between the
with
and
tellTarget
actions
is that
with
takes a reference to a movie clip or other object as its parameter, while
tellTarget
takes a target path string that identifies a movie clip as its parameter, and cannot be used to
target objects.
Example
The following example sets the
_x
and
_y
properties of the
someOther_mc
instance, and then
instructs
someOther_mc
to go to Frame 3 and stop.
with (someOther_mc) {
_x = 50;
_y = 100;
gotoAndStop(3);
}
The following code snippet shows how to write the preceding code without using a
with
action.
someOther_mc._x = 50;
someOther_mc._y = 100;
someOther_mc.gotoAndStop(3);
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...