forked from: Really private namespace test
♥0 |
Line 30 |
Modified 2012-11-30 08:04:18 |
MIT License
archived:2017-03-30 08:27:52
ActionScript3 source code
/**
* Copyright hemingway ( http://wonderfl.net/user/hemingway )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/2m8i
*/
// forked from qizh's Really private namespace test
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";
}
}