I'm using HTML5 and I need to dynamically create some objects from code, then modify them later by name. Right now I have:
var a1 = new lib.symbol3(); a1.name = "A1"; stage.addChild(a1); var a2 = new lib.symbol3(); a2.name = "A2"; stage.addChild(a2);
and so on.
But when I try to reference them by name, I get errors saying they are undefined. Even when I console.log them
I get undefined.
Am I doing something wrong?
May not be the proper answer, but try this as workaround to adress your created clips:
For example to position it to an x-value of 150, try this:
Amazing! I didn't realize I could do that instead. Thanks for your reply!
However I am still curious if there is a 'correct' way to use bracket notation after creating an symbol on stage from code. Using brackets works just fine for symbols that I place on the stage myself.
Copy link to clipboard
If you weren't doing anything wrong it would be working, so... yes.
a1.name = "A1";
stage.A1 = a1;
Be careful when doing this not to overwrite any properties that may already exist.
Woah it works! I never would have guessed that would be the solution. Thank you for your answers!