private, protected & public

In ActionScript 2.0, there are “private” and “public” modifiers, but there is no “protected”. However, “private” behaves like “protected” – i.e. subclasses and instances can access private members; so there is no true private scope.

To make sure the compiler catches access to private properties/functions, strict-typing has to be used:

Because type-checking is only performed at compile time, there is no guarantee that private members cannot be accessed at runtime.

By default, if the “public” modifier is left out, the member is assumed to be public.

2 thoughts on “private, protected & public

  1. Not a bug – it’s a feature! 😎

    Seriously, I’d have liked to see this implemented differently too, but because ActionScript 2.0 code is actually compiled to AS1, and there is no “private” in AS1, this is a Fact of Life until runtime type-checking is implemented.

Leave a Reply

Your email address will not be published. Required fields are marked *

five + three =