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

Using Namespace

Get Adobe Flash player
by 9re 15 Oct 2009

    Talk

    makc3d at 15 Oct 2009 13:07
    for some reason packaged namespaces do not work in internal classes :( which would be necessary to make alternativa3d materials on wonderfl, for example. maybe it was my fault, though, will try again some time...
    9re at 16 Oct 2009 08:24
    hi! i cannot guess what happened in your code, but have much interest on the issue.
    makc3d at 16 Oct 2009 11:00
    I tried again, runned into same issue, and it was no magic. It's just I wasn't overriding clone() method, so clones of my class instance were basically superclass and it made it look like overriden methods in their namespace were not working... Working demo soon :)
    makc3d at 16 Oct 2009 12:17
    done, http://tinyurl.com/stereogram3d

    Tags

    Embed
/**
 * 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();
    }
}