Click to move right

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
modfox
Posts: 3
Joined: Fri Nov 27, 2009 10:29 pm

Click to move right

Post by modfox » Sat Nov 28, 2009 1:42 am

Hi everyone, I was wondering how, if at all possible can I make an image move towards the right (fluidly) when I click and hold a button?
I want to do this so when I let go it will stop moving towards the right.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Re: Click to move right

Post by malte » Sat Nov 28, 2009 8:37 am

The best way to do this is to set up a timer. In your card script (or any other sensible place"

Code: Select all

on mousedown 
  set the flag of me to true
  moveItRight
end mouseDown

on mouseUp
  set the flag of me to false
end mouseUp

on moveItRight
  set the left of img "myImage" to the left of img "myImage" + 10
  if the flag of me then send "moveItRight" to me in 40 millisecs
end moveItRight
This is out of the top of my head, so please watch for typos.

Hth,

Malte

Post Reply