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

Cant removeChilds

Explorer ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

Hey i have problem:

am adding childs with this code:

function show_time(){

    var i:int;

        for (i = 0; i < dataArray.length; i++){

            var kalendorius:MovieClip = new calendar;

            kalendorius.name = "data"+i;

            addChild(kalendorius);

            kalendorius.x = ix;

            kalendorius.y = iy;

            timeArray = dataArray.split(" - ");

            kalendorius.menuo.text = timeArray[0];

            kalendorius.diena.text = timeArray[1];

            kalendorius.savaites_diena.text = timeArray[2];

            kalendorius.time1.text = timeArray[3];

            kalendorius.time2.text = timeArray[4];

            kalendorius.patvirtinimas.text = timeArray[5];

            a++;

            iy=iy+335;

        }

}

Butt now I don`t understand why I cant remnove childs with this:

function reload_calendorius(){

    while (kalendorius.numChildren > 0) {

        kalendorius.removeChildAt(0);

    }

}

TOPICS
ActionScript

Views

398

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 , Apr 20, 2018 Apr 20, 2018

Hi.

You are adding this kalendorius Movie Clip to the main timeline. So they are children of the main timeline.

My advice is to add the kalendorius Movie Clips to a container and them remove them from the container.

Like this:

function show_time()

{

    // ...

    container.addChild(kalendorius);

    // ...

}

function reload_calendorius()

{

    while (container.numChildren > 0)

    {

        container.removeChildAt(0);

    }

}

Regards,

JC

Votes

Translate

Translate
LEGEND ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

Based on what I see of your code, it will not remove any kalendorius object, though it could empty the last one out of whatever is in it.

To remove them, you likely need to be target them by their name (getChildByName()).

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

? removeChild(data1); removeChild(data2) and etc?

this not working too:)

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
LEGEND ,
Apr 23, 2018 Apr 23, 2018

Copy link to clipboard

Copied

LATEST

Not intending to send you steps back at all, but for your reply (which I missed following up on)... names are Strings, so...

removeChild(getChildByName("data1"));

removeChild(getChildByName("data2"));

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

Hi.

You are adding this kalendorius Movie Clip to the main timeline. So they are children of the main timeline.

My advice is to add the kalendorius Movie Clips to a container and them remove them from the container.

Like this:

function show_time()

{

    // ...

    container.addChild(kalendorius);

    // ...

}

function reload_calendorius()

{

    while (container.numChildren > 0)

    {

        container.removeChildAt(0);

    }

}

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

I dont understand nothing about cointainers and i dont know how to write this script:|

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

The 'container' is just a Movie Clip. It's the instance name I gave to it.

The idea is to add the objects to a single Movie Clip and then later on you remove the chidlren from this single Movie Clip you are using as a container.

Got it?

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

oh now i understand about containers thanks.

its the same thing like:

stage. addChild(xxx); i get shild on stage

container.addChild(xxx); i get childs in container Movie Clip:)

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

Exactly!

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

maby you can help with scrolling?  if i have 7 childs in container but i want tosee just 4 and if i scroll down i an see other 3. Im sure you understand that i want to do

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 ,
Apr 20, 2018 Apr 20, 2018

Copy link to clipboard

Copied

when im adding childs seperatly everything ok. But when i add with looping its difficult for me

function show_time(){

    var i:int;

        for (i = 0; i < dataArray.length; i++){

            var kalendorius:MovieClip = new calendar;              // and if i chanhe this line var kalendorius:calendar = new calendar - i have

                                                                                                                      same result and i dont understand difference.

            kalendorius.name = "data"+i;                                   //if I add without this line i have the same result i just know that

                                                                                                       every child gets name data1; data1; data3; data4 and etc.

            addChild(kalendorius);

            kalendorius.x = ix;

            kalendorius.y = iy;

            timeArray = dataArray.split(" - ");

            kalendorius.menuo.text = timeArray[0];

            kalendorius.diena.text = timeArray[1];

            kalendorius.savaites_diena.text = timeArray[2];

            kalendorius.time1.text = timeArray[3];

            kalendorius.time2.text = timeArray[4];

            kalendorius.patvirtinimas.text = timeArray[5];

            a++;

            iy=iy+335;

        }

}

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