Strange private type

xiaoxiao2021-03-06  23

Updated: 12/13/2004 9:08 PM

Var log1 = new loginclass ("RERD");

TRACE (log1.getusername ());

//out.print:rerd

TRACE (log1.username);

//out.print:rerd

Username1_txt.text = log1.username;

// text box Shows RERD

// username and getUsername () are private, but can still be accessed? ? ?

//

Var log2: loginclass = new loginclass ("rerd");

Username2_txt.text = log2.username;

TRACE (log2.getusername ());

TRACE (log2.username);

/ **

Generate the following compilation errors, and log1-related username1_txt can also display value log1.username? ? ?

** Error ** Scene = Scene 1, Layer = Layer 1, Frame = 1: Line 39: The Member Is Private and Cannot Be Accessed.

TRACE (log2.getusername ());

** error ** Scene = Scene 1, layer = layer 1, frame = 1: line 40: The Member Is Private and Cannot Be Accessed.

TRACE (log2.username);

Total ActionScript Errors: 2 REPORTED ERRORS: 2

* /

Really hard to understand! It may be because the data type does not match when the strict data type specified will trigger the compiler error. There is such a sentence in Help "," should pay attention to the member access control is a function of compile time; when running, Flash Player does not distinguish Or public members "This is not difficult to understand why this happens.

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

New Post(0)