Return to Snippet

Revision: 26168
at April 19, 2010 13:29 by adrianparr


Initial Code
package
{
	import flash.display.Sprite;
	import flash.utils.getDefinitionByName;

	public class DynamicCall extends Sprite
	{
		public function DynamicCall()
		{
            var ClassReference:Class = getDefinitionByName("String") as Class;
            var s:String = (new ClassReference("foo=") as String);
            trace(s);
		}
	}
}

// This basically creates an instance of the String class, from the 
// class name 'String'. getDefinitionByName takes the entire class 
// path, so if you wanted to create an instance of MovieClip, you would 
// provide the entire path:
// var ClassReference:Class = getDefinitionByName("flash.display.MovieClip") as Class;

Initial URL
http://www.mikechambers.com/blog/2006/06/22/actionscript-3-get-a-class-reference-by-class-name/

Initial Description

                                

Initial Title
AS3 Get a Class Reference by Class Name

Initial Tags
class

Initial Language
ActionScript 3