2 Replies Latest reply on Dec 12, 2007 8:24 AM by absurd29

    Accessing buttons inside frame a movieClip

    absurd29
      I understand that putting all code on the main timeline of the main movie is the best way to do things; A button in my main movie allows users to view a movieClip – this MC contains 2 frames: in frame 1 a ‘continue’ button takes users to frame 2 of same movieClip – frame 2 has a close button – this is the one that doesn’t work. It seems that anything after the initial frame isn’t recognised when the code is on main (root) timeline. This can’t be right?

      For clarification, this is my code:

      myMovieClip._visible = false;
      /////////////////FUNCTIONS//////////////////
      function fViewInfo() {
      myMovieClip._visible = true;
      }
      function clearAll() {
      _root.myMovieClip.gotoAndStop("frame1");
      _root.myMovieClip._visible = false;
      }
      /////////////////BUTTON ACTIONS//////////////
      viewInfo.onRelease = fViewInfo;
      myMovieClip.continue_btn.onRelease = function() {
      myMovieClip.gotoAndStop("frame2");
      };
      myMovieClip.close_btn.onRelease = clearAll;
        • 1. Accessing buttons inside frame a movieClip
          WhiteRau
          couple of things i'd check:

          1) in myMovieClip, is there only ONE item per layer? two items = bad juju, no workey.

          2) make sure you have a hit area defined for the button. seems dumb, but let's be sure... never know...

          3) realize that once you move off of frame 1, there is no code working. so park some code on frame 2 that will handle what you want to happen. although, i'd handle it a bit differently by altering the button itself to have 2 frames (minimum) that act like a toggle from 'continue' to 'close'. much better that way and you can still handle all your code in frame 1.

          the code i'd put on the button (a movie clip) would look like this (2 frames total):

          on frame 1 (the one that says 'continue'):

          stop();
          this.onRelease = function()
          {
          doSomeStuff(); // this actually does some stuff, like play or some other function
          gotoAndStop(2); // go to the frame that has 'close' on it
          }

          on frame 2 (the one that says 'close):

          stop();
          this.onRelease = function()
          {
          doSomeOtherStuff(); // this actually does some stuff, like play or some other function
          //gotoAndStop(1); // optional return to frame 1 if you want to make a toggle behaviour...
          }

          i hope this helps. if not... um... try to explain in other words and i'll try again.

          NB :)
          • 2. Re: Accessing buttons inside frame a movieClip
            absurd29 Level 1
            thanks for taking the time to input - but I really wanted to know how to keep all the code on the root timeline - people tell me that's best practice. I guess it just doesn't work in all cases.