8 Replies Latest reply on Oct 2, 2007 5:37 PM by Mario Vieira

    Removing the onRelease function of a movieClip

    alexhobday Level 1
      I have a movie clip on stage and am giving it the functionality of a button via actionscript:

      col1_mc.onRelease = function() {
      _parent.loadPlan(this, this._parent)
      };

      The function loadPlan() tells the calling movieClip to play. On frame 10 of the calling movie clip are further movie clips with their own functionality, but when I go to click on one of these the parent clip's function is triggered.

      How can i overcome this problem?

      Thanks
        • 1. Re: Removing the onRelease function of a movieClip
          clbeech Level 3
          you can set the 'enabled' property of the clip to false:

          col1_mc.onRelease = function() {
          _parent.loadPlan(this, this._parent);
          this.enabled = false;
          };

          although if you return to the clip at a different time or state you may need to set the property back to true.

          it is also possible that this will disable other child clips, which may require you to develop a conditional system to disable the button clip.
          • 2. Re: Removing the onRelease function of a movieClip
            alexhobday Level 1
            yes I just tried that but it does as you say, it disables child clips.

            What kind of conditional system would you think?
            • 3. Re: Removing the onRelease function of a movieClip
              alexhobday Level 1
              i tried changing the name of the parent clip but that does not work either
              • 4. Re: Removing the onRelease function of a movieClip
                clbeech Level 3
                well, I'm kind of assuming you've got some sort of menu here. so while the menu is open, you need to tell the parent not to run the loadPlan function right?

                I don't know the whole scope of your system, so I'm guessing here, but you will need to set up a variable that you can use to determine weather or not the function should be called. set up a boolean var in the clips timeline previous to the onRelease ...

                var dothis:Boolean = true;

                ... then in the clips on handler set it opposite when trigger the first time ...

                col1_mc.onRelease = function() {
                if(dothis) {
                _parent.loadPlan(this, this._parent);
                dothis = false;
                }
                };

                ... now you'll have to decide 'when' you need to set it back to true again.

                However, having said all of this, it still may not work. sometimes when 'buttons' (clips as buttons also) are placed within one another, the 'top' layer's on handler will be the only one active, and the other 'buttons' won't function being 'covered up' by the parent layer. If this is the case you may need to contrive a different system. Or even just change the handler to an onRollOver possibly, but I don't have enough info on the structure to say for sure.

                • 5. Re: Removing the onRelease function of a movieClip
                  kglad Adobe Community Professional & MVP
                  you have a larger problem: in as2, mouse handlers defined for a parent will intercept mouse events so no child can respond. to remedy, you can start a loop when the parent is pressed and repeatedly check for a hitTest between the mouse and the child movieclip. terminate your loop when no longer needed.
                  • 6. Re: Removing the onRelease function of a movieClip
                    alexhobday Level 1
                    Sorry I should have explained the file better. However I think you're last paragraph is right in this case, the parent clips onRelease is hiding all the child clips functionality.

                    I will have to place the child clips on the same movie. Just seems odd there is no workabout for it in Flash.

                    I really appreciate your help on this.
                    • 7. Re: Removing the onRelease function of a movieClip
                      alexhobday Level 1
                      Ahh, I remember reading that somewhere now. However the parent still seems to be masking the child clips. I'll try it again though, otherwise i'll have to pull them on to the same timeline.
                      • 8. Re: Removing the onRelease function of a movieClip
                        Mario Vieira Level 1
                        I'm not in the loop, but by the sound of it you'll have the onRelease event you're calling in the same level than the other mcs...

                        eg:
                        col1_mc.DUMM_mc.onRelease, rather than: col1_mc.onRelease

                        haven't followed the issue, just q quick guess...