Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamically retrieve library symbols to add on to stage?

New Here ,
Jun 12, 2017 Jun 12, 2017

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?

178
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 12, 2017 Jun 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]();

Translate
LEGEND ,
Jun 12, 2017 Jun 12, 2017
LATEST

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]();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines