How do I make a picture "lock" into position in this script?
(I want to move the picture to the correct position and if that is true then Lock it (stop drag me command
) (the red commented script)
Thanks! Ben
SCRIPT:
global my_old_position
on mouseDown
set the layer of me to the num of controls
put the loc of me into my_old_position
grab me
end mouseDown
on mouseUp
if within (img "Yellow" ,the loc of me) then
add 1 to field "Answer"
##set the dragMove to false
else
move me to my_old_position
subtract 1 from field "Answer"
end if
end mouseUp
STOP drag me ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: STOP drag me ?
Ben,
try
regards
Bernd
try
Code: Select all
global my_old_position
on mouseDown
set the layer of me to the num of controls
put the loc of me into my_old_position
grab me
end mouseDown
on mouseUp
if within (img "Yellow" ,the loc of me) then
add 1 to field "Answer"
set the loc of me to the loc of img "Yellow" -- set the new loc
else
move me to my_old_position
subtract 1 from field "Answer"
end if
end mouseUp
Bernd
Re: STOP drag me ?
Thanks!
That works but what I want to accomplish to to disable the graphic from being moved again (drag)
Benjamin
That works but what I want to accomplish to to disable the graphic from being moved again (drag)
Benjamin
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: STOP drag me ?
Benjamin,
if you want to disable the drag when the object is at its final position (img "Yellow") handle that in the mouseDown handler
If I understand correctly what you are trying to do.
regards
Bernd
if you want to disable the drag when the object is at its final position (img "Yellow") handle that in the mouseDown handler
Code: Select all
global my_old_position
on mouseDown
if the loc of me = the loc of img "Yellow" then exit mouseDown -- only move if not at final position
set the layer of me to the num of controls
put the loc of me into my_old_position
grab me
end mouseDown
on mouseUp
if within (img "Yellow" ,the loc of me) then
add 1 to field "Answer"
set the loc of me to the loc of img "Yellow" -- set the new loc
else
move me to my_old_position
subtract 1 from field "Answer"
end if
end mouseUp
regards
Bernd
Re: STOP drag me ?
it worked!
thanlks!
ben
thanlks!
ben