MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference page 79

Actionscript language reference
Table of Contents

Advertisement

The following example uses assignment by reference to create the
variable,
moonsOfJupiter
which contains a reference to a newly created Array object. Assignment by value is then used to
copy the value
to the first element of the array referenced by the variable
"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
. Assignment by value is then used to assign the value of
neptune
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
merkur
(the German word for mercury) and assigning it the value of
. This creates two variables
mercury
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)
= (assignment)
79

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents