5 Replies Latest reply on Sep 21, 2009 1:14 PM by kglad

    Movie Rollovers

    raslate

      Since I'm pretty new to this, I'm sure this is going to be a silly issue but here goes.  I have the following code in an animation:

       

      this.brakePedalHold_mc.onRollOver = function(){
        if (_root.held == "N") {
         _root.brakePedalHold_mc.gotoAndStop ("releaseRoll");
        }
        if (_root.held == "Y") {
         _root.brakePedalHold_mc.gotoAndStop ("heldRoll");
      }
      }
      this.brakePedalHold_mc.onRollOut = function(){
      if (_root.held == "N") {
        _root.brakePedalHold_mc.gotoAndStop ("released");
      }
      if (_root.held == "Y") {
        _root.brakePedalHold_mc.gotoAndStop ("held");
      }
      }
      this.brakePedalHold_mc.onRelease = function(){
      if (_root.held == "N") {
        _root.held = "Y";
        _root.brakePedalHold_mc.gotoAndStop ("Held");
      } else {
        _root.held = "N";
        _root.brakePedalHold_mc.gotoAndStop ("Released");
      }
      trace (_root.held);
      }

       

       

      The on/off switch works, but the gotoAndStop commands don't.  The file is attached.  Any help would be greatly appreciated!

       

      Rick

        • 1. Re: Movie Rollovers
          kglad Adobe Community Professional & MVP

          try:

           

           

           

          this.brakePedalHold_mc.onRollOver = function(){
            if (_root.held == "N") {
             this.gotoAndStop ("releaseRoll");

          }

          }

          1 person found this helpful
          • 2. Re: Movie Rollovers
            raslate Level 1

            For some reason, this code works when I place it in the context of a larger movie, but doesn't work in a standalone file.  I changed it a little bit so the rollover would work when entering the movie, it now reads:

             

            this.brakePedalHold_mc.onRollOver = function(){
            if ((_root.held == "N") || (_root.held == undefined)) {
              brakePedalHold_mc.gotoAndStop ("releaseRoll");
            }
            if (_root.held == "Y") {
              brakePedalHold_mc.gotoAndStop ("heldRoll");
            }
            }
            this.brakePedalHold_mc.onRollOut = function(){
            if ((_root.held == "N") || (_root.held == undefined)) {
              brakePedalHold_mc.gotoAndStop ("released");
            }
            if (_root.held == "Y") {
              this.gotoAndStop ("held");
            }
            }
            this.brakePedalHold_mc.onRelease = function(){
            if ((_root.held == "N") || (_root.held == undefined)) {
              _root.held = "Y";
              brakePedalHold_mc.gotoAndStop ("Held");
            } else {
              _root.held = "N";
              brakePedalHold_mc.gotoAndStop ("Released");
            }
            trace (_root.held);
            }

             

            I thried substituting "this.gotoAndStop" but it still doesn't work.  Like I said, this code works in another animation I'm using it in.  Sometimes Flash acts so strangely.

            • 3. Re: Movie Rollovers
              kglad Adobe Community Professional & MVP

              are you trying to direct the timeline of the rolled-over/out/clicked movieclip?

               

              and just above your onRollOver code, what's the following trace() function reveal:

               

              trace(this.brakePedalHold_mc);

              • 4. Re: Movie Rollovers
                raslate Level 1

                It returns:

                 

                _level0.brakePedalHold_mc

                 

                which means _root, right?

                 

                The file with the new code is attached.

                • 5. Re: Movie Rollovers
                  kglad Adobe Community Professional & MVP

                  _level0 and _root are the same in your swf that contains the code you've been posting.

                   

                  are you trying to direct the timeline of the rolled-over/out/clicked movieclip?