O.K., I made these two classes (foo and bar), each in their own .AS file. Both of these classes were saved in a package called custom.
In an .FLA file I called "Sandbox", I put the following code in the timeline:
import custom.foo;
import custom.bar;
var f:foo = new foo("FOO");
var b:bar = new bar("BAR");
trace(f.valueOf());
trace(b.valueOf());
f.statement();
b.statement();
I got the following output:
FOO
BAR
Statement: the value is FOO
Statement: the value is BAR
Now, usually, I wouldn't think much of this, but look at the code for the classes...
Here is the foo.as file (minus my comments):
package custom {
public class foo {
public var property:String;
public var value:String;
public function foo (par:String = "?") {
this.property = par;
this.value = this.valueOf();
return;
}
prototype.expression = function () {
trace ("Expression: the value is", this.property);
}
public function statement () {
trace ("Statement: the value is", this.property);
}
public function valueOf() {
return(this.property);
}
}
}
...and here is the bar.as file (minus my comments):
package custom {
public class bar {
public var property:String;
public var value:String;
public function bar (par:String = "?") {
prototype.property = par;
prototype.value = prototype.valueOf();
return;
}
prototype.expression = function () {
trace ("Expression: the value is", prototype.property);
}
public function statement () {
trace ("Statement: the value is", prototype.property);
}
public function valueOf() {
return(prototype.property);
}
}
}
Why did I get the same results when I used prototype instead of this?
I find that, although this is a vexing question, it cannot be answered unless someone can tell me what prototype actually means.
I know this roughly translates to "this instance of this class", but... What does prototype mean?
