Public
Your constructor has to be public in Actionscript 3.0
package {
public class MyClass extends MovieClip
public function MyClass():void
{
// your code here
}
}
When sending a message DOWN the display list (say, from stage to a MovieClip to a MovieClip nested inside a MovieClip) making a method public allows you to use that method from the stage or the parent MovieClip.
package {
public class MyClass extends MovieClip
public function MyClass():void
{
// your code here
}
public function start():void
{
// start this instance from a parent MovieClip or the stage
}
}
Private
Most of the time, when you’re not sure what to do, you can just make your methods and properties private and you will be doing the right thing.
Think of it like this…a car has many properties. Something like a steering wheel might be public because the user needs to access the steering wheel. But the user doesn’t need to know about how the engine works in order to be able to drive the car…so the engine can be private.
Protected
Using the protected access modifier comes in when dealing with inheritance. If you have a base class (say, a class called Animal) and you have a variable or method that you want to be available in the subclass (say, the property eyeballs or the method run). Making these properties or methods protected will make them available in the subclasses Cat or Dog.
If you use private this won’t work at all…so if you’re having problems accessing things in your subclasses make sure to change them from private to protected.
Internal
The only time I have seen the access modifier internal used is when writing singletons. Otherwise I know of no real-world use of internal. You can write tons of things in Actionscript without using internal at all…


