7 Replies Latest reply on May 10, 2006 4:46 AM by chris_knows

    Buttons...

    chris_knows
      I've recently purchased Flash Professional 8.0 and I'm working on a project, but I need to make it so that a button (gas pedal) is clicked and a movie clip of the RPM needle moving starts, and when the button is released the needle slowly goes down...Could someone explain this to a total noobie on Flash? Thanks in advance for any help.
        • 1. Re: Buttons...
          TiJayOldroyd
          this.gaspedal.on (press) = function () {
          gotoAndPlay("RPMAccelerate");
          }

          this.gaspedal.on (release) = function () {
          gotoAndPlay("RPMDecelerate");
          }

          of course, change the symbol names to whatever you called them. This is providing you have already created the motion tweens for the needle moving, if not, that is a totally different story, let me know if you need a hand with that.

          Good Luck

          TiJay
          • 2. Re: Buttons...
            chris_knows Level 1
            Thanks for that, but I think I was misunderstanding what I have to make. I thought I could make it so that there's just 2 layers (button and movie clip) and there was a code like this or something:

            (For the properties of the button)

            on (press) }
            rpm_needle.play;
            }

            on (release) }
            rpm_needle.reverse;
            }

            I know I'm a total noob at this lol.
            • 3. Re: Buttons...
              jak418
              that would work, except there is no function called "reverse"
              also play needs "()"
              what you can do is something like this

              (in the button instance)

              on (press) }
              _root.playing = true;
              }

              on (release) }
              _root.playing = false;
              }

              (in the main actions)

              onEnterFrame = function() {
              if (_root.playing == true) {
              rpmneedle.gotoAndStop(rpmneedle._currentframe+1);
              } else if (_root.playing == false) {
              rpmneedle.gotoAndStop(rpmneedle._currentframe-1);
              }
              }


              that should work
              hope that fixed your problem
              • 4. Re: Buttons...
                chris_knows Level 1
                quote:

                Originally posted by: jak418
                on (press) }
                _root.playing = true;
                }

                on (release) }
                _root.playing = false;
                }
                Thanks for the help, but when I enter that in the actions - button text field, I get 3 errors:



                **Error** Scene=Scene 1, layer=gaspedal, frame=1:Line 1: '{' expected
                on (press) }

                **Error** Scene=Scene 1, layer=gaspedal, frame=1:Line 2: Statement must appear within on handler
                _root.playing = true;

                **Error** Scene=Scene 1, layer=gaspedal, frame=1:Line 3: Unexpected '}' encountered
                }

                Total ActionScript Errors: 3 Reported Errors: 3
                • 5. Re: Buttons...
                  TiJayOldroyd Level 1
                  Oops - even the best of us make mistakes...this is what he meant:

                  on (press) {
                  _root.playing = true;
                  }

                  on (release) {
                  _root.playing = false;
                  }

                  (in the main actions)

                  onEnterFrame = function() {
                  if (_root.playing == true) {
                  rpmneedle.gotoAndStop(rpmneedle._currentframe+1);
                  } else if (_root.playing == false) {
                  rpmneedle.gotoAndStop(rpmneedle._currentframe-1);
                  }
                  }

                  (he accidentally put a } instead of a {...Jak - you are making TiJay mistakes now...watch it...)
                  • 6. Re: Buttons...
                    chris_knows Level 1
                    Thanks, that should work, but where do I put each one?...Does this:
                    on (press) {
                    _root.playing = true;
                    }

                    on (release) {
                    _root.playing = false;
                    }

                    Go in the button's Actionscript?

                    And where are the main actions? lol

                    Thanks for the help so far though
                    • 7. Re: Buttons...
                      chris_knows Level 1
                      Bump