I am unable to test this or my own code under Beta 7 as it has expired (which what I have been using while transitioning to 2.0) but my code used to run error free before
But under Beta 8 the code mike posted errors on line 8 as you say. This was not the case in the past as my code was fine.
Here is s slightly different block of code but I have used the same principal for each screen, call a disable screen function/method that takes down the screen and disposes of the assets before drawing the next one.
This now errors:-
function Menu(pageFadeOn)
local function disableMenuPageButtons(event)
print ("*** You have entered disableMenuPageButtons()")
bntStart:removeEventListener( “tap”, Start)
for i=grpBackground.numChildren,1,-1 do local child = grpBackground[i] child.parent:remove( child )end
print ("* grpBackground count = “…#grpBackground…” if 0 all objects removed from display group")
print ("*** nilScreenItems()")
bntStart = null
menuBackgroundImg = null
grpBackground = null
end
local function Start ( event )
print("*** You have selected Start() button")
media.playEventSound(buttonMenuExitSID)
timer.performWithDelay( globalDelay, disableMenuPageButtons)
clueSelected = 0
currentPageNo = 1
PageSetup(globalPageFade)
end
bntStart:addEventListener( “tap”, Start)
end
I have discovered that the reason is the location of the function Start if it is not local all works ok.
So that leaves we with two question
1-If a function is not prefixed local is it global (visible outside Menu() or global in as much as local to the code inside Menu()
2-When should a function be local as I though good practice was always local unless there was a need to be global as then when a block of code is not executed say a function it’s sub functions are removed from memory. Where as if they are functions within function but defined global they are all in memory for the duration of execution of main() so to speak.
Thanks for your help
[import]uid: 5872 topic_id: 2300 reply_id: 7121[/import]