Page 1 of 1
Drag 'n' Drop
Posted: Wed Oct 03, 2007 10:08 am
by Matt9537
For school coursework we have to use Revolution Media to make an interractive program. In this we need to use a drag and drop feature. Through many attempts to do this we are unsuccesful, can anyone give us a pointer? We are aware of the 'grab me' command.
I'm sure you're all aware of the drag games where you drag a picture or text over an answer and you get points or womehting happens. For example, matching the pictures with words or rearranging text/pictures into order and getting feedback...
Thanks in advance
Regards
Matt
PS: I have searched through help files and tuturials etc but no succes...please help!
Posted: Wed Oct 03, 2007 11:13 am
by Klaus
Hi Matt,
this code snippet in a button or (locked) field or image will check the location WHERE the "dropping" occured and lets you trigger an action if the location is correct, you get the idea
Code: Select all
local my_old_position
## If you want to "restore" the original position of the "dragged" object
on mouseDown
set the layer of me to the num of objects
## this way the object will alwys be "on top" of all other
## objects on the card
put the loc of me into my_old_position
## store the original loc for a later "snap back" of this object
grab me
end mouseDown
on mouseUp
if within(img "the correct answer",the loc of me) then
## do something here in case this is the correct thing
else
## not correct, PUNISH the User :-)
end if
## set the loc of me to my_old_position
## or to use a more damatic effect:
move me to my_old_position in 500 millisecs
end mouseUp
Hope that helps, of course this is only ONE possible approach, but a working and understandable one
Best from germany
Klaus
Posted: Wed Oct 03, 2007 12:55 pm
by Matt9537

Just what i was looking for! Thank you very much.
Though the layer code didn't seem to work (got an error) but thats the least of my worries

. It would be intresting, though, to see other approches.
Thanks again Klaus so easy to follow and I understand it all!
regards
matt
Posted: Wed Oct 03, 2007 1:04 pm
by Klaus
Hi Matt,
sorry, a little typo!
It should read:
...
set the layer of me to the num of CONTROLS
...
Glad I could help
Best
Klaus