8 Replies Latest reply on Dec 24, 2007 10:32 PM by kglad

    Key.removeListener(keyListener1);

    budd101
      I have two Movie Clips nested in a parent Movie Clip. I want to remove a key listener in one of the nested movie clips when the other nested movie clip reaches a certain point in its timeline. In other words I want the key listener to function normally until the user reaches a certain point in the other movie clip. At that point I want to remove the key listener in the other nested movie clip, thus disabling the function the key listener initiates. How do I do this?

      Thank you
        • 1. Re: Key.removeListener(keyListener1);
          kglad Adobe Community Professional & MVP
          add your remove listener statement (using the correct path to the listener object) to the frame in your "other movie clip".
          • 2. Re: Key.removeListener(keyListener1);
            budd101 Level 1
            Yes, I have tried that. From the nested movie clip "clickhere_mc" I put in the code

            _root.clip1_mc.Key.removeListener(keyListener1);

            to turn off the keyListener in the nested movie clip "clip1_mc".

            Here is the problem: "clip1_mc" is accessed via a button, when the button is clicked, all of the keyListeners in "clip1_mc" are activated. "clip1_mc" has input text, so when the input text loses focus, I remove all of the keyListeners using onKillFocus. In other words, when the user enters "clip_mc" all of the keyListeners are loaded, when he leaves, all of the keyListeners are removed. The user can enter and exit "clip1_mc" repeatedly, sometimes before and sometimes after accessing "clickhere_mc".

            There is one keyListener in "clip1_mc" that I want to disable after "clickhere_mc" has reached a certain spot on its timeline. I figure I need to put actionscript in "clip_mc" that will know that "clickhere_mc" has reached this point. Maybe somekind of "if" statement.

            Hope this makes sense, thank you for your help.
            • 3. Re: Key.removeListener(keyListener1);
              kglad Adobe Community Professional & MVP
              keyListener1 is not defined in your nested movieclip is it? (use trace(keyListener1) to confirm.) you need to use the correct path to it. try:

              • 4. Re: Key.removeListener(keyListener1);
                budd101 Level 1
                I used trace(_root.clip1_mc.keyListener) and I got the output [object Object}. I used Key.removeListener(_root.clip1_mc.keyListener1); but it did not work.

                I think it is a matter of timing. The keyListener in clip1_mc is activated after the removeListener in clickhere_mc, so the removeListener has no effect. I need away to put the removeListener in clip1_mc where it will only be activated after clickhere_mc has run past a certain point in its timeline.

                Thanks again
                • 5. Re: Key.removeListener(keyListener1);
                  kglad Adobe Community Professional & MVP
                  then assign the listener in a function. call the function when you want to activate the listener.
                  • 6. Re: Key.removeListener(keyListener1);
                    budd101 Level 1
                    Is there a function that allows me to call a function when another movie clip enters a specific frame?
                    • 7. Re: Key.removeListener(keyListener1);
                      budd101 Level 1
                      Never mind, I figured something out.

                      In clickhere_mc, when it reaches a specific point in the timeline I wrote:

                      _root.clip1_mc.answer1_txt.onSetFocus = function() {
                      _root.clip1_mc.gotoAndPlay(37);}

                      Because answer1_txt is set as the focus anytime clip1_mc runs, this event will trigger the actionscript.

                      On frame 36 of clip_mc I wrote
                      stop();

                      On frame 37 of clip_mc I wrote
                      stop();
                      Key.removeListener(keyListener1);

                      This way the removeListener is only activated when clickhere_mc reaches a specific point in the timeline.

                      Thank you for your help.
                      • 8. Re: Key.removeListener(keyListener1);
                        kglad Adobe Community Professional & MVP
                        you're welcome.