I get errors when i run this. Its with the addEventListener. It returns a nil. Im using Solor2d(Corona SDK). Thanks for any help
local button
local function changeScenes()
composer.gotoScene("scenetemplate", {effect="slideRight", time=300})
end
function scene:create( event )
local sceneGroup = self.view
bg = display.newImageRect( "clown2.png", 350, 470 )
bg.x = display.contentCenterX
bg.y = display.contentCenterY+300
sceneGroup:insert(bg)
title=display.newText("Scene 2",display.contentCenterX,display.contentCenterY-200,"candystr",60)
title:setFillColor(0,0,1)
sceneGroup:insert(title)
button = display.newRect(display.contentCenterX,display.contentCenterY,display.contentWidth*.3,display.contentHeight*.05)
button:setFillColor(1,0,0)
sceneGroup:insert(button)
button.addEventListener("tap",changeScenes)
Use colon notation instead of dot notation
button:addEventListener("tap",changeScenes)