Date: Thu, 2 Mar 1995 15:38:42 +0000 From: Peter Small <peter@GENPS.DEMON.CO.UK> Subject: Toward the perfect button On Mon, 27 Feb 1995 21:07:15 -0600 Charles Wiltgen <cwiltgen@MCS.COM> wrote: >stuff deleted >(Note: Although in some cases I use >circle shapes, Director seems to stupidly use the circle's *bounding box* >to detect mouseCast -- duh!!) > >Beyond this, it's still a hell of a lot of work to get my buttons to work >like real buttons. A simple mouseDown/mouseUp combo is not problem, but >doing all the other tracking necessary to create user-friendly buttons is >intensive (not in the Lingo necessary to do so, really, but in all the >extra code execution that needs to happen in each frame). > >Wanted from Macromedia: A button object that allows for three graphics, >one script, and a user definable hot region (a one-bit mask is fine).It comes up on this list so many times that I thought everybody would know by now that the hot area of buttons can be *exactly the same shape* as the button if you set the ink of the sprite you are using for the button to MATTE.
Try it out. Make a weird shaped, bit mapped cast, with all kinds of curly arms. Set the ink of the sprite to MATT in the score window. Set the button script to:
on mouseUp beep end mouseUpYou will find that you only get beeps when you click inside the body of the bit map. Clicking between the arms has no effect even though the click is well inside the bounding rectangle.
To get the "MAC" button effect (where, when you drag away from a button before the mouseUp, it will not activate the button script) you might consider using the mouseDown with a stillDown() in a repeat loop.
The following handler works in this way and also switches casts to give a mouseDown visual effect which indicates if the mouseUp script is going to take place or not.
on mouseDown
put mouseCast() into MC
--REPEAT UNTIL THE MOUSE IS UP
repeat while stillDown() =1
if mouseCast() = MC then
--CHANGE PICTURE OF BTN TO PRESSED CONDITION
set the castNum of sprite 3 to MC +1
updateStage
next repeat
end if
--SET BTN PICTURE TO NORMAL IF MOUSE OFF BTN
if (mouseCast() <> MC +1) then set the castNum of sprite 3 to MC
updateStage
end repeat
--IF THE MOUSE IS STILL OVER THE BUTTON ON MOUSEUP
--ACTIVATE THE SCRIPT
if the mouseCast = MC then
--doThe MouseThing
end if
--RETURN BTN PICTURE TO NORMAL
set the castNum of sprite 3 to MC
updateStage
end
I think it is a very good idea of yours, Charles, to discuss on this list a variety of different buttons.
Perhaps we can extend it to include all kinds of different mechanisms which are activated by user response?