Revision: 40491
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 3, 2011 00:38 by JaaQ
Initial Code
import flash.utils.getDefinitionByName; import flash.utils.getQualifiedClassName; public function getNewClassInstance(object:*):*{ var className:String = getQualifiedClassName(object); var classReference:Class = getDefinitionByName(className) as Class; var newClassInstance:* = new classReference(); // e.g. object is from the class MovieClip trace(newClassInstance); // [object MovieClip] trace(className); // flash.display::MovieClip trace(classReference); // [class MovieClip] return newClassInstance; }
Initial URL
Initial Description
This function returns a new instance of the class it receives.
Initial Title
Returns a new object of the same Class
Initial Tags
class, object, copy
Initial Language
ActionScript 3