Page 1 of 1

Drag and Drop HELP

Posted: Thu Dec 30, 2010 6:47 pm
by nitya
Hello

I am new to live code. I am try to develope apps based on drag and drop.

please see attached pic.
PartsOfTheBody2.jpg
PartsOfTheBody2.jpg (102.85 KiB) Viewed 4206 times
User have to drag and drop part of the body label to relevant box.

if drop on correct box then label centre location equal to correct box centre location

if drop on wrong box then set location of label back to start point.

Questions
1) how to track and store start location of label
2) how to set label location to box location if answer is correct
3) how to set label location back to start location

So far my code is as following where Code in RED not working and Code in Blue is working fine.

on touchStart
--get startlocation
end touchStart

-- dragORdrop is custom property set either drag or drop

on touchmove pid,pX,pY

if the dragORdrop of the target is "drag" then
set the loc of the target to pX, pY
end if

end touchmove


Many thanks in advance.

Re: Drag and Drop HELP

Posted: Thu Dec 30, 2010 8:46 pm
by Randy Hengst
Hello nitya,

I've attached an example of one way to do this.

See the card script for the handlers.

take care
randy hengst

Re: Drag and Drop HELP

Posted: Fri Dec 31, 2010 12:07 am
by nitya
Dear Randy

Your example rocks. I will try and run code on IPAD simulator.
Many thanks for help.

Regards
Nitya

Re: Drag and Drop HELP

Posted: Tue Jan 25, 2011 6:53 am
by cruddydan
It would be nice to see this solution using the "touch" events, not the "grab" command.