Hope there is someone here kind and knowledgable enough to help me out with this.
I have a gallery that has several predetermined categories, each on with a button.
The buttons are named with the “bt”+(gallery name) convention
So, i got instance names like “btcolor”, “btsketch”, “bttape”. I subtract the first two letters and use the remaining substring to call the images in the gallery itself. The gallery images are named “color1”, “color2”,…
I want to place a custom embelm in the header of each gallery. They include an illlustration, so generating them via AS is not an option. I have them in my library and chose to output them to AS in the properties dialog, using the naming convention “em”+(gallery name).
Problem is I don’t know how to add a child of a dynamically determined class name.
var simbolo:[“em”+destino] = new [“em”+destino];
does not compile… I want the “simbolo” to be an instance of the class “em”+(class), depending on what the user clicks (ex: emcolor, emsketch…). They work if I reference them explicitly,
var simbolo:emcolor= new emcolor();
but how can I reference them dynamically?
Any ideas?
Here’s the full code:
btcolord.addEventListener (MouseEvent.CLICK,opengallery);
bttrend.addEventListener (MouseEvent.CLICK,opengallery);
[...]
function opengallery(evt:Event):void
{
var destino:String=evt.target.name.substring(2,evt.target.name.length);
trace (destino);
var square:Sprite = new Sprite();
square.graphics.beginFill (0x000000,0.5);
square.graphics.drawRect(0,0, stage.stageWidth-100,stage.stageHeight-100);
square.graphics.endFill();
var punto:Point = new Point(50,50);
var punctum:Point = this.globalToLocal(punto);
square.x=punctum.x;
square.y=punctum.y;
addChild(square);
var simbolo:["em"+destino] = new ["em"+destino];
simbolo.x=punctum.x;
simbolo.y=punctum.y;
addChild(simbolo);
}
stop();