how to create draggable objects
Klaus Major
klaus at major-k.de
Tue Jul 20 06:54:10 EDT 2004
Hi Nicolas
> Any pointers as to where to begin looking in the Transcript Dictionary
> to
> learn about how to allow objects to be dragged and dropped would be
> very
> welcome. (The purpose: students click on a button to hear an English
> word
> and then drag the corresponding image to that same button.)
I have done this before and just used a combination of:
grab, mouseup, within() or intersect()
Give the image a "mousedown" AND a "mouseup"handler:
local oldloc
## to let the image "snap back" to its old positon after releasing the
mouse...
## VERY PRO :-D
on mouseUp
if intersect(me, btn 1) then
##do whatever to do in this case
end if
set the loc of me to oldloc
## snap back :-)
end mouseUp
on mousedown
put the loc of me into oldloc
grab me
end mousedown
Tested and works fine...
Hope that helps.
> Cheers,
>
> Nicolas Cueto
Regards
Klaus Major
klaus at major-k.de
http://www.major-k.de
More information about the use-livecode
mailing list