9 Replies Latest reply on Sep 18, 2010 6:57 AM by kglad

    mouse rollover action

    Poop Joke

      Hello. I have a transparent button (upButton), and I want it to move a background image (BG1) when the mouse rolls over it.

       

      So far I've got it set so that the mouse moves it y+1 when it's over the button, but it only seems to do it once. I want it to keep moving BG1, basically making it scroll, until the user moves the cursor off the button.

       

      Here's what I have so far. This is applied to the button (upButton).

       

      on (rollOver) {
          setProperty("BG1", _y, "+1");
      }

       

      Thanks in advance for any help!

        • 1. Re: mouse rollover action
          kglad Adobe Community Professional & MVP

          is there any good reason you're using as1?

          • 2. Re: mouse rollover action
            Poop Joke Level 1

            I've only ever worked in AS2, but I was intermediate at best. I was starting out this project intending to try to teach myself AS3, but the syntax made even less sense to me than AS2. I wasn't getting the idea of how to set things up with the actions in the frame instead of directly on the button, so I went back to AS2, and this is what I ended up with working through Script Assist.

             

            If it's easier for you to explain in AS3, I'll be happy to learn that way. I'm not so far along that I can't change the project over.

            • 3. Re: mouse rollover action
              kglad Adobe Community Professional & MVP

              that's as1, not as2.  and it's easier to work with as2 than as1.

               

              to start, no code should be attached to objects.  then assign your button an instance name, say btn and use:

               

               

               

              var tl:MovieClip=this;

               

              btn.onRollOver=function(){

              BG1._y++;

              tl.onEnterFrame=function(){

              BG1._y++;

              }

              }

              btn.onRollOut=function(){

              delete tl.onEnterFrame;

              }

              • 4. Re: mouse rollover action
                Poop Joke Level 1

                Thanks so much! That does exactly what I asked.

                 

                I do have two follow up questions, if you don't mind (let me know if you'd like me to make a separate post for these):

                 

                1. How can I make it scroll more quickly? and,

                2. How can I set a limit to how far it will scroll in that direction?

                 

                Thanks again! All the help is really appreciated!

                • 5. Re: mouse rollover action
                  kglad Adobe Community Professional & MVP

                  to scroll more quickly increment the _y by more than 1 per loop.  and, to stop scrolling use an if-statement:

                   


                  var tl:MovieClip=this;

                   

                  btn.onRollOver=function(){

                  if(BG1._y<0){

                  BG1._y+=3;

                  tl.onEnterFrame=function(){

                  BG1._y+=3;

                  }

                  }

                  }

                  btn.onRollOut=function(){

                  delete tl.onEnterFrame;

                  }

                  1 person found this helpful
                  • 6. Re: mouse rollover action
                    Poop Joke Level 1

                    Thanks for the help, again! I really appreciate it.


                    • 7. Re: mouse rollover action
                      kglad Adobe Community Professional & MVP

                      you're welcome.

                      • 8. Re: mouse rollover action
                        Gaciwz

                        Hi....

                        I can be this difficult to change the keyboard to the mouse function.
                        anyone can help me?

                         

                         

                        onClipEvent (keyDown) {

                        with (_root)

                        {

                        if (Key.getCode() == Key.UP)

                        {

                        nextPacDir = 0;

                        }

                        else if (Key.getCode() == Key.RIGHT)

                        {

                        nextPacDir = 1;

                        }

                        else if (Key.getCode() == Key.DOWN)

                        {

                        nextPacDir = 2;

                        }

                        else if (Key.getCode() == Key.LEFT)

                        {

                        nextPacDir = 3;

                        }

                        else if (playing && (Key.getCode() == 80 || Key.getCode() == 112))

                        {

                         

                         

                        tx Before...

                        • 9. Re: mouse rollover action
                          kglad Adobe Community Professional & MVP

                          again, no code should be attached to objects.

                           

                          and, you should start a new thread for new issues.