Hello guys i was with the same problem but a friend Scott helped me out in this.
Here is the code i’m using.
- In the scrollView.lua
First add this[blockcode]scrollView.activeButton = {}
[/blockcode]
Right after[blockcode]function new(params) – this thing is about the line 33 or somenthing[/blockcode]
Then
This first block of Code is right after the
[blockcode]
elseif( phase == “ended” or phase == “cancelled” ) then
local dragDistance = event.y - self.startPos
self.lastTime = event.time
Runtime:addEventListener(“enterFrame”, scrollView )
Runtime:removeEventListener(“enterFrame”, trackVelocity)
[/blockcode]
First Block of Code He simple check if the finger has moved. if is not he will dispach the event.
[blockcode]
local bounds = self.stageBounds
local x, y = event.x, event.y
local isWithinBounds = bounds.xMin <= x and bounds.xMax >= x and bounds.yMin <= y and bounds.yMax >= y
– Only consider this a “click”, if the user lifts their finger inside button’s stageBounds
if isWithinBounds and (dragDistance < 10 and dragDistance > -10 ) then
local event = { name=“scrollDoneHandler”, target=Runtime }
Runtime:dispatchEvent( event )
end
Second block of code still on scrollview.lua
[blockcode]
function scrollDoneHandler ()
if scrollView.activeButton.btn ~= nil then
local event = {}
event.phase = “ended”
–print(‘go activeButton.call’)
scrollView.activeButton.call(event)
–print(‘over activeButton.call’)
scrollView.activeButton = {}
end
end
Runtime:addEventListener(“scrollDoneHandler”,scrollDoneHandler)
[/blockcode]
This second block of code i pasted right affter the
[blockcode]function scrollView:cleanUp()
[/blockcode]
and in this function scrollView:cleanUp() i add the removeEvent Listener of the ScrollDOne Handler.
[blockcode]Runtime:removeEvenetListeer(“scrollDoneHandler”,scrollDoneHandler)
[/blockcode]
- The code of the button.
[blockcode]
local function NameOfYourEvent (event)
if (event.phase == “began”) then
quizScrollView.activeButton.btn = NameOfYourButton
quizScrollView.activeButton.name = ‘I am set’
quizScrollView.activeButton.call = NameOfYourEvent
quizScrollView.activeButton.y = quizScrollView.y
elseif (event.phase == “ended”) then
print(" ********* This is the place you paste your code of the button **********");
end
end
NameOfYourButton:addEventListener(“touch”, NameOfYourEvent) ;
[/blockcode]
Hope u guys can make it work like me.
I’m using the director class and worked veryfine.
Fell free to ask
Bye!
Ps: First post =) Not a Corona Forum Virgen Anymore! [import]uid: 114525 topic_id: 8984 reply_id: 90245[/import]