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

RemoveChild on buttons to remove movieclips

New Here ,
Dec 12, 2015 Dec 12, 2015

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);

}

TOPICS
ActionScript
3.0K
Translate
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 , Dec 14, 2015 Dec 14, 2015

here's what you should have:  http://www.kglad.com/Files/forums/test5.fla

compare it to what you do have.

Translate
New Here ,
Dec 13, 2015 Dec 13, 2015

If you enter into the movieclips 'b1, b2, b3, b4, b5' the time line has the two labels over/out as in the screenshot. Was that not how I was suppose to do it? (the actions are just stop();)

Capture.JPG

Translate
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 ,
Dec 13, 2015 Dec 13, 2015

that ss looks correct, but i'm not sure you should have 5 buttons.  that's new.

and what are those error messages referencing about scenes over and scenes out?

Translate
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
New Here ,
Dec 13, 2015 Dec 13, 2015

Sorry, meant to mention that. I added the fifth button which has the contact information.

I have no idea what the error message is referring to about scenes over and scenes out. Could it be that I need to add a dot syntax because the labels can't be found in the scene but are actually found inside the movieclip?

like (b2.'out') ?

Translate
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 ,
Dec 13, 2015 Dec 13, 2015

no, i already referenced the movieclip button timelines.

when do you see that error message? after clicking one of your buttons?

Translate
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
New Here ,
Dec 13, 2015 Dec 13, 2015

yes, each click generates a new error.

Translate
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 ,
Dec 14, 2015 Dec 14, 2015

here's what you should have:  http://www.kglad.com/Files/forums/test5.fla

compare it to what you do have.

Translate
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
New Here ,
Dec 14, 2015 Dec 14, 2015

This is fantastic! I'll work on it hopefully tomorrow.

Translate
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 ,
Dec 14, 2015 Dec 14, 2015

you're welcome.

Translate
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
New Here ,
Dec 14, 2015 Dec 14, 2015

Works! Thanks again for all of your help.

Translate
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 ,
Dec 15, 2015 Dec 15, 2015

you're welcome, again.

did you figure out what was wrong in your file?  if so, what was that?

Translate
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
New Here ,
Dec 17, 2015 Dec 17, 2015
LATEST

No, I didn't figure it out. I just started again and pulled over everything into your file. I have no idea. Just glad it works! Happy Holidays.

Translate
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