Page 1 of 1

What's wrong with this swiping code?

Posted: Tue Jan 08, 2013 2:26 am
by abanowBUSTfGf
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

Re: What's wrong with this swiping code?

Posted: Tue Jan 08, 2013 2:49 am
by dunbarx
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

Re: What's wrong with this swiping code?

Posted: Tue Jan 08, 2013 10:26 am
by dave_probertGA6e24
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