Skip to main content
Known Participant
October 27, 2021
Answered

How To Determine An Instance Name When Adding A Movie Clip From The Library In Animate CC

  • October 27, 2021
  • 1 reply
  • 572 views

Hi,

 

I have the following code - 

var fl_MyInstance = new lib.ResetBtns();

 

this.ShowReset.addEventListener("click", fl_MouseClickHandler_2.bind(this));

function fl_MouseClickHandler_2() {

  this.addChild(fl_MyInstance);
  fl_MyInstance.x = 219.05;
  fl_MyInstance.y = 110.55;
} //This code adds a MC from the library and works just fine

 

//This code should call the alert command and does not work

this.ResetButtons.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));

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

 

The name of the libary item I'm adding is ResetButtons. The Linkage name is ResetBtns. 

 

ResetSVDU is a button within the ResetButtons MC.

 

I've tried ResetButtons, ResetBtns, and fl_MyInstance but I can't get to the ResetSVDU button to trigger the alert command.

 

My question is, what name should I use in the following line?

 

this.????.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));

 

Thanks

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

    Here you go.

     

    https://drive.google.com/file/d/1fV3cwfS9Qqz6cdNHKeiSe7Idz4zaq6Cw/view?usp=drivesdk


    Thanks for the file.

     

    You only need to remove the this keyword from the beginning of line 20.

     

    From this:

    this.fl_MyInstance.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));

     

    To this:

    fl_MyInstance.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));

     

    fl_MyInstance is a variable you created and not a property of the main timeline.

     

    Regards,

    JC

     

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    October 27, 2021

    Hi.

     

    It should be:

    fl_MyInstance.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));
     
    But is ResetSVDU the instance name or the symbol name? Make sure it's the instance name.
     
    Please let us know.
     
    Regards,
    JC
    mlb172Author
    Known Participant
    October 28, 2021

    So here's what I'm running. It still doesn't work.

     

    var fl_MyInstance = new lib.ResetBtns();

     

    //set the dynamic text
    this.ShowReset.ResetText.text = "Show Reset Buttons";

     

    this.ShowReset.addEventListener("click", fl_MouseClickHandler_2.bind(this));

    function fl_MouseClickHandler_2() {


    this.addChild(fl_MyInstance);
    fl_MyInstance.x = 219.05;
    fl_MyInstance.y = 110.55;
    }

     

    this.fl_MyInstance.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));

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

    }

     

    ResetSVDU is the instance name of the button inside the fl_MyInstance MC.

    mlb172Author
    Known Participant
    October 29, 2021

    Thanks for the file.

     

    You only need to remove the this keyword from the beginning of line 20.

     

    From this:

    this.fl_MyInstance.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));

     

    To this:

    fl_MyInstance.ResetSVDU.addEventListener("click", fl_MouseClickHandler.bind(this));

     

    fl_MyInstance is a variable you created and not a property of the main timeline.

     

    Regards,

    JC

     


    That fixed it 🙂

     

    Thanks for the help.