progressView updating woes

Hello again.  I’m preloading 20 scenes and it is taking some devices 20 seconds to complete. I’d like to use the widget progressView but I’m stumped at getting it to update or animate during the loading process.  Here’s my latest attempt where I thought when a function ended it would update graphics and show the progress. createScene calls preload()

progressView = widget.newProgressView {     left = 150,     top = display.contentHeight - 100,     width = 300,     isAnimated = false } function loaderUP1()   local page1 = storyboard.loadScene( "page1", false )   progressView:setProgress( 0.05 )   loaderUP2() end function loaderUP2()   local page2 = storyboard.loadScene( "page2", false )   progressView:setProgress( 0.1 )   loaderUP3() end -------more---- function loaderUP20()   local page20 = storyboard.loadScene( "page20", false )   progressView:setProgress( 1 )   removeLoadings() end local t = {} function t:timer( event )   timer.cancel( event.source )   loaderUP1() end function preload()   timer.performWithDelay( 500, t, 0 ) end  

and you guessed it, the progressView never moves a bit, it’s up for the duration then is removed.

thanks for any help!

Try this:

local progressView = widget.newProgressView { left = 10, top = display.contentHeight - 100, width = 300, isAnimated = false } local timerID local i = 1 local function loadScenes() storyboard.loadScene( "page" .. i, false ) progressView:setProgress( 1/20 \* i ) if i == 20 then removeLoadings() timer.cancel(timerID) end i=i+1 end timerID = timer.performWithDelay( 500, loadScenes,0)

This works great!  

But I’m not sure how it works.  The timer fires every 500 regardless of what storyboard.loadscene is doing.  Does storyboard.loadscene only do one at a time, it doesn’t do 2 at once?  Why does this not crash when the last scene takes longer than 500 to load, won’t the timer fire off again and look for a scene that doesn’t exist?

I left the 500ms timer there because you used. I would use something like this:

local timerID local i = 1 local function loadScenes() storyboard.loadScene( "page" .. i, false ) progressView:setProgress( 1/20 \* i ) if i == 20 then removeLoadings() else i=i+1 timer.performWithDelay( 10, loadScenes) end end loadScenes()

Try this:

local progressView = widget.newProgressView { left = 10, top = display.contentHeight - 100, width = 300, isAnimated = false } local timerID local i = 1 local function loadScenes() storyboard.loadScene( "page" .. i, false ) progressView:setProgress( 1/20 \* i ) if i == 20 then removeLoadings() timer.cancel(timerID) end i=i+1 end timerID = timer.performWithDelay( 500, loadScenes,0)

This works great!  

But I’m not sure how it works.  The timer fires every 500 regardless of what storyboard.loadscene is doing.  Does storyboard.loadscene only do one at a time, it doesn’t do 2 at once?  Why does this not crash when the last scene takes longer than 500 to load, won’t the timer fire off again and look for a scene that doesn’t exist?

I left the 500ms timer there because you used. I would use something like this:

local timerID local i = 1 local function loadScenes() storyboard.loadScene( "page" .. i, false ) progressView:setProgress( 1/20 \* i ) if i == 20 then removeLoadings() else i=i+1 timer.performWithDelay( 10, loadScenes) end end loadScenes()