Scrolling with keys
Dar Scott
dsc at swcp.com
Mon Jun 23 16:43:00 EDT 2003
On Monday, June 23, 2003, at 03:02 PM, Dar Scott wrote:
>> So, how would I scroll an image with a keypress while it's down, then
>> stop
>> on keyup.
>
> Something like this might get you started:
I forgot to say to put that into the card script and to make an image
named "My Image".
I tried it and it works, but I changed it a little:
local sendID = ""
local toTheRight = "false"
local toTheLeft = "false"
constant rightArrow = 65363
constant leftArrow = 65361
--constant stepSize = 4
constant stepPeriod = 0.04
on rawKeyDown keyCode
if keyCode is rightArrow then put true into toTheRight
if keyCode is leftArrow then put true into toTheLeft
updateMoving
end rawKeyDown
on rawKeyUp keyCode
if keyCode is rightArrow then put false into toTheRight
if keyCode is leftArrow then put false into toTheLeft
updateMoving
end rawKeyUp
on updateMoving
if (toTheRight or toTheLeft) then
if sendID is empty then
moveStep -- Does one step and it repeats itself
end if
else
cancel sendID
put empty into sendID
end if
end updateMoving
on moveStep
if toTheRight then
if the right of image "My Image" < 320 then
--move image "My Image" rel (stepSize,0) in stepPeriod seconds
without waiting
move image "My Image" rel (1,0) without waiting
end if
else
if the left of image "My Image" > 5 then
--move image "My Image" rel ((-stepSize),0) in stepPeriod seconds
without waiting
move image "My Image" rel (-1,0) without waiting
end if
end if
send moveStep to me in stepPeriod seconds
put the result into sendID
end moveStep
Dar Scott
More information about the use-livecode
mailing list