AddChild Using HTML5 Canvas In Animate 2020

Community Beginner ,
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

163

Likes

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

Adobe Community Professional , Nov 12, 2020 Nov 12, 2020
Hi. Is the linkage name of your symbol set to bluBlox in the Library? Please let us know. Regards, JC

Likes

Translate

Translate
Adobe Community Professional ,
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

Likes

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

Copy link to clipboard

Copied

Linkage.png

 

Here's what I see in the library

Likes

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
Adobe Community Professional ,
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).

Likes

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 Beginner ,
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);

}

Likes

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 Beginner ,
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 🙂

Likes

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

Copy link to clipboard

Copied

Hi again. Your addChild statement should be:

this.addChild(fl_MyInstance);

 

Likes

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

Copy link to clipboard

Copied

Thanks, it works now.

Likes

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

Copy link to clipboard

Copied

the addChild part was correct in your original post. 

Likes

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

Copy link to clipboard

Copied

LATEST

Yes, I screwed that part up.

Likes

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