Skip to main content
Inspiring
December 24, 2007
Answered

Key.removeListener(keyListener1);

  • December 24, 2007
  • 3 replies
  • 557 views
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
This topic has been closed for replies.
Correct answer budd101
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.

3 replies

kglad
Community Expert
Community Expert
December 25, 2007
you're welcome.
kglad
Community Expert
Community Expert
December 24, 2007
then assign the listener in a function. call the function when you want to activate the listener.
budd101Author
Inspiring
December 24, 2007
Is there a function that allows me to call a function when another movie clip enters a specific frame?
kglad
Community Expert
Community Expert
December 24, 2007
add your remove listener statement (using the correct path to the listener object) to the frame in your "other movie clip".
budd101Author
Inspiring
December 24, 2007
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.
kglad
Community Expert
Community Expert
December 24, 2007
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: