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

Problem dynamically adding from Library

Explorer ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

Hello,

I am using canvas and have a MovieClip in my library called sliderBtn. I am trying to import it to the stage using the following code, but this only works if I actually put the element on the stage. I would like to be able to add it by using code, if possible. This seems like something pretty simple. Is it possible to import an MC from the library as in AS3?

sliderBtn = new lib.sliderBtn();

stage.addChild(sliderBtn);

sliderBtn.x = 200;

sliderBtn.y = 200;

Views

1.3K

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 , Feb 23, 2017 Feb 23, 2017

If it's not used on any timeline you have to give it a linkage name by double-clicking the Linkage field in the library.

Votes

Translate

Translate
LEGEND ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

If it's not used on any timeline you have to give it a linkage name by double-clicking the Linkage field in the library.

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
Explorer ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

I saw this thread indicating that while the linkage name is grayed out, you can still click it in the interface, but I don't see where... No fields in the properties panel are becoming active when I double click and enter a name.

CreateJS Linkage ID greyed out in Flash CC 2015/Canvas Document

linkage.png

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
LEGEND ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

Clay means the linkage column in the Library. Not inside the symbol properties. Double-click on the currently empty linkage column for that symbol, and type sliderBtn.

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
Explorer ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

OMG. Thank you! This is not intuitive AT ALL.

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
LEGEND ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

Thanks for the "correct answer". I transferred it to Clay, because he gave the answer first, and his answer also gave the extra information about how if it's in the timeline you don't have to do the linkage name.

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
Explorer ,
Feb 24, 2017 Feb 24, 2017

Copy link to clipboard

Copied

LATEST

Yes, many thanks to both of you! In case it's helpful to someone else, here's a screen shot:

linkage.png

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
LEGEND ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

Something else that may matter, or not, I'm not sure! But you're adding the object to stage, and that isn't the same thing as the main timeline level. Here's a test:

alert(this==stage);

alert(this==exportRoot);

What I think of as being the main timeline is exportRoot and not stage.

As I say, it may not matter, but I would use:

this.addChild(sliderBtn);

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