3 Replies Latest reply on Jan 24, 2007 6:42 PM by kglad

    mc out of scope event handler


      I have two event handlers on the Main Timeline.(attached at the bottom)
      Also on the Main Timeline, there is an outerMC(2frames), which contains, a innerMC1(frame1) and an innerMC2(frame2).

      With the event handler on the Main Timeline, when the nested movieclip is no longer under the playhead, the event handler goes out of scope and stays out of scope, even if the playhead is returned to the firstframe, via the simple on() {prevFrame();} button.

      This seems to be very odd, a parent function, does not go out of scope, when the playhead moves within a nested movieclip.

      How can I have centralized event handler code on the Main Timeline and be able to address nested movieclips regardless if that movieclip exists on the first frame or not.

        • 1. Re: mc out of scope event handler
          kglad Adobe Community Professional & MVP
          you can't.

          you can put each of your functions (they are functions, not event handlers) inside an initialize function. and call an initialize function when the appropriate objects exist.
          • 2. Re: mc out of scope event handler
            heavyp Level 1
            Thank you for the correction. I also found a small mention in Colin Moock's AS Flash MX book about the scope and the existance of the object.

            So might I use a function call to the Main Timeline, from the frame where the nested mc exists.
            frame1: _root.myFunctionWhichContainsMyEventHandlerMethod1().
            frame2: _root.myFunctionWhichContainsMyEventHandlerMethod2().
            The code can be centralized and use this, event handler method. It works, but is there a better way?

            The corrected code:
            • 3. Re: mc out of scope event handler
              kglad Adobe Community Professional & MVP
              well, there is a better way. and that's to use object oriented programming.

              you would create a class the defines all the methods and properties of your object and then when an member of your class is instantiated (created), your class definitions would be retrieved.