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
Hi.
Is the linkage name of your symbol set to bluBlox in the Library?
Please let us know.
Regards,
JC
Copy link to clipboard
Copied
Hi.
Is the linkage name of your symbol set to bluBlox in the Library?
Please let us know.
Regards,
JC
Copy link to clipboard
Copied
Here's what I see in the library
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).
Copy link to clipboard
Copied
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);
}
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 🙂
Copy link to clipboard
Copied
Hi again. Your addChild statement should be:
this.addChild(fl_MyInstance);
Copy link to clipboard
Copied
Thanks, it works now.
Copy link to clipboard
Copied
the addChild part was correct in your original post.
Copy link to clipboard
Copied
Yes, I screwed that part up.