how to add a symbol from the library?
this.attachMovie(“square”, “square”, 1);
and in AS3,
var square1:square=new square();
but how do you add a symbol dynamically from the library? say if you have a shape stored in a variable:
var shape:String = “square”;
and you want to add the symbol in the library with this name.
in AS2, simple! you could have written:
this.attachMovie(shape, shape, 1);
however the AS3 syntax doesn’t obviously allow for dynamic references. so how is it done? (credit to kglad for assisting in this discovery)
getDefinitionByName is what you need to extract the class from the library like so:
var classRef:Class = getDefinitionByName(shape) as Class;
var square1:* = new classRef();