Flash MX 2004 Class members have the difference between public and private members, so how do we apply and differentiate them, here are a few simple examples to help you understand.
If not specifically specified, all members of the class are public, not specifically declared. But private members must be declared.
If the member is public, it can be invoked by the main class and Flash. If the members are private, they can only be accessed through the main class. Let's look at an example, which has a private method showsomething ().
Class Show {private Function showsomething () {Trace ("Sth");}
Then take a look at the following code:
var say:show = new show (); say. Showsomething ();
The code run will appear: "The ' is private and cannot to be accessed." This is because we cannot invoke private members.
If you modify this, there is no problem because the main class is called:
var say = new show (); say. Showsomething ();
Now we should have some understanding of the public and private members.
If it is a class that calls itself, then there is no problem, see this example:
Class Show {private Function showsomething () {Trace ("Sth");} Public Function ShowSomething2 () {showsomething ();}}
Then, this program will work:
var say:show = new show (); say. ShowSomething2 ();
Because we're calling a public member.
You can do more exercises and get to know the difference between public and private members.