I know I’m a little late to the party on this one but I finally cracked Flash Classes last weekend – yay!
To be honest there wasn’t really a whole lot to crack, just the definitions of private and public functions.
Essentially a public function will execute when the class is initialised, and a private function will wait to be called, and that’s all there is to it .
Try this out:
In a text editor create a file and name it TestClass.as
Type the following:
class TestClass{
public function foo(){
trace(“Hello from Foo”);
}
private function baa(){
trace(“Hello from Baa”);
}
}
Now create a new Flash document and save it in the same folder as TestClass.as
On frame one (or any other) type:
var myTestClass = new TestClass();
now publish your movie and you should get the output “Hello from Foo”
If you now add the following line:
myTestClass.baa();
publish your movie and you should get the output “Hello from Foo”, “Hello from Baa”
Yes, it really is that easy!