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

AddChild Using HTML5 Canvas In Animate 2020

Explorer ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

I'm trying to add a movie clip from the library when I click a button on the stage. When I test the movie, I get no reponse when I click the button. Here's the code I'm using. The movie clip I'm trying to add is called "bluBox".

 

var fl_MyInstance = new lib.bluBox();

this.addButton.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler()
{

this.addChild(fl_MyInstance);
}

 

Thanks

Views

963

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

Community Expert , Nov 12, 2020 Nov 12, 2020

Hi.

 

Is the linkage name of your symbol set to bluBlox in the Library?

image.png

 

Please let us know.

 

Regards,

JC

Votes

Translate

Translate
Community Expert ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

Hi.

 

Is the linkage name of your symbol set to bluBlox in the Library?

image.png

 

Please let us know.

 

Regards,

JC

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 ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

Linkage.png

 

Here's what I see 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
Community Expert ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

your code is failing because you have no linkage id assigned.  the symbol name isn't relevant when using the "new" constructor.

 

do what @JoãoCésar suggested by double clicking in the linkage field of your bluBox library symbol and typing "bluBox" (without quotes).

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 ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

Linkage_2.png

 

Okay, I changed the linkage but it still doesn't add bluBox to the stage when I click the button.

 

Here's the code:

var fl_MyInstance = new lib.bluBox();

this.addButton.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler()
{
alert("Mouse clicked");

this.addChild(bluBox);

}

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 ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

Okay, it works now. 

 

I screwed up the addChild line.

 

I had "this.addChild(bluBox);"

 

I changed it to "this.addChild(fl_MyInstance);"

 

Thanks for the help 🙂

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
Community Expert ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

Hi again. Your addChild statement should be:

this.addChild(fl_MyInstance);

 

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 ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

Thanks, it works now.

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
Community Expert ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

the addChild part was correct in your original post. 

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 ,
Nov 12, 2020 Nov 12, 2020

Copy link to clipboard

Copied

LATEST

Yes, I screwed that part up.

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