Still connected to internet?

havana24

  • *
  • Posts: 504
Hi all,

Is there a way to check if the user is connected to internet before trying the POST/GET blocks?
Becouse without this "if statement" stencyl gives me a pop-up error if I'm not connected...

Thanks in advance,
Alessandro
My Website: www.havana24.net

captaincomic

  • *
  • Posts: 6109
Maybe you could use code to wrap the web requests in a try-catch block.

havana24

  • *
  • Posts: 504
Thanks captaincomic,
Can you give me an example?
My Website: www.havana24.net

captaincomic

  • *
  • Posts: 6109
Okay, I'm not sure if this will work, but here's the idea:

In a code block put this code
Code: [Select]
try
{
Then use the "vistit URL" or "POST data" blocks, follewed by another code block:
Code: [Select]
}
catch(e:Error)
{
print("Web request failed: " + e);
}
(This is for a Flash game, for iOS you would need different code.)

Then run the game while offline, and check the console if it prints "Web request failed: ...".