Toon posts:

[Flash/AS 2.0] Het gebruik van het sleutelwoord 'this'

Pagina: 1
Acties:

Verwijderd

Topicstarter
Flash ActionScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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. You can use the this keyword to learn when a method or property belongs to a particular class. For example, for a function on the main Timeline, write ActionScript using the following format:

circle_mc.onPress = function() {
   this.startDrag();
};
circle_mc.onRelease = function() {
   this.stopDrag();
};

For a class, you can write code in the following format:

class User {
   private var m_username:String;
   private var m_password:String;
   function User(username:String, password:String) {
      this.m_username = username;
      this.m_password = password;
   }
   public function get username():String {
      return this.m_username;
   }
   public function set username(username:String):Void {
      this.m_username = username;
   }
}
Ik vraag me af of het beter is om ook op de timeline zelf gebruik te maken van het sleutelwoord this? Dus: this.createEmptyMovieClip() etc. Graag hoor ik jullie mening.

[ Voor 5% gewijzigd door Verwijderd op 23-09-2005 14:55 ]