EasyManua.ls Logo

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

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...
ActionScript coding conventions 749
Using the this keyword
Whenever possible, use the this keyword as a prefix instead of omitting the keyword, even if
your code works without it. Use the
this keyword to learn when a method or property
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 this keyword in these situations, your ActionScript 2.0 code will
be much easier to read and understand.

Table of Contents

Related product manuals