Help with my UI plz

I am getting the following error:

Runtime error ui.lua:31: attempt to index local ‘coverTap’ (a function value) stack traceback:
ui.lua:31: in main chunk
[C]: in function 'require’Runtime error: ui.lua:31: attempt to index local ‘coverTap’ (a function value)
stack traceback:
ui.lua:31: in main chunk
[C]: in function ‘require’

I have the following code:

main.lua

local ui = require("ui")  
local cover = display.newImage ("Page0.jpg")  

ui.lua

--Declair the Tap Menu, including top menu, Dropdown Menu, and bottom Menu  
local topMenu = display.newImage ("tapMenuBtn.png",0,0)  
topMenu.alpha = 0  
local topMenuDD = display.newImage ("tapMenuBtnDD.png",0,150)  
topMenuDD.alpha = 0   
local contents = display.newImage ("contentsBtn.png",0,824)  
contents.alpha = 0   
local settings = display.newImage ("settingsBtn.png",256,824)  
settings.alpha = 0   
local more = display.newImage ("moreBtn.png",512,824)  
more.alpha = 0  
  
--Functions, tap functions to toggle top menu   
local function coverTap ( event )  
   
if topMenu.alpha == 1 then  
topMenu.alpha = 0  
topMenuDD.alpha = 0  
contents.alpha = 0  
settings.alpha = 0  
more.alpha = 0  
elseif topMenu.alpha == 0 then  
topMenu.alpha = 1  
contents.alpha = 1  
settings.alpha = 1  
more.alpha = 1  
return true  
end  
   
end  
coverTap:addEventListener ("tap", coverTap)  
  
 --Functions, tap functions to toggle Dropdown Menu  
local function topMenuTap ( event )  
   
if topMenuDD.alpha == 1 then  
topMenuDD.alpha = 0  
elseif topMenuDD.alpha == 0 then  
topMenuDD.alpha = 1  
return true  
end  
   
end  
topMenu:addEventListener ("tap", topMenuTap)  

It was working, I didnt change anything and it stopped working. I dont know what happened. [import]uid: 112297 topic_id: 19684 reply_id: 319684[/import]

Shouldn’t it be:

cover:addEventListener ("tap", coverTap)

coverTap is a function. You need a display object to attach an event listener.
[import]uid: 70847 topic_id: 19684 reply_id: 76147[/import]

its not the tap functions because if I take out the UI and have it all on one page the whole thing works.

--local ui = require("ui")  
   
local cover = display.newImage ("Page0.jpg")  
  
--Declair the Tap Menu, including top menu, Dropdown Menu, and bottom Menu  
local topMenu = display.newImage ("tapMenuBtn.png",0,0)  
topMenu.alpha = 0  
local topMenuDD = display.newImage ("tapMenuBtnDD.png",168,150)  
topMenuDD.alpha = 0   
local contents = display.newImage ("contentsBtn.png",0,824)  
contents.alpha = 0   
local settings = display.newImage ("settingsBtn.png",256,824)  
settings.alpha = 0   
local more = display.newImage ("moreBtn.png",512,824)  
more.alpha = 0  
  
--Functions, tap functions to toggle top menu   
local function coverTap ( event )  
   
if topMenu.alpha == 1 then  
topMenu.alpha = 0  
topMenuDD.alpha = 0  
contents.alpha = 0  
settings.alpha = 0  
more.alpha = 0  
elseif topMenu.alpha == 0 then  
topMenu.alpha = 1  
contents.alpha = 1  
settings.alpha = 1  
more.alpha = 1  
return true  
end  
   
end  
cover:addEventListener ("tap", coverTap)  
  
 --Functions, tap functions to toggle Dropdown Menu  
local function topMenuTap ( event )  
   
if topMenuDD.alpha == 1 then  
topMenuDD.alpha = 0  
elseif topMenuDD.alpha == 0 then  
topMenuDD.alpha = 1  
return true  
end  
   
end  
topMenu:addEventListener ("tap", topMenuTap)  

works just fine. But if I make it a UI then it doesnt work :(. Any other ideas? [import]uid: 112297 topic_id: 19684 reply_id: 76283[/import]

The problem with your first post was that you has written
coverTap:addEventListener (“tap”, coverTap)

instead of
cover:addEventListener (“tap”, coverTap)

Also ‘cover’ needs to be in your ui.lua [import]uid: 70847 topic_id: 19684 reply_id: 76300[/import]