Hello,
I am new in LUA and Corona but i want to create a scrollview in director with multiple buttons. I have create a seperate display.newGroup with the name “Mylist” for the buttons.
But the buttons do not seem the work when i insert a scrollview. see the code below.
please some help?
thank you
[code]
module(…, package.seeall)
_W = display.contentWidth
_H = display.contentHeight
function new(Params)
local ui = require ( “ui” )
local scrollView = require(“scrollView”)
local util = require(“util”)
local localGroup = display.newGroup()
local Mylist = display.newGroup()
local background = display.newImage( “bg.png” )
local header = display.newImage( “header.png” )
local topBoundary = display.screenOriginY
local bottomBoundary = display.screenOriginY +50
local scrollView = scrollView.new{ top=topBoundary, bottom=bottomBoundary }
local btn1t = function( event )
if event.phase == “release” then
director:changeScene( “newsscreen1”, “moveFromRight” )
end
end
local btn2t = function ( event )
if event.phase == “release” then
director:changeScene( “newsscreen2”, “moveFromRight” )
end
end
local btn3t = function ( event )
if event.phase == “release” then
director:changeScene( “newsscreen3”, “moveFromRight” )
end
end
local btn4t = function ( event )
if event.phase == “release” then
director:changeScene( “newsscreen4”, “moveFromRight” )
end
end
local btn5t = function ( event )
if event.phase == “release” then
director:changeScene( “newsscreen5”, “moveFromRight” )
end
end
local btn6t = function ( event )
if event.phase == “release” then
director:changeScene( “newsscreen6”, “moveFromRight” )
end
end
local btn7t = function ( event )
if event.phase == “release” then
director:changeScene( “newsscreen7”, “moveFromRight” )
end
end
local btn8t = function ( event )
if event.phase == “release” then
director:changeScene( “newsscreen8”, “moveFromRight” )
end
end
local btn1 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn1t,
id = “btn1”
}
local btn2 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn2t,
id = “btn2”
}
local btn3 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn3t,
id = “btn3”
}
local btn4 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn4t,
id = “btn4”
}
local btn5 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn5t,
id = “btn5”
}
local btn6 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn6t,
id = “btn6”
}
local btn7 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn7t,
id = “btn7”
}
local btn8 = ui.newButton{
default = “listItemBg.png”,
over = “listItemBg_over.png”,
onEvent = btn8t,
id = “btn8”
}
local initVars = function ()
localGroup:insert( background)
localGroup:insert( header )
Mylist:insert( btn1 )
Mylist:insert( btn2 )
Mylist:insert( btn3 )
Mylist:insert( btn4 )
Mylist:insert( btn5 )
Mylist:insert( btn6 )
Mylist:insert( btn7 )
Mylist:insert( btn8 )
localGroup:insert( Mylist )
scrollView:insert( Mylist)
header.x = _W/2
header.y = _H - 449
btn1.x = _W/2
btn1.y = _H - 356
btn2.x = _W/2
btn2.y = _H - 263
btn3.x = _W/2
btn3.y = _H - 170
btn4.x = _W/2
btn4.y = _H - 77
btn5.x = _W/2
btn5.y = _H + 16
btn6.x = _W/2
btn6.y = _H + 109
btn7.x = _W/2
btn7.y = _H + 202
btn8.x = _W/2
btn8.y = _H + 295
end
initVars()
return localGroup
end
[code] [import]uid: 117593 topic_id: 22954 reply_id: 322954[/import]