Packages and Access Modifiers
When creating a program with several classes, we will potentially encounter conflicts between our classes and the adobe classes (and even between our own classes!). If we choose to implement frameworks and other prepared classes, the risk will only increase.
The simple solution is to simply rename your classes, but this forces you to create an elaborate naming system, resulting in unintuitive class names and confusion.
We can avoid these conflicts by smart usage of Packages.
Package definitions are declared at the start of the .as class file, signified by the keyword package.
package myPackageName{ }
Now, if we decided to create a Button class with specific behaviour in a hypothetical package called game, it will not conflict with the Button class of the Adobe suite.
package game{ public class Button{ //this class will not conflict with the Button class of the Adobe suite! } }
Access of variables among classes from different packages depends on a function’s access modifier. The only way a variable from one package can be accessed from another is if the function’s access modifier is set to public.
The chart below will explain how access modifiers affect classes.
