nested overlays

I am trying to display an overlay on top of another overlay and everything looks fine until I try to go back to the original overlay. I get an error that the lua doesn’t exist. It is not a lua. It is in the code.

[lua]local grpBplcyscene = storyboard.newScene( “grpBplcyscene” )
function grpBplcyscene:createScene(event)

display.remove( viewButton )
viewButton = nil

local group = self.view
local grpBplcyrectext = display.newRoundedRect(0, 60, display.contentWidth-5,340,12 )
local function ongrpBDoneRelease( event )

display.remove( grpBdoneButton )
grpBdoneButton = nil

storyboard.hideOverlay(true, “fade”)

storyboard.showOverlay( “eligiblescene”, {isModal=true, effect = “fade”} )
end

– button below is local because of forward declaration defined earlier
grpBdoneButton = widget.newButton{
style = “blue1Small”,
label = “Done”,
onRelease = ongrpBDoneRelease
}
grpBdoneButton.x = 275
grpBdoneButton.y = 375

local grpBplcytitle = “Group B Policy Information”
local grpBplcytxt1 = “Each plan allows you to insure up to your average daily wage, with benefits ranging from $60 to $201 in increments of $3. The plans offer a variety of discipline days. Coverage increases each year the policy is in force.\n\n”
local grpBplcytxt2 = “NO 7: First year coverage starts at 250 days and reaches a maximum number of 365 covered discipline days per year or per claim in four years.\n\n”
local grpBplcytxt3 = “NO 10: First year coverage starts at 180 days and reaches a maximum number of 300 days per year or per claim in five years. Also included an accidental death feature that protects the member on and off the job. It also provides an accidental death benefit to your beneficiary at no extra cost.\n\n”

– don’t forget to insert objects into the scene group!

group:insert(grpBplcyrectext)
group:insert(grpBdoneButton)

local grpBplcytxttitle = display.newText( group, grpBplcytitle, 6, 62, display.contentWidth-12, 60, native.systemFontBold, 24 )
grpBplcytxttitle:setTextColor ( 251,170,39 )
local grpBplcytxt = display.newText( group, grpBplcytxt1…grpBplcytxt2…grpBplcytxt3, 6, 90, display.contentWidth - 12, 275, native.systemFont, 14 )
grpBplcytxt:setTextColor ( 0)

end
grpBplcyscene:addEventListener( “createScene”, grpBplcyscene )

local groupid = “”
local eligiblescene = storyboard.newScene( “eligiblescene” )
function eligiblescene:createScene(event)

local group = self.view
local eligiblerectext = display.newRoundedRect(0, 60, display.contentWidth-5,340,12 )
local columnData = {}
columnData[1] = {}
columnData[1][1]=“ACRE”
columnData[1][2]=“AEF”
columnData[1][3]=“ARASA”
columnData[1][4]=“ATDA”
columnData[1][5]=“ATDD”
columnData[1][6]=“ATU”
columnData[1][7]=“BLET”
columnData[1][8]=“BMWE”
columnData[1][9]=“BRC”
columnData[1][10]=“BRS”
columnData[1][11]=“HERE”
columnData[1][12]=“HO”
columnData[1][13]=“IAMAW”
columnData[1][14]=“IBB”
columnData[1][15]=“IBEW”
columnData[1][16]=“IBT”
columnData[1][17]=“ILA”
columnData[1][18]=“LI”
columnData[1][19]=“NCFO”
columnData[1][20]=“OTHER”
columnData[1][21]=“REA”
columnData[1][22]=“SEIU”
columnData[1][23]=“SMWIA”
columnData[1][24]=“SPU”
columnData[1][25]=“TCRC”
columnData[1][26]=“TCU”
columnData[1][27]=“TCUC”
columnData[1][28]=“TCW”
columnData[1][29]=“TWU”
columnData[1][30]=“UNK”
columnData[1][31]=“USEU”
columnData[1][32]=“USWA”
columnData[1][33]=“UTU”
columnData[1][34]=“WRSA”

columnData[1].alignment = “right”
columnData[1].width = 60
columnData[1].startIndex = unionIndex or 1

columnData[2] = {}
columnData[2][1]=“AIR TRAFFIC CONTROLLER”
columnData[2][2]=“AIRFIELD OPERATIONS SPECIALIST”
columnData[2][3]=“AIRLINE PERSONNEL”
columnData[2][4]=“AIRLINE PILOT”
columnData[2][5]=“ASST SIGNALMAN”
columnData[2][6]=“BRAKEMAN”
columnData[2][7]=“BRIDGE TENDER”
columnData[2][8]=“BUS DRIVER”
columnData[2][9]=“CAR DRIVER”
columnData[2][10]=“CAR INSPECTOR”
columnData[2][11]=“CARMAN”
columnData[2][12]=“CLERK”
columnData[2][13]=“CONDUCTOR”
columnData[2][14]=“CRANE OPR”
columnData[2][15]=“CREW CALLER”
columnData[2][16]=“CREW MGR”
columnData[2][17]=“DELIVERY TRUCK DRIVERS”
columnData[2][18]=“DIESEL FOREMAN”
columnData[2][19]=“DISPATCH”
columnData[2][20]=“DOCK WORKER”
columnData[2][21]=“ELECTRICIAN”
columnData[2][22]=“ENGINEER”
columnData[2][23]=“ENGINEER/MWE”
columnData[2][24]=“ENGR DEPT CO-ORDINATOR”
columnData[2][25]=“FIREMAN”
columnData[2][26]=“FLAGMAN”
columnData[2][27]=“FOREMAN”
columnData[2][28]=“HEAVY TRUCK DRIVERS”
columnData[2][29]=“HOSTLER”
columnData[2][30]=“LABORER”
columnData[2][31]=“LONG SHRMN/DCK WRKR”
columnData[2][32]=“MACHINE OPR”
columnData[2][33]=“MACHINIST”
columnData[2][34]=“MECH LABORER”
columnData[2][35]=“MECH MAINTENANCE”
columnData[2][36]=“MGR TRACK MAINTENANCE”
columnData[2][37]=“MISCELLANEOUS”
columnData[2][38]=“ON BOARD SERVICE”
columnData[2][39]=“OPERATOR”
columnData[2][40]=“POSTAL CARRIER”
columnData[2][41]=“PRE LOADER”
columnData[2][42]=“PUMP REPAIR MAN”
columnData[2][43]=“RR TRAFFIC CONTROLLER”
columnData[2][44]=“SAILOR MARINE OILER”
columnData[2][45]=“SHEET METAL WORKER”
columnData[2][46]=“SHIP CAPTAINS MATES PILOTS”
columnData[2][47]=“SHIP ENGINEER”
columnData[2][48]=“SIGNAL INSPECTOR”
columnData[2][49]=“SIGNAL MAINTAINER”
columnData[2][50]=“SIGNALMAN”
columnData[2][51]=“SORTER/AIR DRIVER”
columnData[2][52]=“STEEL WORKER”
columnData[2][53]=“SUBWAY CONDUCTOR”
columnData[2][54]=“SWITCHMAN”
columnData[2][55]=“TRACK FOREMAN”
columnData[2][56]=“TRACK REPAIRMAN”
columnData[2][57]=“TRACK SUPER/INSP”
columnData[2][58]=“TRACKMAN”
columnData[2][59]=“TRAIN OPERATOR”
columnData[2][60]=“TRAIN OPR/US STEELE”
columnData[2][61]=“TRAINMAN”
columnData[2][62]=“TRANS RPT SERV”
columnData[2][63]=“TRUCK DRIVER”
columnData[2][64]=“UPS DRIVER”
columnData[2][65]=“UPS LOADER”
columnData[2][66]=“UTILITY TECHNICIAN”
columnData[2][67]=“VAN DRIVER”
columnData[2][68]=“WELDER”
columnData[2][69]=“YARD SERVICE”
columnData[2][70]=“YARDMASTER”
columnData[2].alignment = “center”
columnData[2].width = 60
columnData[2].startIndex = craftIndex or 1

– create pickerWheel widget
local picker = widget.newPickerWheel{
top=120,
font=native.systemFontBold,
fontSize=12,
columns=columnData,
}

local function onDoneRelease( event )

display.remove( picker )
picker = nil

display.remove( doneButton )

doneButton = nil

storyboard.hideOverlay(true, “fade”)
end
local function onViewRelease( event )
local pickerValues = picker:getValues()
unionIndex = pickerValues[1].index
craftIndex = pickerValues[2].index
unionName = pickerValues[1].value

if string.find(“ATDA,ATDD,BLET,OTHER,TCRC,TCU,UNK,USWA,UTU”,unionName,1,true)==nil then
groupid =“B”
else
groupid=“A”

end

display.remove( picker )
picker = nil
display.remove( doneButton )
doneButton = nil

if groupid == “B” then
storyboard.showOverlay( “grpBplcyscene”, {isModal=true, effect = “fade”} )
else
storyboard.showOverlay( “grpAplcyscene”, {isModal=true, effect = “fade”} )
end
end
– button below is local because of forward declaration defined earlier
doneButton = widget.newButton{
style = “blue1Small”,
label = “Done”,
onRelease = onDoneRelease
}
doneButton.x = 275
doneButton.y = 375

viewButton = widget.newButton{
style = “blue1Small”,
label=“View”,
onRelease = onViewRelease
}
viewButton.x = 75
viewButton.y = 375

local eligibletitle = “Choose Union and Craft”

– don’t forget to insert objects into the scene group!

group:insert(eligiblerectext)
group:insert(doneButton)
local eligibletxttitle = display.newText( group, eligibletitle, 6, 62, display.contentWidth-12, 60, native.systemFontBold, 24 )
eligibletxttitle:setTextColor ( 251,170,39 )

end
eligiblescene:addEventListener( “createScene”, eligiblescene )[/lua]

[import]uid: 136344 topic_id: 31316 reply_id: 331316[/import]

“eligiblescene” is displayed first and the “grpBplcyscene” is displayed second then I hide overlay and try to get “eligiblescene” back and I get the error. [import]uid: 136344 topic_id: 31316 reply_id: 125154[/import]

In the documentation, it clearly states that you can only have one overlay active at a time.

In my experience, I can open two, but closing the top one closes both of them and since Corona Labs specifically says “Only one”, who knows what kind of memory leak or corruption will happen.
[import]uid: 19626 topic_id: 31316 reply_id: 125155[/import]

[lua]function policiesscene:createScene( event )

local group = self.view
local ttltxt1 = display.newText( “Plans and Rates”, 0,60,display.contentWidth, 0, native.systemFontBold, 24)
ttltxt1:setTextColor(251,170,39 )
ttltxt1:setReferencePoint( display.LeftReferencePoint )
local rectext= display.newRoundedRect( 5, 120, display.contentWidth-10,270,12 )
local partxt2 = display.newText( “LECMPA has a plan that is right for your union and craft. Take a look at our plans and rates and sign up today. \n\nWant to know more about how to calculate your coverage and what wages are covered? Read our calculation FAQs.”,8 , 125, display.contentWidth-20,0, native.systemFont, 16)
partxt2:setTextColor(0)
partxt2:setReferencePoint( display.LeftReferencePoint )
local loyaltyleft = ((display.contentWidth-20)/3)+80
local repleft = (((display.contentWidth-20)/3))+80

local eligiblebutton = widget.newButton( {id = “eligiblebutton”, left=40, top =400, label = “Eligible Plans”, width= (display.contentWidth-20)/2, height=30, defaultColor={251, 170, 39}, onPress = function() storyboard.showOverlay( “eligiblescene”, {isModal=true, effect = “fade”} ); end } )

– don’t forget to insert objects into the scene group!
group:insert( ttltxt1 )
group:insert( rectext )
group:insert( partxt2 )

group:insert( eligiblebutton )
end
policiesscene:addEventListener( “createScene”, policiesscene )[/lua]

Here is the code that launches the eligiblescene. When eligible launches grpBplcyscene it goes away. I assume this is what you mean by one scene at a time.

When I close grpBplcyscene I am unable to launch policiesscene again from the above code.

So I am not trying to have multiple scenes open at the same time but I should be able to open and close them multiple times.

[import]uid: 136344 topic_id: 31316 reply_id: 125157[/import]

I would like to get it to work before worrying about memory leaks… [import]uid: 136344 topic_id: 31316 reply_id: 125166[/import]

There must be a recommended method for controlling the show and hide of overlays. i.e. close ov1 open ov2 close ov2 open ov1 but where and when?
[import]uid: 136344 topic_id: 31316 reply_id: 125173[/import]

Ok so we have scene1 with a button that opens ov1 with two buttons - view button opens ov2 and - done button closes ov1, ov2 has one button - done button closes ov2. When ov2 closes this displays scene1 and the button that opens ov1 gives error. “Runtime error Attempting to load scene from invalid scene module (eligiblescene.lua). Did you forget to return the scene object at the end of the scene module? (e.g. ‘return scene’)” I don’t know what this means. How is it that the button stops working? [import]uid: 136344 topic_id: 31316 reply_id: 125281[/import]

Are you trying to put multiple scenes in a single .lua file or are these in separate scenes?

Normally each scene is a separate .lua file looks like:

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
end  
  
function scene:enterScene( event )  
 local group = self.view  
end  
  
function scene:exitScene( event )  
 local group = self.view  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

Note that it returns a scene object that the storyboard code uses to move things on and off screen. I know you can have everything in a single lua file, but I’m not sure why. [import]uid: 19626 topic_id: 31316 reply_id: 125285[/import]

“eligiblescene” is displayed first and the “grpBplcyscene” is displayed second then I hide overlay and try to get “eligiblescene” back and I get the error. [import]uid: 136344 topic_id: 31316 reply_id: 125154[/import]

In the documentation, it clearly states that you can only have one overlay active at a time.

In my experience, I can open two, but closing the top one closes both of them and since Corona Labs specifically says “Only one”, who knows what kind of memory leak or corruption will happen.
[import]uid: 19626 topic_id: 31316 reply_id: 125155[/import]

[lua]function policiesscene:createScene( event )

local group = self.view
local ttltxt1 = display.newText( “Plans and Rates”, 0,60,display.contentWidth, 0, native.systemFontBold, 24)
ttltxt1:setTextColor(251,170,39 )
ttltxt1:setReferencePoint( display.LeftReferencePoint )
local rectext= display.newRoundedRect( 5, 120, display.contentWidth-10,270,12 )
local partxt2 = display.newText( “LECMPA has a plan that is right for your union and craft. Take a look at our plans and rates and sign up today. \n\nWant to know more about how to calculate your coverage and what wages are covered? Read our calculation FAQs.”,8 , 125, display.contentWidth-20,0, native.systemFont, 16)
partxt2:setTextColor(0)
partxt2:setReferencePoint( display.LeftReferencePoint )
local loyaltyleft = ((display.contentWidth-20)/3)+80
local repleft = (((display.contentWidth-20)/3))+80

local eligiblebutton = widget.newButton( {id = “eligiblebutton”, left=40, top =400, label = “Eligible Plans”, width= (display.contentWidth-20)/2, height=30, defaultColor={251, 170, 39}, onPress = function() storyboard.showOverlay( “eligiblescene”, {isModal=true, effect = “fade”} ); end } )

– don’t forget to insert objects into the scene group!
group:insert( ttltxt1 )
group:insert( rectext )
group:insert( partxt2 )

group:insert( eligiblebutton )
end
policiesscene:addEventListener( “createScene”, policiesscene )[/lua]

Here is the code that launches the eligiblescene. When eligible launches grpBplcyscene it goes away. I assume this is what you mean by one scene at a time.

When I close grpBplcyscene I am unable to launch policiesscene again from the above code.

So I am not trying to have multiple scenes open at the same time but I should be able to open and close them multiple times.

[import]uid: 136344 topic_id: 31316 reply_id: 125157[/import]

I would like to get it to work before worrying about memory leaks… [import]uid: 136344 topic_id: 31316 reply_id: 125166[/import]

There must be a recommended method for controlling the show and hide of overlays. i.e. close ov1 open ov2 close ov2 open ov1 but where and when?
[import]uid: 136344 topic_id: 31316 reply_id: 125173[/import]

Ok so we have scene1 with a button that opens ov1 with two buttons - view button opens ov2 and - done button closes ov1, ov2 has one button - done button closes ov2. When ov2 closes this displays scene1 and the button that opens ov1 gives error. “Runtime error Attempting to load scene from invalid scene module (eligiblescene.lua). Did you forget to return the scene object at the end of the scene module? (e.g. ‘return scene’)” I don’t know what this means. How is it that the button stops working? [import]uid: 136344 topic_id: 31316 reply_id: 125281[/import]

Are you trying to put multiple scenes in a single .lua file or are these in separate scenes?

Normally each scene is a separate .lua file looks like:

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
function scene:createScene( event )  
 local group = self.view  
end  
  
function scene:enterScene( event )  
 local group = self.view  
end  
  
function scene:exitScene( event )  
 local group = self.view  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

Note that it returns a scene object that the storyboard code uses to move things on and off screen. I know you can have everything in a single lua file, but I’m not sure why. [import]uid: 19626 topic_id: 31316 reply_id: 125285[/import]