ActionScript 3.0 provides some attributes that control access to properties inside member of a class, including variables, constants, and methods: public, private, protected, and internal.
internal (default): Visible to references inside the same package. Makes a property visible to callers within its own package.
private: Visible to references in the same class. It makes a property visible only to callers within the property’s defining class
protected: Visible to references in the same class and derived classes. It is available within its own class or to classes that lie anywhere below it in the inheritance hierarchy
public: Visible to references everywhere. It makes a property visible anywhere in your script.
static: Specifies that a property belongs to the class, as opposed to instances of the class. Can be used with properties declared with the var, const, or function keywords, allows you to attach a property to the class rather than to instances of the class. Code external to the class must call static properties by using the class name instead of an instance name.
So, what access modifiers should i use?
Well, for small projects you can define everything as public and project run perfectly, but if you want to build a strong project with reusability, portability and reliability you should learn more about access modifiers and how to use them.

Post new comment