3 Replies Latest reply: Oct 9, 2013 7:49 PM by Ned Murphy RSS

    Movieclips interacting with other movieclips

    mentalcase129 Community Member

      Okay.  So I've got a movieclip.  Inside that movieclip are a bunch of buttons.  The buttons are programed to turn on and off a bunch of movieclips to work as a form of image gallery.  The movieclips that are being turned on and off are NOT in the movieclip with the buttons.  The buttons are in their own movieclip because they're scrollable with a functioning scrollbar.

      The action script for all of this is in the main timeline where the image movieclips and the movieclip containing the buttons are.

      It's not working.

      My guess would have been that the buttons can't find the corresponding movieclips because they're technically on different timelines.

      The problem with that theory is I tried this once before and it worked.  Before there wasn't a scrollbar involved but I had the buttons in their own movieclip because they were tweened and it worked perfectly fine. 

      Why won't this work?

      Any thoughts?

        • 1. Re: Movieclips interacting with other movieclips
          Ned Murphy CommunityMVP

          The answer will lie in how you coded things.  Show the code for one of the buttons and explain where the button is versus the object it is trying to impact.

          • 2. Re: Movieclips interacting with other movieclips
            mentalcase129 Community Member

            Okay here's the code.  Basically it makes all the movieclip images labeled IMG_number invisible until their corresponding buttons make them visible.  This code is located on the same timeline as the IMG files but the buttons are contained within a movieclip on that timeline.

             

            IMG1_MC.visible=false;

            IMG2_MC.visible=false;

            IMG3_MC.visible=false;

            IMG4_MC.visible=false;

            IMG5_MC.visible=false;

            IMG6_MC.visible=false;

            IMG7_MC.visible=false;

             

            img1_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

             

            function fl_MouseClickHandler(event:MouseEvent):void

            {

                IMG1_MC.visible=true;

            IMG2_MC.visible=false;

            IMG3_MC.visible=false;

            IMG4_MC.visible=false;

            IMG5_MC.visible=false;

            IMG6_MC.visible=false;

            IMG7_MC.visible=false;

            }

             

            img6_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler2);

             

            function fl_MouseClickHandler2(event:MouseEvent):void

            {

                IMG1_MC.visible=false;

            IMG2_MC.visible=false;

            IMG3_MC.visible=false;

            IMG4_MC.visible=false;

            IMG5_MC.visible=false;

            IMG6_MC.visible=true;

            IMG7_MC.visible=false;

            }

             

            img2_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler8);

             

            function fl_MouseClickHandler8(event:MouseEvent):void

            {

                IMG1_MC.visible=false;

            IMG2_MC.visible=true;

            IMG3_MC.visible=false;

            IMG4_MC.visible=false;

            IMG5_MC.visible=false;

            IMG6_MC.visible=false;

            IMG7_MC.visible=false;

            }

             

            img3_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler3);

             

            function fl_MouseClickHandler3(event:MouseEvent):void

            {

                IMG1_MC.visible=false;

            IMG2_MC.visible=false;

            IMG3_MC.visible=true;

            IMG4_MC.visible=false;

            IMG5_MC.visible=false;

            IMG6_MC.visible=false;

            IMG7_MC.visible=false;

            }

             

            img4_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler4);

             

            function fl_MouseClickHandler4(event:MouseEvent):void

            {

                IMG1_MC.visible=false;

            IMG2_MC.visible=false;

            IMG3_MC.visible=false;

            IMG4_MC.visible=true;

            IMG5_MC.visible=false;

            IMG6_MC.visible=false;

            IMG7_MC.visible=false;

            }

             

            img5_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler5);

             

            function fl_MouseClickHandler5(event:MouseEvent):void

            {

                IMG1_MC.visible=false;

            IMG2_MC.visible=false;

            IMG3_MC.visible=false;

            IMG4_MC.visible=false;

            IMG5_MC.visible=true;

            IMG6_MC.visible=false;

            IMG7_MC.visible=false;

            }

             

            img7_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler6);

             

            function fl_MouseClickHandler6(event:MouseEvent):void

            {

                IMG1_MC.visible=false;

            IMG2_MC.visible=false;

            IMG3_MC.visible=false;

            IMG4_MC.visible=false;

            IMG5_MC.visible=false;

            IMG6_MC.visible=false;

            IMG7_MC.visible=true;

            }

            • 3. Re: Movieclips interacting with other movieclips
              Ned Murphy CommunityMVP

              You explained that the buttons are inside a movieclip.  You need to target the buttons via targeting that movieclip...  If that movieclip happens to be named btnMC for instance you need to use....

               

              btnMC.img1_MC.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);