Using Namespace
♥4 |
Line 35 |
Modified 2009-10-15 09:11:55 |
MIT License
archived:2017-03-08 17:24:14
ActionScript3 source code
/**
* Copyright 9re ( http://wonderfl.net/user/9re )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tXLe
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
public class NamespaceExample extends Sprite {
public function NamespaceExample() {
var tf:TextField = new TextField;
tf.width = tf.height = 465;
tf.mouseEnabled = tf.selectable = false;
addChild(tf);
var sp:Super = new Super;
tf.appendText(sp.public_function() + "\n");
tf.appendText(sp.my_internal::internal_function() + "\n");
tf.appendText(sp.super_function() + "\n");
}
}
}
namespace my_internal = "http://wonderfl.net/user/9re/";
class UsingNamespace {
public function UsingNamespace() {
my_internal::my_instance = this;
}
public function public_function():String {
return "public_function";
}
my_internal function internal_function():String {
return "internal_function";
}
my_internal var my_instance:UsingNamespace;
}
class Super extends UsingNamespace {
public function super_function():String {
use namespace my_internal;
return "super: " + my_instance.internal_function();
}
}