I wish to create an exercise for my students where they click on a chemical formula (from a list of 10 or more) and drag it to one of two graphic bins labeled ionic and covalent. If the text is dropped in the correct bin they hear a "reward" sound and the formula remains in the bin. If placed in the incorrect bin the formula snaps back it it's original location while a "wrong" sound is played.
I've searched the forums/tutorials and have found some info on dragging objects but nothing that will allow me to do this.
Can anyone point me to some info on this?
Thanks,
Doug Gilliland
Drag and Drop - Chemical Formulas
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 18
- Joined: Wed Apr 04, 2007 7:48 pm
- Contact:
Altoug there is the "grab" command, for most cases it doesn't allow for enough control, but your case could be done with it i guess (even if how to do it isn't as straight forward as other stuff in Rev):
Spice the code in the "testWithin" handler up with repeat loops, if you have many targets.
Usefull docu topics:
grab command
is within operator
within() function (note: works differently then "is within")
Code: Select all
on mouseDown
grab me
end mouseDown
on mouseRelease --if the user is faster then rev
testWithin
end mouseRelease
on mouseUp
testWithin
end mouseUp
on testWithin
if the loc of me is within the rectangle of button "target" then
beep
set the loc of me to the loc of button "target"
end if
end testWithin
Usefull docu topics:
grab command
is within operator
within() function (note: works differently then "is within")
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Ah right, i forgot the snap back.
useful topics:
local command
global command
constant command
location property
Code: Select all
local theOrigin
on mouseDown
put the loc of me into theOrigin
grab me
end mouseDown
on mouseRelease --neded if the user is faster then Rev
setback
end mouseRelease
on mouseUp
setback
end mouseUp
on setback
set the loc of me to theOrigin
end setback
local command
global command
constant command
location property
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- Posts: 18
- Joined: Wed Apr 04, 2007 7:48 pm
- Contact: