I have Director working with 5 screens, one of them being the home screen (menu.lua). Each screen has a native.showWebPopup on it, including Home.
The native.showWebPopup on the home screen loads fine when the app loads, and on all other screens as well. They work fine to click back and forth between the screens.
But when the user goes back to the home screen (menu.lua) from any of the other screens, the native.showWebPopup doesn’t load.
My menu.lua code is below:
module(..., package.seeall)
function new()
local localGroup = display.newGroup()
--\> This is how we start every single file or "screen" in our folder, except for main.lua
-- and director.lua
--\> director.lua is NEVER modified, while only one line in main.lua changes, described in that file
------------------------------------------------------------------------------
------------------------------------------------------------------------------
local background = display.newImage ("whitebackground.png")
localGroup:insert(background)
--\> This sets the background
local titlebar = display.newImageRect ("titlebar.png", 1135, 102)
localGroup:insert(titlebar)
titlebar.y = 22
--\> This sets the titlebar
local title = display.newImageRect ("title.png", 200, 42)
localGroup:insert(title)
title.x = 160
title.y = 40
--\> This sets the title
local navbar = display.newImageRect ("navbarbg.png", 1148, 120)
localGroup:insert(navbar)
navbar.y = 462
--\> This sets the navbar
local eatbutton = display.newImageRect ("eatbutton.png", 94, 45)
eatbutton.x = 60
eatbutton.y = 390
localGroup:insert(eatbutton)
local dobutton = display.newImageRect ("dobutton.png", 94, 45)
dobutton.x = 160
dobutton.y = 390
localGroup:insert(dobutton)
local shopbutton = display.newImageRect ("shopbutton.png", 94, 45)
shopbutton.x = 260
shopbutton.y = 390
localGroup:insert(shopbutton)
--\> This places our three buttons
local function pressEat (event)
if event.phase == "ended" then
director:changeScene ("eat")
end
end
eatbutton:addEventListener ("touch", pressEat)
local function pressDo (event)
if event.phase == "ended" then
director:changeScene ("do")
end
end
dobutton:addEventListener ("touch", pressDo)
local function pressShop (event)
if event.phase == "ended" then
director:changeScene ("shop")
end
end
shopbutton:addEventListener ("touch", pressShop)
--\> This adds the functions and listeners to each button
local iconHome = display.newImageRect ("icon\_home.png", 58, 30)
iconHome.x = 38
iconHome.y = 457
localGroup:insert(iconHome)
--\> This places our "home" button, which will do nothing here on the home screen
local iconEvents = display.newImageRect ("icon\_events.png", 62, 30)
iconEvents.x = 101
iconEvents.y = 457
localGroup:insert(iconEvents)
local iconDeals = display.newImageRect ("icon\_deals.png", 58, 30)
iconDeals.x = 163
iconDeals.y = 457
localGroup:insert(iconDeals)
local iconExplore = display.newImageRect ("icon\_explore.png", 68, 30)
iconExplore.x = 228
iconExplore.y = 457
localGroup:insert(iconExplore)
local iconInfo = display.newImageRect ("icon\_info.png", 46, 30)
iconInfo.x = 286
iconInfo.y = 457
localGroup:insert(iconInfo)
--\> This places bottom navs
local function pressEvents (event)
if event.phase == "ended" then
director:changeScene ("events")
end
end
iconEvents:addEventListener ("touch", pressEvents)
local function pressDeals (event)
if event.phase == "ended" then
director:changeScene ("deals")
end
end
iconDeals:addEventListener ("touch", pressDeals)
local function pressExplore (event)
if event.phase == "ended" then
director:changeScene ("explore")
end
end
iconExplore:addEventListener ("touch", pressExplore)
local function pressInfo (event)
if event.phase == "ended" then
director:changeScene ("info")
end
end
iconInfo:addEventListener ("touch", pressInfo)
--\> This adds the functions and listeners to each buttom nav button (Except home)
------------------------------------------------------------------------------
native.showWebPopup( -1, 76, 320, 285, "http://fingerlakesapp.com/app" )
return localGroup
end
And an example from another screen (deals.lua):
[code]
module(…, package.seeall)
function new()
local localGroup = display.newGroup()
–> This is how we start every single file or “screen” in our folder, except for main.lua
– and director.lua
–> director.lua is NEVER modified, while only one line in main.lua changes, described in that file
local background = display.newImage (“whitebackground.png”)
localGroup:insert(background)
–> This sets the background
local titlebar = display.newImageRect (“titlebar.png”, 1135, 102)
localGroup:insert(titlebar)
titlebar.y = 22
–> This sets the titlebar
local title = display.newImageRect (“title.png”, 200, 42)
localGroup:insert(title)
title.x = 160
title.y = 40
–> This sets the title
local navbar = display.newImageRect (“navbarbg.png”, 1148, 120)
localGroup:insert(navbar)
navbar.y = 462
–> This sets the navbar
local iconHome = display.newImageRect (“icon_home.png”, 58, 30)
iconHome.x = 38
iconHome.y = 457
localGroup:insert(iconHome)
–> This places our “back home” button
local function pressBack (event)
if event.phase == “ended” then
director:changeScene (“menu”)
native.cancelWebPopup()
end
end
iconHome:addEventListener (“touch”, pressBack)
–> This adds the function and listener to the “back” button
local iconEvents = display.newImageRect (“icon_events.png”, 62, 30)
iconEvents.x = 101
iconEvents.y = 457
localGroup:insert(iconEvents)
local iconDeals = display.newImageRect (“icon_deals.png”, 58, 30)
iconDeals.x = 163
iconDeals.y = 457
localGroup:insert(iconDeals)
local iconExplore = display.newImageRect (“icon_explore.png”, 68, 30)
iconExplore.x = 228
iconExplore.y = 457
localGroup:insert(iconExplore)
local iconInfo = display.newImageRect (“icon_info.png”, 46, 30)
iconInfo.x = 286
iconInfo.y = 457
localGroup:insert(iconInfo)
–> This places bottom navs
local function pressEvents (event)
if event.phase == “ended” then
director:changeScene (“events”)
end
end
iconEvents:addEventListener (“touch”, pressEvents)
local function pressDeals (event)
if event.phase == “ended” then
director:changeScene (“deals”)
end
end
iconDeals:addEventListener (“touch”, pressDeals)
local function pressExplore (event)
if event.phase == “ended” then
director:changeScene (“explore”)
end
end
iconExplore:addEventListener (“touch”, pressExplore)
local function pressInfo (event)
if event.phase == “ended” then
director:changeScene (“info”)
end
end
iconInfo:addEventListener (“touch”, pressInfo)
–> This adds the functions and listeners to each buttom nav button (Except home)
native.showWebPopup( -1, 76, 320, 340, “http://fingerlakesapp.com/app/deals” )
return localGroup
end
[/code] [import]uid: 101670 topic_id: 28652 reply_id: 328652[/import]