6 Replies Latest reply on Sep 14, 2007 3:44 PM by kglad

    Nested Movie Clip

    budd101
      If I have a nested movie clip, how can I make the parent timeline switch over to the child timeline?

      I have created a learning interaction where the parent timeline contains a set of math problems and the child timeline contains a clock. When the student is finished with the math problems in the parent timeline a button will appear, named stop_btn. I want this stop_btn, when it is clicked, to activate the actionscript in the child timeline.

      Thanks,
      budd101
        • 1. Re: Nested Movie Clip
          kglad Adobe Community Professional & MVP
          is this as2 or as3? what are the instance names of the parent and child movieclips and paste the clock code using the attach code option?
          • 2. Re: Nested Movie Clip
            budd101 Level 1
            This is as2.

            The child movieclip is timer_mc, the parent movie clip is the root timeline, so I do not have an instance name for it.

            A piece of code from the parent movie clip that will stop the child movie clip timer_mc if the stop_btn is clicked is:

            stop_btn.onRelease = function() {
            timer_mc.stop();
            };

            Perhaps I need a piece of code to replace the stop(); after timer_mc that activates the timeline in the child movie clip.

            The clock I created in the child movie clip timer_mc is simply a graphic with numbers that progress through the timeline. Since it is at 10 frames per second, each number occupies 10 frames. If the student completes the learning interaction in under twenty seconds, I want the stop_btn to activate the actionscript in frame 1 of the child movie clip timer_mc that controls frames 1-200 in timer_mc. If the learning interaction is completed between 20 and 40 seconds, than the stop_btn will activate the actionscript located at frame 201 that controls frames 201-400.

            Thanks,
            budd101
            • 3. Re: Nested Movie Clip
              kglad Adobe Community Professional & MVP
              you can control the execution of code in any frame (OTHER than 1) by directing timer_mc to that frame. because frame in code 1 is executed as soon as timer_mc is instantiated, you can't control whether that code executes or not except by controlling whether timer_mc in instantiated or not. of course, that's not satifactory.

              you should place the code in frame 1 of timer_mc in a function. give that function a name and then you can control the execution of that code independent of timer_mc's instantiation.
              • 4. Re: Nested Movie Clip
                budd101 Level 1
                I have a function on the first frame of the child movie clip timer_mc:

                stop_btn.onRelease = function (){
                gotoAndPlay(171);
                };

                The stop_btn resides in the parent movie clip as does frame 171. How can I make the clicking of the stop_btn in the parent movie clip activate this code in the child movie clip timer_mc to send the movie to frame 171 in the parent movie clip?

                Thanks,
                budd101
                • 5. Re: Nested Movie Clip
                  budd101 Level 1
                  Okay, I got it. I put the function in the child movie clip timer_mc using this actionscript:

                  _root.stop_btn.onRelease = function (){
                  _root.gotoAndPlay(171);
                  };

                  Because the stop_btn only appears when the student is finished with the ten problems, I put this code in every frame of the child movie clip. Therefore when the stop_btn appears in the parent movie clip, there is new actionscript in the child movie clip to activate.

                  Thanks for your help, when you mentioned entering a function in the child movie clip, it made me realize I was on the right track and had to fix the code accordingly.

                  budd101
                  • 6. Re: Nested Movie Clip
                    kglad Adobe Community Professional & MVP
                    you're welcome.