To create class files:
1.
Select File > New and then select ActionScript File, and then click OK.
2.
Select File > Save As and name the new file User.as.
3.
Type the following ActionScript code into the Script window:
/**
User class
author: John Doe
version: 0.8
modified: 08/21/2005
copyright: Macromedia, Inc.
This code defines a custom User class that allows you to create new
users and specify user login information.
*/
class User {
// private instance variables
private var __username:String;
private var __password:String;
// constructor statement
public function User(p_username:String, p_password:String) {
this.__username = p_username;
this.__password = p_password;
}
public function get username():String {
return this.__username;
}
public function set username(value:String):Void {
this.__username = value;
}
public function get password():String {
return this.__password;
}
public function set password(value:String):Void {
this.__password = value;
}
}
4.
Save your changes to the class file.
The previous code snippet begins with a standardized documentation comment, which
specifies the class name, author, version, date the class was last modified, copyright
information, and a brief description of what the class does.
236
Classes
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?