3 Replies Latest reply on Nov 11, 2009 4:29 PM by rowancavanagh

    Button no longer works when inside a Movie Clip?

    rowancavanagh

      Again I turn to the almighty Adobe forums for help...

      So basically, I've had this problem for over a day now, and I've posted on Experts-Exchange.com... to no avail really.

       

      So here we go:

       

      I have a button in a Flash project I've made. It's used to jump to another place on the root timeline, labelled "Why". It used to work perfectly.

      I have now placed the button inside a movie clip (it has to be in an animated sequence), but now it no longer works. It appears to work fine, the rollover state works and all. But when clicked it does nothing.

       

      The code I use to work the buttons goes on the main timeline, the code for this button is:
      mc_anim_backdrops_menu.btn_subsection1.onRelease = function() {
      gotoAndStop("Why");
      _global.swfloaded = "";
      }


      Why does it no longer work? and what can I do to fix it?

       

      The question is posted here over at Experts Exchange - http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Act ionScript/Q_24888850.html

       

      what we've tried there is tracing the problem. The code seems to be pointing to the right place, but none of the actual function works.. as you'll be able to see if you open up the attached file (and change it's extension from .txt to .fla to get it working)

       

      So would someone be able to open it up, have a look and tell me what's wrong? Because I'm stumped. And frustrated.

        • 1. Re: Button no longer works when inside a Movie Clip?
          Rothrock Level 5

          My guess is that you have a scope problem. By putting the button inside a movieclip you have made the buttons scope the same as that clip.

           

          So if you add a trace inside the release event handler, what do you get?

           

          trace("My current scope is: "+this);

           

          I'm guessing it is "_level0.mc_anim_backdrops_menu," right?

           

          So since you are using the global function of gotoAndPlay() it is looking for that label in the current timeline and not finding it.

           

          You should probably use the MovieClip method and specifiy which timeline it should look in.

           

          _root.gotoAndPlay("Why");

          _level0.gotoAndPlay("Why")

          _parent.gotoAndPlay("Why");

           

          both would probably work. I would never use the first two, other than to make sure that there wasn't something else going on...

          1 person found this helpful
          • 2. Re: Button no longer works when inside a Movie Clip?
            rowancavanagh Level 1

            That's the problem, nothing in the button seems to work

             

            Here's the code I've got on the main timeline (now):

            trace(mc_anim_backdrops_menu.btn_subsection1);

             

            mc_anim_backdrops_menu.btn_subsection1.onRelease = function() {
            trace("if you can read this being traced, the function is running");
            _parent.gotoAndPlay("Why");
            _global.swfloaded = "";
            }

             

            that first trace there brings this back:

            _level0.mc_anim_backdrops_menu.btn_subsection1

             

            but when you click the button, nothing of what it says to do above happens.

             

            and apologies if ive done something wrong with what youve said, but i wouldnt consider myself the coding type..

            • 3. Re: Button no longer works when inside a Movie Clip?
              rowancavanagh Level 1

              sorry for the bother but this has just been fixed over at the other site I mentioned.

               

              What I did in the end was put the buttons in their own movie clips, and put this code on those movie clips:

              onClipEvent (mouseDown) {   
                    if (this.hitTest(_root._xmouse, _root._ymouse, true) && hitState != "over") {

                           _root.gotoAndStop("Why");
                    }   
              }