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);
}
}
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
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()).
Copy link to clipboard
Copied
? removeChild(data1); removeChild(data2) and etc?
this not working too:)
Copy link to clipboard
Copied
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"));
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
Copy link to clipboard
Copied
I dont understand nothing about cointainers and i dont know how to write this script:|
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?
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:)
Copy link to clipboard
Copied
Exactly!
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
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;
}
}