Using the this keyword
Whenever possible, use the
your code works without it. Use the
belongs to a particular class. For example, for a function on a timeline, you write ActionScript
2.0 code by using the following format:
circleClip.onPress = function() {
this.startDrag();
};
circleClip.onRelease = function() {
this.stopDrag();
};
For a class, use the following format to write code:
class User {
private var username:String;
private var password:String;
function User(username:String, password:String) {
this.username = username;
this.password = password;
}
public function get username():String {
return this.username;
}
public function set username(username:String):Void {
this.username = username;
}
}
If you consistently add the
be much easier to read and understand.
keyword as a prefix instead of omitting the keyword, even if
this
keyword to learn when a method or property
this
keyword in these situations, your ActionScript 2.0 code will
this
ActionScript coding conventions
749
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?