Move object while button is held down

Hey guys,

I’ve been playing with Corona for a few hours now, and I love it! I am having an issue with moving an object while a button is pressed down, and I’d appreciate it if someone could help steer me in the right direction.

I don’t fully understand even listeners quite yet, so I’m sure that’s where the problem lies.

Basically what I have right now is

local buttonHandler = function( event )  
 transition.to( block, { time=500, x=(block.x+10)} )  
end  

However, I can’t figure out how to make the transition call repeat until the user releases the button.

Thanks in advance!
[import]uid: 22447 topic_id: 5380 reply_id: 305380[/import]

Whoops! I forgot to include my button code:

local buttonArrowR = ui.newButton{ default = "buttonArrow.png", over = "buttonArrowOver.png", onPress = buttonHandler, -- onRelease = buttonRelease, id = "arrow" } [import]uid: 22447 topic_id: 5380 reply_id: 17957[/import]

Take a look at the MultiPuck sample. That ought to have EXACTLY the code you need.
[import]uid: 9659 topic_id: 5380 reply_id: 18022[/import]

Don’t use a transition. Instead, set an event listener for enterFrame and then move the object a little bit each frame. Then you can remove the event listener when the button is released. [import]uid: 12108 topic_id: 5380 reply_id: 18029[/import]