In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Really private namespace test

Создание неймспейса, который невозможно получить извне.
Get Adobe Flash player
by qizh 29 Nov 2012
/**
 * Copyright qizh ( http://wonderfl.net/user/qizh )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3Mm4
 */

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            const tf:TextField = new TextField();
            tf.wordWrap = true;
            tf.width = 465;
            tf.height = 465;
            addChild(tf);
            
            const obj:ClassWithSecret = new ClassWithSecret();
            
            tf.appendText(obj.doAction());
            
            const exclusiveNS:Namespace = obj.getNS("password");
            tf.appendText("\n" + obj.exclusiveNS::doAction());
        }
    }
}
class ClassWithSecret {
    private namespace exclusive;
    public function getNS(password:String):Namespace {
        if (password == "password") return exclusive;
        else return null;
    }
    exclusive function doAction():String {
        return "exclusive thing";
    }
    public function doAction():String {
        return "ordinary thing";
    }
}