bsp; // 构造器永远都是public的 function Helper() { } }
// 子辅助类默认是internal的 // 可以继承其他辅助类 class SubHelper extends Helper { // 构造器,public function SubHelper() { trace(pubNum); // OK trace(protNum); // OK - 继承得到的 // trace(privNum); // Error - 不能访问private trace(interNum); // OK } }
另外一个例子:
package { import flash.display.Sprite; import containers.*; // Application class needs to be public (internal by default) public class AccessControl extends Sprite { // constructors are always public function AccessControl() { // can access classes in other packages // only if public var bowl:Bowl = new Bowl(); // OK // var basket:Basket = new Basket(); // Error - cannot access internal trace(bowl.pubNum); // OK // trace(bowl.protNum); // Error - cannot access protected // trace(bowl.privNum); // Error - cannot access priv |