Statements
209
Specifies that a variable or function is available to any caller. Because variables and functions
are public by default, this keyword is used primarily for stylistic reasons. For example, you
might want to use it for reasons of consistency in a block of code that also contains private or
static variables.
Availability:
ActionScript 2.0; Flash Lite 2.0
Parameters
name
:
String
- The name of the variable or function that you want to specify as public.
Example
The following example shows how you can use public variables in a class file. Create a new
class file called User.as and enter the following code:
class User {
public var age:Number;
public var name:String;
}
Then create a new FLA or AS file in the same directory, and enter the following ActionScript
in Frame 1 of the Timeline:
import User;
var jimmy:User = new User();
jimmy.age = 27;
jimmy.name = "jimmy";
If you change one of the public variables in the User class to a private variable, an error is
generated when trying to access the property.
See also
private statement
return statement
return[
expression
]
Specifies the value returned by a function. The
return
statement evaluates
expression
and
returns the result as a value of the function in which it executes. The
return
statement causes
execution to return immediately to the calling function. If the
return
statement is used alone,
it returns
undefined.
You can't return multiple values. If you try to do so, only the last value is returned. In the
following example,
c
is returned:
return a, b, c ;
If you need to return multiple values, you might want to use an array or object instead.
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...