2 Replies Latest reply on May 24, 2008 1:21 PM by Newsgroup_User

    Move button position on mouseDown

    Renos83 Level 1
      I would like a tip of how you can change the xAxis, yAxis position of a button on mouseDown (a very slight position change, just like the "Back", "Up" buttons on Firefox Mozilla or Windows Explorer). :)

        • 1. Re: Move button position on mouseDown
          multiduck
          Probably the easiest way to do it is to have two button bitmaps, one for when the button isn't pressed and one where it is. Then on mousedown change the member of the buttons sprite to the down bitmap and on mouseup change it back.

          If you still want to change the position you can use

          on mousedown me
          sprite(me.spritenum).loch=sprite(me.spritenum).loch-3 -- (chage 3 to the amount of pixels to move the button)
          sprite(me.spritenum).locv=sprite(me.spritenum).locv-3
          end

          on mouseup me
          sprite(me.spritenum).loch=sprite(me.spritenum).loch+3 -- (chage 3 to the amount of pixels to move the button)
          sprite(me.spritenum).locv=sprite(me.spritenum).locv+3
          end

          Note that there is a sligt flaw in this in that the position may not move as you want if the user releases the mouse outside the button for example

          When I looked, for me, the buttons becomes smaller when pressed, you can archive this by scaling the sprite through it's widht and height properties, tho again, having two bitmaps looks better.

          Or, you can use the flash button that I belive has this function built in, but in my experience is not as reliable as make a button of your own.
          • 2. Re: Move button position on mouseDown
            Level 7
            "Note that there is a sligt flaw in this in that the position may not
            move as you want if the user releases the mouse outside the button for
            example"


            I believe this can be overcome by adding this handler to cover situation.

            on mouseupOutside me
            sprite(me.spritenum).loch=sprite(me.spritenum).loch+3 -- (chage 3 to
            the
            amount of pixels to move the button)
            sprite(me.spritenum).locv=sprite(me.spritenum).locv+3
            end

            but I agree with multiduck, better to swap out cast members. I use the
            mouseupOutside handler for buttons where I swap members as well.