Skip to main content
Participant
June 12, 2017
Answered

Dynamically retrieve library symbols to add on to stage?

  • June 12, 2017
  • 1 reply
  • 208 views

The current way to add a library symbol through code is through writing

var test = new lib.librarysymbolname();

this.addChild(test);

or just

this.addChild(new lib.librarysymbolname());

But suppose i have an XML file with a list of the library symbols names

How do i dynamically create the symbols after getting the names?

    This topic has been closed for replies.
    Correct answer ClayUUID

    As you've noted, dot notation doesn't allow use of variables. Bracket notation, however, does.

    Property accessors - JavaScript | MDN

    var test = new lib[variableName]();

    1 reply

    ClayUUIDCorrect answer
    Legend
    June 12, 2017

    As you've noted, dot notation doesn't allow use of variables. Bracket notation, however, does.

    Property accessors - JavaScript | MDN

    var test = new lib[variableName]();