Hi all,
I am trying to display a rectangle with loading message when the app is trying to get some data via web service call to have user a better user experience.
I tired to follow the example provided by Gilbert with no luck. See below for the link.
http://developer.anscamobile.com/code/simple-loading-message
I basically made two global functions as follows, and call the 1st one right before I call the http.request function and call the 2nd one immediately before I display the results I received from the web service call.
However, it didn’t display the message as I expected. It basically halt when making the web service call until it finished. Then show the loding message, and remove the loading message right away. So the user is not aware of the loading message as it disappeared too fast. Is there any other better way to display the loading message in the app?
Thank you.
function LoadingPage:displayLoadingMessage()
loadscreen = display.newGroup()
myRectangle= display.newRect(0, 0, display.contentWidth,display.contentHeight)
myRectangle.strokeWidth = 3
myRectangle:setFillColor(140, 140, 140)
myRectangle:setStrokeColor(180, 180, 180)
message = display.newText("Loading", 0, 0, native.systemFont, 24)
message.x = 100 + message.width\*0.5
message.y = display.contentCenterY
loadscreen:insert(myRectangle)
loadscreen:insert(message)
--Every second update the loading message
local counter = 0
function loadingMessage( event )
counter = counter + 1
if counter \> 3 then
counter = 0
message.text = "Loading" --remove the dots
else
message.text = message.text.."." --add a dot
end
message.x = 100 + message.width\*0.5
end
loadingTimer = timer.performWithDelay( 1000, loadingMessage, 0 )
end
function LoadingPage:removeLoadingPage()
timer.cancel( loadingTimer )
myRectangle:removeSelf()
message:removeSelf()
end
[import]uid: 23306 topic_id: 8047 reply_id: 308047[/import]