EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 78

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
78 Data and Data Types
Number data type
The Number data type is a double-precision floating-point number. The minimum value of a
number object is approximately 5e-324. The maximum is approximately 1.79E+308.
You can manipulate numbers using the arithmetic operators addition (
+), subtraction (-),
multiplication (
*), division (/), modulo (%), increment (++), and decrement (--). For more
information, see “Using numeric operators” on page 188.
You can also use methods of the built-in Math and Number classes to manipulate numbers.
For more information on the methods and properties of these classes, see the Math and
Number entries in ActionScript 2.0 Language Reference.
The following example uses the
sqrt() (square root) method of the Math class to return the
square root of the number 100:
Math.sqrt(100);
The following example traces a random integer between 10 and 17 (inclusive):
var bottles:Number = 0;
bottles = 10 + Math.floor(Math.random() * 7);
trace("There are " + bottles + " bottles");
The following example finds the percent of the intro_mc movie clip that is loaded and
represents it as an integer:
var percentLoaded:Number = Math.round((intro_mc.getBytesLoaded() /
intro_mc.getBytesTotal()) * 100);
Object data type
An object is a collection of properties. A property is an attribute that describes the object. For
example, the transparency of an object (such as a movie clip) is an attribute that describes its
appearance. Therefore,
_alpha (transparency) is a property. Each property has a name and a
value. The value of a property can be any Flash data type—even the Object data type.
This lets you arrange objects inside each other, or nest them.
To specify objects and their properties, you use the dot (
.) operator. For example, in the
following code,
hoursWorked is a property of weeklyStats, which is a property of employee:
employee.weeklyStats.hoursWorked

Table of Contents

Related product manuals