drag/drop/snap button to arc

Malte Brill revolution at derbrill.de
Sun Aug 19 17:59:04 EDT 2007


Hi Emilio,

please excuse the shameless plug. If you´d use animationengine you would 
want to use something like the following script in the card (assuming 
one moving button called myButton and one oval graphic, called arc):

local tDragTime

on init
  set the loc of btn "myButton" to 400,400
  set the constrainRectangular of the btn "myButton" to the rect of this cd
end init

on constrainRectangularInit
  put the milliseconds into tDragTime
end constrainRectangularInit

on constrainrectangularCallBack
  if intersect(the target, grc "arc") then
    set the constrainElliptical of the target to \
    the loc of grc "arc",the width of grc "arc"/2,the height of grc "arc"/2
  end if
end constrainrectangularCallBack

on constrainEllipticalExit
  set the constrainElliptical of the target to empty
  answer the milliseconds-tDragTime
end constrainEllipticalExit

you would need to call the init method first. The button is placed at 
400,400 then. Start dragging the button to the oval. Release the button 
and see the time.

Hope that helps,

Malte




More information about the use-livecode mailing list