TIA, 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. code: outerMC.innerMC1 = function (){ this._parent.nextFrame();} outerMC.innerMC2 = function (){ this._parent.prevFrame();}
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: outerMC.innerMC1.onPress = function (){ this._parent.nextFrame();} outerMC.innerMC2.onPress = function (){ this._parent.prevFrame();}
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.
Don't see what you're looking for? Try a search.
|