2 Replies Latest reply on Apr 11, 2011 2:54 AM by halder492

    need help: movie clip onrelease function execution error

    halder492

      Hi I am

      new to this forum. I am having a typical

      error in my movie clip. The code is working just fine. The effects are just what I needed. I have a set of 24 buttons, executing 24 URLs when clicked. buttons are responding on rollover, onRollout and onRelease states. But the problem is when I click the butoons randomly and very fast, multiple buttons remins in onRelease state (as if more than one button has been selected). I do not undetastand wheather this a problem with my coding or problem with my settinf in flash or a bug in flash itself (i'm too small to detect a bug in flash though!!). My setting are: actionscript 1. fps 30.

       

      and the code is:

       

      stop();

      this.onRollOver = function() {
      if (this._name != _global.sub_menuname) {
        this.gotoAndStop(2);
        this.btnbg_mc.gotoAndPlay(2);
      }
      };

       


      this.onRollOut = function() {
      if (this._name != _global.sub_menuname) {
        this.gotoAndStop(1);
        this.btnbg_mc.gotoAndPlay(16);
      }
      };


      this.onRelease = function() {
      _global.previous_submenuname = _global.sub_menuname;
      P_sub_menu = eval("_level0.instance26."+_global.previous_submenuname);
      sub_menu_names= "_level0.instance26.instance";
      if (this._name != _global.sub_menuname) {
           P_sub_menu.gotoAndStop(1);                        ////////My problem centers around thse two lines
          P_sub_menu.btnbg_mc.gotoAndStop(1);         ///////// as when clicked randomly and very fast , previously clicked buttons are not getting refreshed.
          this.gotoAndStop(2);
        this.btnbg_mc.gotoAndStop(13);
        //getURL("javascript:frmFlash('PE_AutoComp');");
        _global.sub_menuname = this._name;
            trace(this);
      }
      };

       

       

      Any and all help will be appreciated. Thanks in advance.  

        • 1. Re: need help: movie clip onrelease function execution error
          Rothrock Level 5

          My guess is that you need to add and onReleaseOutside event handler. If you click the mouse down on a button and then move to the outside of the the button and release there won't be any event handled. You can do it easily like this:

           

           

          this.onRelease=this.onReleaseOutside=function()[....whatever you already have.

           

          There is also a slightly better way to do what you are doing here.

           

          this.onRollOver = handleRollOver;

          this.onRollOut = handleRollOut;

           

          function handleRollOut() {
          if (this._name != _global.sub_menuname) {
            this.gotoAndStop(1);
            this.btnbg_mc.gotoAndPlay(16);
          }
          };

           

          function handleRollOver() {

          if (this._name != _global.sub_menuname) {
            this.gotoAndStop(2);
            this.btnbg_mc.gotoAndPlay(2);
          }
          };

           

          and so on. It is just a little trick that doesn't make much difference now, but down the line will help.

           

          Also it isn't generally a good idea to _global objects. I'm guessing (from the this) that you are putting this code on the timeline for your buttons? it would be better to put your code on the main timeline. That way you don't have to go looking for the code in all sorts of different places....

           

           

          • 2. Re: need help: movie clip onrelease function execution error
            halder492 Level 1

            Hi Rothrock,

            Thanks a lot for your advice. It worked. I just missed the situation waht

            can happen. thanks again.

             

            --rupam.