There is a better way to do what you want. On beginsprite you store the loc of the sprite, and its home state member. Presumably you're going to scatter the sprite somewhere around the stage, you would do that in the beginsprite handler too. When they drag the sprite around and let go, you check how far it is from the start loc, and if its within a certain distance you snap it to the home location. Something like this:

property s,,h,dragging

on beginsprite me
   s = the spritenum of me --(I prefer that form to me.spritenum.me.whatever)
   h = sprite(s).loc
   sprite(s).loc = point(random(640),random(480))
   dragging = false
end

on mousedown
   dragging = true
end

on prepareframe
   if dragging then
        sprite(s).loc = the mouseloc
        if not the mousedown then
               dragging = false
              snapto
        end if
   end if
end

on mouseup
    if not dragging then exit
    snapto
end

on snapto
    dx = sprite(s).loch - h[1]
    dy = sprite(s).locv - h[2]
    if dx*dx+dy*dy < 100 then sprite(s).loc = h
    dragging = false
end
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
lingo-l@penworks.com  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to