Description
Operator; assigns the value of
element, or property in
Assignment by value copies the actual value of
Assignment by value is used when a variable is assigned a number or string literal. Assignment by
reference stores a reference to
commonly used with the
a reference to that location in memory is assigned to a variable.
For more information, see
Example
The following example uses assignment by value to assign the value of 5 to the variable
var x:Number = 5;
The following example uses assignment by value to assign the value
var x:String;
x = "hello";
The following example uses assignment by reference to create the
which contains a reference to a newly created Array object. Assignment by value is then used to
copy the value
"Callisto"
:
moonsOfJupiter
var moonsOfJupiter:Array = new Array();
moonsOfJupiter[0] = "Callisto";
The following example uses assignment by reference to create a new object, and assign a reference
to that object to the variable
49528 to the size property of the myObject object:
var mercury:Object = new Object();
mercury.diameter = 3030; // in miles
trace (mercury.diameter); // output: 3030
The following example builds upon the previous example by creating a variable named
(the German word for mercury) and assigning it the value of
that reference the same object in memory, which means you can use either variable to access the
object's properties. We can then change the diameter property to use kilometers instead of miles:
var merkur:Object = mercury;
merkur.diameter = 4878; // in kilometers
trace (mercury.diameter); // output: 4878
See also
== (equality)
(the parameter on the right) to the variable, array
expression2
. Assignment can be either by value or by reference.
expression1
in
expression2
operator. Use of the
new
"Operator precedence and associativity" on page
to the first element of the array referenced by the variable
. Assignment by value is then used to assign the value of
neptune
and stores it in
expression2
. Assignment by reference is
expression1
operator creates an object in memory and
new
"hello"
moonsOfJupiter
mercury
.
expression1
32.
.
x
to the variable
variable,
merkur
. This creates two variables
= (assignment)
:
x
119
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?