top | item 23362240

(no title)

zwetan | 5 years ago

In Java you would use packages to group together class definitions

same as with C++, C# where you would use namespaces to do that

aka define the scope of classes

in AS3, the packages are used the same, group collection of definitions, not only classes and interfaces but also variables, constants.

The namespaces in AS3 are used to define the visibility of definitions at the class level, a bit like being able to define your own "public" attribute.

In ActionScript 3, by default the AS3 namespace is open, for example with a builtin like Array instead of using the push() method defined in the prototype, it uses the push() method defined in the AS3 namespace.

See https://github.com/adobe/avmplus/blob/master/core/Array.as#L...

But you also have mode to compile with -ES to not open that AS3 namespace by default.

In ES4, namespaces could do more advanced stuff like namespace shadowing (only a proposal at the time), see https://web.archive.org/web/20070629024201/http://developer....

For AS3, see 1.9 Namespaces / 12 Namespaces / etc. https://github.com/as3lang/ActionScript3/wiki/Specification

discuss

order

No comments yet.