At 1:22 pm -0800 3/3/02, Scott Rossi wrote:
>Recently, Keelan Lightfoot wrote:
>
>>  on mousedown
>>  global amDragging
>>  put true into amDragging
>>  end mousedown
>>
>>  on mousemove
>>  global amDragging
>>  if amDragging then set the loc of me to the mouseloc
>>  end mousemove
>>
>>  on mouseup
>>  global amDragging
>>  put false into amDragging
>>  end mouseup
>>
<snip>
>
>The script above is incomplete.  Try adding the following after your script.
>
>on mouseRelease
>   mouseUp
>end mouseRelease

And one more improvement:

on mousemove pX, pY
  global amDragging
  if amDragging then
   put pX & "," & pY into tLoc
   set the loc of me to tLoc
  end if
end mousemove

This will add a pefomance boost, especially if you need to do other 
things in a mouseMove handler; for example, checking if the dragged 
object is over other objects, etc.

Also, instead of using globals, you should consider using locals 
declared outside of the handlers. This is not for performance 
reasons, but improves script management. You don't need to worry 
about name clashes with globals declared elsewhere that you might 
have forgotten about. So:

local amDragging

on mousedown
   put true into amDragging
end mousedown

on mousemove pX, pY
  if amDragging then
   put pX & "," & pY into tLoc
   set the loc of me to tLoc
  end if
end mousemove

on mouseup
   put false into amDragging
end mouseup

on mouseRelease
   mouseUp
end mouseRelease

Cheers
Dave Cragg


_______________________________________________
improve-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/improve-revolution

Reply via email to