RemoveChild on buttons to remove movieclips
Hello,
I have been going crazy trying to make my little flash site to work. I have used the removeChild script to remove movieclips on the stage when you click a button. When I test it the first button clicked loads the appropriate movieclip and unloads any movie that was playing (in this case it is the home content) but then none of the other buttons work after including the first button that previously worked. Its like the removechild removes it completely. My script is below and any help woul;d be so very much appreciated:
b1.addEventListener(MouseEvent.CLICK, playhomebutton);
function playhomebutton(e: MouseEvent): void {
homecontent.play();
}
b1.addEventListener(MouseEvent.CLICK, removeGallery1);
function removeGallery1(event:MouseEvent):void{
if (gallery.parent)
gallery.parent.removeChild(gallery);
}
b1.addEventListener(MouseEvent.CLICK, removevideo1);
function removevideo1(event:MouseEvent):void{
if (video.parent)
video.parent.removeChild(video);
}
b1.addEventListener(MouseEvent.CLICK, removematerials1);
function removematerials1(event:MouseEvent):void{
if (materialsmovie.parent)
materialsmovie.parent.removeChild(materialsmovie);
}
b2.addEventListener(MouseEvent.CLICK, playgallerybutton);
function playgallerybutton(e: MouseEvent): void {
gallery.play();
}
b2.addEventListener(MouseEvent.CLICK, removeHome);
function removeHome(event:MouseEvent):void{
if (homecontent.parent)
homecontent.parent.removeChild(homecontent);
}
b2.addEventListener(MouseEvent.CLICK, removevideo2);
function removevideo2(event:MouseEvent):void{
if (video.parent)
video.parent.removeChild(video);
}
b2.addEventListener(MouseEvent.CLICK, removematerials2);
function removematerials2(event:MouseEvent):void{
if (materialsmovie.parent)
materialsmovie.parent.removeChild(materialsmovie);
}
b3.addEventListener(MouseEvent.CLICK, playvideobutton);
function playvideobutton(e: MouseEvent): void {
video.play();
}
b3.addEventListener(MouseEvent.CLICK, removeHome3);
function removeHome3(event:MouseEvent):void{
if (homecontent.parent)
homecontent.parent.removeChild(homecontent);
}
b3.addEventListener(MouseEvent.CLICK, removeGallery3);
function removeGallery3(event:MouseEvent):void{
if (gallery.parent)
gallery.parent.removeChild(gallery);
}
b3.addEventListener(MouseEvent.CLICK, removematerials3);
function removematerials3(event:MouseEvent):void{
if (materialsmovie.parent)
materialsmovie.parent.removeChild(materialsmovie);
}
b5.addEventListener(MouseEvent.CLICK, playmaterialbutton);
function playmaterialbutton(e: MouseEvent): void {
materialsmovie.play();
}
b5.addEventListener(MouseEvent.CLICK, removeHome5);
function removeHome5(event:MouseEvent):void{
if (homecontent.parent)
homecontent.parent.removeChild(homecontent);
}
b5.addEventListener(MouseEvent.CLICK, removeGallery5);
function removeGallery5(event:MouseEvent):void{
if (gallery.parent)
gallery.parent.removeChild(gallery);
}
b5.addEventListener(MouseEvent.CLICK, removevideo5);
function removevideo5(event:MouseEvent):void{
if (video.parent)
video.parent.removeChild(video);
}
