Hi,
Perhaps you find code below useful. Please note that this is a piece from a large chunk of code I use in my app, so it will have references to other functions/variables. Just use it for inspiration :). It is a horizontal scrollable tab bar with icons on top.
local function moveListener( event ) idnr = event.target.id if ( event.phase == "moved" ) then local dx = math.abs( event.x - event.xStart ) if ( dx \> 5 ) then scrollView:takeFocus( event ) end elseif ( event.phase == "ended" ) then --take action if an object was touched audio.play(storyboard.state.buttonSound, {channel=30}) for i=1,mItemsNr do sMenu.icons[i].alpha = sMenu.alphaOff end sMenu.icons[idnr].alpha = sMenu.alphaOn scrollView:scrollToPosition({x=xBoundary/2-sMenu.icons[idnr].x, time=100}) eventIdNr = event.id if not sMenu.shown then sMenu.shown = true doSubMenuBG() end doSubMenu() end return true end scrollView = widget.newScrollView { width = xBoundary, height = tDim.smH, scrollWidth = tDim.smW, scrollHeight = tDim.smH, friction = 0.98, maxVelocity = 2.5, verticalScrollDisabled = true, hideBackground = false, leftPadding = -0.8\*iconOffset, rightPadding = -0.0\*iconOffset } scrollView.x = tDim.smX scrollView.y = tDim.smY local scrollLine = display.newLine(0,tDim.smH,tDim.smW,tDim.smH) scrollLine.strokeWidth = 2 scrollLine:setStrokeColor(unpack(cGreen)) --generate icons for i = 1, mItemsNr do sMenu.bgrects[i] = display.newRect(iconOffset+(i-1)\*xBoundary/5,tDim.smH/2, tDim.smH, tDim.smH) sMenu.bgrects[i].alpha = 0 sMenu.bgrects[i].isHitTestable = true sMenu.bgrects[i].id = i sMenu.icons[i] = display.newImageRect( "images/mg"..tostring(i)..".png", 0.8\*tDim.smH, 0.8\*tDim.smH ) sMenu.icons[i].x = iconOffset+(i-1)\*xBoundary/5 sMenu.icons[i].y = tDim.smH/2 sMenu.icons[i].isHitTestable = false sMenu.icons[i].alpha = sMenu.alphaOff mGroup:insert(sMenu.bgrects[i]) mGroup:insert(sMenu.icons[i]) scrollView:insert( sMenu.bgrects[i] ) scrollView:insert( sMenu.icons[i] ) sMenu.icons[i].id = i sMenu.bgrects[i]:addEventListener( "touch", moveListener ) end mGroup:insert(scrollView) scrollView:insert(scrollLine) scrollView:scrollToPosition({x=-0.8\*iconOffset, time=200})