some if don't work well for some reason which is this if part:
if (mc.main.avatar.contains(my_loader) == true) {
mc.main.avatar.removeChild(my_loader);
}
this is the whole part of if i need it to work:
if (varfromphp !="")
{
if (mc.main.avatar.contains(my_loader) == true) {
mc.main.avatar.removeChild(my_loader);
}
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest(varfromphp + "?n=" + Math.random() ));
mc.main.avatar.addChild(my_loader);
mc.main.avatar.buttonMode = true;
mc.main.avatar.avatar_bg_mc.visible = false;
} else {
mc.main.avatar.avatar_bg_mc.visible = true;
}
this code is in setInterval
so it happens in loop after minute and half and what i want is to remove image the loader loaded everytime this run and add the new one based on the "varfromphp" variable every time it loops.
the problem is when i place the if i mentioned above at the top of loader. the loader dont load and i bet the whole code after inside this if dont happen like making the bg invisible dont happen... and if i added it before addchild the old loaded image is not removed and new one is overlayed on the old one.... and ofc if i placed the if at the bottom logically everything work but the added child will be removed as normal. so what i do???