Skip to main content
poped18613449
Participant
July 5, 2021
Answered

Accessing a movie clip in library with javascript

  • July 5, 2021
  • 1 reply
  • 264 views

Hi,

Please accept my apologies for, what must seem like a basic question.

 

I have imported an .svg from inkscape to the library, converted it to a movie clip (test1) and I want to be able to add the movie clip to the stage using javascript. Here is my latest effort.

 

var stage = new createjs.Stage('democanvas');
var test2 = new lib.test1();
this.addChild(test2);

 

I haven't found any post about this forum and others, probably because it is is trivial.

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

There's no need to instantiate a new stage because there's already a Stage instance called stage that is created in the publishing process.

 

To add a symbol from the Library, you have first to make sure it has a linkage name. Like this:

 

Then just instantiate it and add it to the display list:

var test1 = new lib.test1();
this.addChild(test1);

 

I hope it helps.

 

Regards,

JC

1 reply

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
July 5, 2021

Hi.

 

There's no need to instantiate a new stage because there's already a Stage instance called stage that is created in the publishing process.

 

To add a symbol from the Library, you have first to make sure it has a linkage name. Like this:

 

Then just instantiate it and add it to the display list:

var test1 = new lib.test1();
this.addChild(test1);

 

I hope it helps.

 

Regards,

JC

poped18613449
Participant
July 5, 2021

Thank you so much. I am embarrased to say that my library panel was docked and  so it didn't

look like your  screenshot until I expanded it. This is my  first post, what do I do to rate you or your answer. I have marked it as the correct answer. Is there anything elses i should do?

JoãoCésar17023019
Community Expert
Community Expert
July 5, 2021

You're welcome!

 

I'm glad you figured it out.

 

No need to do anything else! Marking as correct is enough and it will help others that may have the same doubt as you. Thanks a lot for your consideration and have a really nice week!