Removing Movie Clip using RemoveChild Help
hi, im new forum, , new actionscript 3.
i'm wondering, how can remove movieclip doesnt stack when click button.
btn 1 opens movieclip addchild
btn 2 opens 2nd movieclip stacks in front , , first movieclip isnt removed
as linkage of movieclip can bring stage.
my code
thumbnail1.addeventlistener(mouseevent.click ,mythumb1);
function mythumb1(evt:mouseevent):void
{
var mymc:hover1 = new hover1();
container.addchild(mymc);
if(contains(mymc))
{
container.removechild(mymc)
}
}
thumbnail2.addeventlistener(mouseevent.click ,mythumb2);
function mythumb2(evt:mouseevent):void
{
var mymc2:hover2 = new hover2();
container.addchild(mymc2);
}
by declaring vars inside function, remove ability target them directly name outside of function. 1 way deal declare mymc1 , mymc2 outside of functions every function can target them.
an alternative approach empty container out before adding children using removechildat() method (you need check there children within remove beforehand)
for code show, mythumb1 function isn't going since adding mymc1 , removing after
More discussions in ActionScript 3
adobe
Comments
Post a Comment