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

Dynamically retrieve library symbols to add on to stage?

New Here ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

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?

Views

135

Translate

Translate

Report

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

Votes

Translate

Translate
LEGEND ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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