Skip to main content
Known Participant
January 26, 2021
Question

remove child

  • January 26, 2021
  • 2 replies
  • 175 views

hello!

i have chalange with remove child

i wrote this code

in button_2  the code removed olny the child from empty but not from empty1

what's wrong in the code??


this["empty"].addChild(new lib["picword14"]());
this["empty1"].addChild(new lib["picword14"]());


this.button_2.addEventListener("click", fl_ClickToGoToAndPlayFromFrame_2.bind(this));

function fl_ClickToGoToAndPlayFromFrame_2()
{
this["empty"].removeChildAt(); 
this["empty1"].removeChildAt();
}


this.button_3.addEventListener("click", fl_ClickToGoToAndPlayFromFrame_3.bind(this));

function fl_ClickToGoToAndPlayFromFrame_3()
{
this["empty"].addChild(new lib["picword14"]());
this["empty1"].addChild(new lib["picword14"]());
}

    This topic has been closed for replies.

    2 replies

    Yigal0D4BAuthor
    Known Participant
    February 3, 2021

    thank you

    it its work

    JoãoCésar17023019
    Community Expert
    Community Expert
    January 26, 2021

    Hi.

     

    You're using the removeChildAt method which requires an index. E.g.:

    this["empty"].removeChildAt(0);

     

    Just provide an index or use the removeChild method instead.

     

    Regards,

    JC