Actionscript Attributes: Public, Private, Internal, Protected

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.

0
Your rating: None

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: [code], [blockcode], [as], [as3], [css], [drupal5], [drupal6], [html], [java], [javascript], [mysql], [php], [xml].
  • You may quote other posts using [quote] tags.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.