EasyManua.ls Logo

MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE - Typeof Operator

MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE
780 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...
Operators 177
Example
Usage 1: The following example declares a public variable named
userName whose type is
String and assigns an empty string to it:
var userName:String = "";
Usage 2: The following example shows how to specify a function's parameter type by defining
a function named
randomInt() that takes a parameter named integer of type Number:
function randomInt(integer:Number):Number {
return Math.round(Math.random()*integer);
}
trace(randomInt(8));
Usage 3: The following example defines a function named squareRoot() that takes a
parameter named
val of the Number type and returns the square root of val, also a Number
type:
function squareRoot(val:Number):Number {
return Math.sqrt(val);
}
trace(squareRoot(121));
See also
var statement, function statement
typeof operator
typeof(expression)
The typeof operator evaluate the expression and returns a string specifying whether the
expression is a
String, MovieClip, Object, Function, Number, or Boolean value.
Availability: ActionScript 1.0; Flash Lite 2.0
Operands
expression : Object - A string, movie clip, button, object, or function.
Returns
String - A String representation of the type of expression. The following table shows the
results of the
typeof operator on each type of expression.
Expression Type Result
String string
Movie clip movieclip

Table of Contents

Related product manuals