What's wrong with this swiping code?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
abanowBUSTfGf
Posts: 63
Joined: Sat Dec 22, 2012 3:01 am

What's wrong with this swiping code?

Post by abanowBUSTfGf » Tue Jan 08, 2013 2:26 am

I can't figure out why I'm getting this error on the below swiping code: "Execution error at line 5 (Operators-: error in right operand, character 15)
===============================================================
on mouseDown
put the mouseH into sStartH
end mouseDown
on mouseUp
if abs(the mouseH - sStartH) > 50 then
if the mouseH < sStartH then
go to next card
else
go to previous card
end if
end if
end mouseUp
=======================
Many thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: What's wrong with this swiping code?

Post by dunbarx » Tue Jan 08, 2013 2:49 am

Hi,

try this:

Code: Select all

on mouseDown
   put the mouseH into sStartH
end mouseDown
on mouseUp
   if abs(the mouseH - sStartH) > 50 and the mouseH < sStartH then
   go to next card
   else
   go to previous card
   end if
end mouseUp
Craig Newman

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: What's wrong with this swiping code?

Post by dave_probertGA6e24 » Tue Jan 08, 2013 10:26 am

Hi Dunbar,

Problem with your solution is that a simple click will cause a move to previous card - because of the else aspect.

I think the problem is not with the structure of the original code - but simply that it needs a:

Code: Select all

local sStartH

... orig code here
at the top of the script.

I have just tested the code here and that was all I added to make it work.

Hope that helps,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

Post Reply