hello list,
i've written a behavior to drag 4 sprites to 5 target-locs, where they snap 
to, leaving one specific target free. targets are at channels 3 to 7, 
objects at 20 to 23. objects communicate with targets by the sendallsprites 
method, which will return either targets spriteNum or nothing.
the user can move the 4 objects around the stage (constraint set to an 
invisible shape). while dragging the object (mousedown) the user has to get 
the objects into the right order and snap them to the targets. when the 
dragged object comes close to one of the targets its getting snapped to it, 
deciding by the question: is 'the mouseLoc + offset' still inside the 
target (target.loc + snapdistance) - or not.
as the user continues dragging (no mouseup yet) then the object moves again 
with the mouse, once the mouse is outside the snap distance. if the mouse 
is inside that distance the object should not move.
when the user releases the mouse button, the dragged object stayes right in 
place, snapped or not. so the objects do not need to, for instance, move 
back to their original position. and the objects can
the aim of all that is to get the 4 objects on the targets, placed in the 
right order and with the empty target on the right position. if the user 
was not successful, the targets will fall to the bottom of the stage and 
the user gets another chance. (but that is beeing checked by another 
handler and works fine).

my problem is, that the mouseUp or leaving the target detection gets 
somehow confused. so often, when moving (dragging) the object into the 
target.rect and releasing the mousebutton while shortly continuing moving 
the mouse, then this happens:
when moving the mouse with an object drag-snapped to the target and "right 
after" the mouseUp -seemingly while the mouseUp- the sprite moves according 
to the mouse-movement, away from its snaploc although it is snapped. when 
clicked again then on mousedown it jumps back to the snapLoc and on next 
mouseUp to the mouseLoc again.
this can be repeated, even after 'strongly' moving the mouse or clicking 
elsewhere outside, until next time moving that one object-sprite.

seems like the script takes too long to calculate the new object-position 
while the mouse already went on... might that be? or is the idea of setting 
the property TRACKING to FALSE not the right approach?
can anybody help me?

the objects come from another (internal) cast and are initiated by a 
separate frame (read into a global list). their ink is set to #mask. all 
other stuff coes from the internal cast. the actual frame-script only 
checks if  all 4 objects are snapped to the targets, and if not gets the 
go-the-frame command. no other scripts acting, no puppets.
platform is win98, dir8.0

please help me
matze


+++++
moveable objects:
property sp, tracking, xOffset, yOffset, snapped

on beginsprite me
   sp = sprite(me.spritenum)
   snapped = FALSE
end

on mouseDown me
   if tracking then
     set tracking = FALSE
   else
     set xOffset = sprite(sp).locH - the mouseH
     set yOffset = sprite(sp).locV - the mouseV
     set tracking = TRUE
   end if
end

on mouseUp me
   set tracking = FALSE
end

on mouseUpOutside me
   set tracking = FALSE
end

on exitframe me
   if tracking then
     akt = point((the mouseH + xOffset),(the mouseV + yOffset))
     set a = sendAllSprites(#bindrauf, akt)
     if a > 1 then
         sprite(sp).loc = sprite(a).loc
         set snapped = TRUE
     else
       sprite(sp).loc = akt
       set snapped = FALSE
     end if
   end if
end

+++++
targets:
on bindrauf me, x
a = sprite(me.spriteNum).rect
if x.inside(a) then return me.spriteNum
end



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to