Slider Question

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
calmrr3
Posts: 100
Joined: Mon Oct 28, 2013 2:39 pm

Slider Question

Post by calmrr3 » Mon Oct 28, 2013 2:46 pm

Hello,

I was just wondering how I would be able to make something happen when the slider is stopped at a specific value.

https : / / vimeo . com / 77926435

I want to be able to move to next card when the image is lined up correctly (this is just an example) the slider value for this is 90.

Thanks

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Slider Question

Post by Klaus » Mon Oct 28, 2013 2:55 pm

HI calmrr3,

1. welcome to the forum! :D

2. Use a scrollbar and add a mouseup script to it:

Code: Select all

on mouseup
  ## Check the THUMBPOSITION (thumbpos) of the scrollbar!
  if the thumbpos of me = 90 then
    ## do your stuff...
  end if
end mouseup
Check these stacks to learn more about the basics of Livecode, maybe start with stack "Controls" 8)
http://www.hyperactivesw.com/revscriptc ... ences.html

Best

Klaus

calmrr3
Posts: 100
Joined: Mon Oct 28, 2013 2:39 pm

Re: Slider Question

Post by calmrr3 » Mon Oct 28, 2013 2:58 pm

Thanks! I'll give it a go

calmrr3
Posts: 100
Joined: Mon Oct 28, 2013 2:39 pm

Re: Slider Question

Post by calmrr3 » Mon Oct 28, 2013 5:14 pm

This is the the code I am using (hacked together using examples!)

local sWidth, sHeight, sAngle, sScale, sWdim, sHdim, sValue, sLoc

on mouseDown
put the loc of img "branch2" into sLoc
set the lockloc of img "branch2" to false
put the thumbPos of me into sValue
end mouseDown

on mouseup
  if the thumbpos of me = 90 then
    go to card "card2"
  end if
end mouseup

on scrollBarDrag pValue
lock screen

if exists(img "tempImg") then
set the angle of img "tempImg" to pValue - sValue
end if
if sLoc is empty then exit scrollBarDrag
set the loc of img "branch2" to sLoc
if exists(img "tempImg") then set the loc of img "tempImg" to sLoc
unlock screen
end scrollBarDrag

(see vimeo link for demonstration) the problem is:

when I use the slider then deselect it then select it again, the rotated part of the image jumps back to its original position. I want it to remember its position so that I can use specific slider positions to trigger an event - at the moment at value 90 the rotation of the image is not always the same.

Very difficult to explain, sorry!

Post Reply