a shake and a wiggle
BNig
niggemann at uni-wh.de
Tue Nov 1 03:09:30 EDT 2011
Hi Nicolas,
I post the script I sent you here for anybody who has followed this thread.
Make a button called "wiggleBehavior" for the behavior of the objects you
want to delete by the gesture. Set it's script to:
-----------------------------------------------
local sX, sLastTime, sCountWiggle = 0, sMove = false, sOldDirection
on mouseDown
put item 1 of the clickLoc into sX
put the milliseconds into sLastTime
put true into sMove
grab me
end mouseDown
on mouseMove x
if not sMove then exit mouseMove
put x-sX into tDiffX
put x into sX
if tDiffX = 0 then exit mouseMove
put tDiffX >0 into tDirection
if the milliseconds - sLastTime < 600 then -- change intervall as
needed
if not (tDirection = sOldDirection) then
add 1 to sCountWiggle
end if
else
put the milliseconds into sLastTime
put 0 into sCountWiggle
end if
put tDirection into sOldDirection
if sCountWiggle > 4 then -- change condition as needed
put false into sMove
put the long id of me into tMyID
send "delete tMyID" to me in 0 milliseconds
-- script in the card, makes new button, for testing mainly
-- send "makeNewButton" to this card in 3 milliseconds -- unblock if
needed
beep
end if
end mouseMove
on mouseUp
put false into sMove
put 0 into sCountWiggle
end mouseUp
on mouseRelease
mouseUp
end mouseRelease
-----------------------------------------------
set the card script to the following script if you want a new button every
time the old one is deleted, unblock "send "makeNewButton"... in the
behavior script
-----------------------------------------------
on makeNewButton
create button
set the loc of the last button to 100,100
set the behavior of the last button to the long id of button
"wiggleBehavior"
set the backgroundColor of the last button to any line of the colorNames
set the label of the last button to "wiggle me"
end makeNewButton
-----------------------------------------------
make a button and set it's behavior to the long ID of the button
"wiggleBehavior" (or issue "makeNewButton" from the messageBox if you have
set the card script to the code above.
Now you can wiggle a button and it will delete itself. Adjust the sampling
intervall and number of changes in direction as indicated in the script if
needed.
Kind regards
Bernd
--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/a-shake-and-a-wiggle-tp3955354p3962691.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the use-livecode
mailing list