Here is a really chunky and sloppy written code of what I am trying to do because I am still formulating new methods and am not quite sure what I need yet.
But my main question is, is there a smoother, more accurate way to go about this?
Code: Select all
on mouseup
##find the x location of the mouse (the graphic only scrolls left and right)
put the mouseloc into tMouseLoc
put item 1 of tMouseLoc into xMouseLoc
##spacing on the side
put (the left of field "contact name" of this card + (the width of grc "slider bar" of this card/2)) into tVarWidth
##get the location of the graphic into separate variables for easy calc
put the location of me into tMeLoc
put item 2 of tMeLoc into yMeLoc
put item 1 of tMeLoc into xMeLoc
##I think this line of code made it jump to 3 decimal places but did not help
set the numberFormat to "#.00000"
put ((the left of graphic "slider bar" of this card)-(the left of field "contact name" of this card))/50 into tInterval
if the left of grc "slider bar" of this card < (the width of this stack * 0.5) then
repeat with x = 1 to 50
set the left of me to (the left of me - tInterval)
##moveControl sets a group's location according to the location of the graphic
moveControl
end repeat
##I put this here to correct any differences at the end but it does not work that well
if the left of grc "slider bar" of this card <> the left of the field "contact name" of this card then
set the left of grc "slider bar" of this card to the left of the field "contact name" of this card
moveControl
end if
##This is a repeat of the above if statement for the right side
else if the right of grc "slider bar" of this card >= (the width of this stack * 0.5) then
put true into gAllowMove
repeat with x = 1 to 50
set the left of me to (the left of me + tInterval)
moveControl
end repeat
if the right of grc "slider bar" of this card <> the right of the field "sort list" of this card then
set the right of grc "slider bar" of this card to the right of the field "sort list" of this card
moveControl
end if
else
exit mouseup
end if
put false into gAllowMove
end mouseup