Hey all, when using storyboard scenes, I add some text and a button in the following section that calls a function to do a bunch of database inserts to create new teams. The problem is that text2 does not show up until AFTER the database activity is complete, even though I call it before the database activity. See the excerpt from the function below. What am I doing wrong?
function scene:createScene( event )
screenGroup = self.view
local path = system.pathForFile(“Data.db”, system.DocumentsDirectory)
db = sqlite3.open( path )
text2 = display.newText( “Creating Teams.”, centerX, 150, native.systemFontBold, 40 )
text2:setFillColor( 1 )
text2.isVisible=false
screenGroup:insert( text2 )
local function handleButtonEvent( event )
local myButtons = event.target
local ButtonName = myButtons.id
if ( “ended” == event.phase ) then
if (ButtonName == “CreateTeamsButton”) then
CreateTeams()
end
end
end
local CreateTeamsButton = widget.newButton
{
id=“CreateTeamsButton”,
width = 369,
height = 87,
defaultFile = “CreateTeamsButton.png”,
overFile = “CreateTeamsButton-Over.png”,
onEvent = handleButtonEvent,
x=870,
y=720,
}
screenGroup:insert( NewGameButton )
end
function CreateTeams()
text2.isVisible=true
local text3 = display.newText( “Please wait…”, centerX, 200, native.systemFontBold, 40 )
text3:setFillColor( 1 )
screenGroup:insert( text3 )
db:exec(“insert into teams …[rest of the query is here]”)
…[there are about 30 queries that run here that take awhile]
text2.text="DONE!’
end
Why does text 2 and text3 show up only AFTER the database queries finish and not before?
Thanks!