AS2.0 support for Private

xiaoxiao2021-03-06  29

The emergence of AS2.0 makes many people to share the object-oriented programming. More people have also begun to develop him to develop, but many people have found some problems, for example, for the support of the method, no, There is no limit on Private, and many people are more discussions are not worried about private limits. In fact, private can achieve access to control in AS2.0.

I have also heard a lot of people saying that Private's restrictions started to the role in AS2.0. I have also tried it before, this code written.

The constructor of the TEST class is defined as private

Private function test ()

{

Trace ("this is test");

}

In a flash, call the constructor that private can not initialize the variable with NEW, but this

VAR a = new test ();

But there is no problem, you can still use it, everyone will say, to A, AS2.0 is not supported for Private. But today I look closely like this variable statement seems to have some problems. It turns out that we are wrong, in us define variables There is no type of declaration a! For object-oriented languages, the object is declared, and the type of object must be declared, or the TEST class is still compiled.

Vat A: Test = new test ();

However, object-oriented programming should declare the type of variables as the second method. This leads out two problems, 1 is Flash variable declaration mechanism, 2 is to develop good programming habits.

转载请注明原文地址:https://www.9cbs.com/read-79518.html

New Post(0)