2 Replies Latest reply on Aug 7, 2007 9:43 PM by Rothrock

    nagging variable problem

    posterboy
      i have declared three variables depending on which button you click...

      // this is on frame 48, variables in bold...

      btn_group_mc.landing_btn.onRelease = function(){
      btn_group_mc.rollout_btn.enabled=true;
      gotoAndPlay(49);
      var landing;
      }

      btn_group_mc.omdp_btn.onRelease = function(){
      btn_group_mc.rollout_btn.enabled=true;
      gotoAndPlay(49);
      var omdp;
      }

      btn_group_mc.rollover_btn.onRelease = function(){
      btn_group_mc.rollout_btn.enabled=true;
      gotoAndPlay(49);
      var rollover;
      }

      // then on frame 87 the AS tells it to go to the root timeline...
      // however, no matter which button i click, it only plays frame 2 on the root timeline
      //any ideas? i'm pulling what little hair i have left out!

      if ("landing") {
      _root.gotoAndPlay(2);
      } else if ("omdp") {
      _root.gotoAndPlay(3);
      } else if ("rollover") {
      _root.gotoAndPlay(4);
      }
        • 1. nagging variable problem
          rturknett
          The statement if("landing") will always result in true. Also, you have declared several variables but you did not assign them any value. I suggest you review the documentation on variables and how they work. Try the following (corrections in bold):

          // on frame 48

          var buttonClicked;

          btn_group_mc.landing_btn.onRelease = function(){
          btn_group_mc.rollout_btn.enabled=true;
          gotoAndPlay(49);
          var buttonClicked="landing";
          }

          btn_group_mc.omdp_btn.onRelease = function(){
          btn_group_mc.rollout_btn.enabled=true;
          gotoAndPlay(49);
          buttonClicked="omdp";
          }

          btn_group_mc.rollover_btn.onRelease = function(){
          btn_group_mc.rollout_btn.enabled=true;
          gotoAndPlay(49);
          buttonClicked="rollover";
          }

          // then on frame 87 the AS tells it to go to the root timeline...
          // however, no matter which button i click, it only plays frame 2 on the root timeline
          //any ideas? i'm pulling what little hair i have left out!

          if ( buttonClicked=="landing") {
          _root.gotoAndPlay(2);
          } else if ( buttonClicked=="omdp") {
          _root.gotoAndPlay(3);
          } else if ( buttonClicked=="rollover") {
          _root.gotoAndPlay(4);
          }

          Cheers,

          Rob
          • 2. Re: nagging variable problem
            Rothrock Level 5
            You could rely on just the variable declarations, but you will need to drop the quotes from your conditionals. None of the variables you created were assigned a string value nor are you actually comparing the string to anything!

            But to me it seems a bit sloppy and prone to causing undesired behaviour. Personally I would define all of those to false and then in the release event handlers assign it to true.