Hola Leogallardo, How are you?
I see you speak Spanish but I am posting this in English so anyone can read it. I saw this post a couple of days ago and also see that no one has replied to the bug you've logged so far.
I was facing a similar issue using the Parse extension from mdotedot where I wanted to check the user's internet connection to make sure I could use the parse extension first to connect to the database and the same happened to me that the game was freezing but in my case it happens in both Flash and Mobile.
I am not a programmer but I understand a bit and I can get around this so what I did is to check the Stencyl API here
https://github.com/Stencyl/stencyl-engine/blob/master/Source/com/stencyl/behavior/Script.hx and I found that the visitURL block works as follows:
public function visitURL(URL:String, fn:Event->Void = null)
{
if(fn == null)
{
fn = defaultURLHandler;
}
try
{
var request = new URLRequest(URL);
request.method = URLRequestMethod.GET;
var loader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, fn);
#if flash
loader.addEventListener(IOErrorEvent.NETWORK_ERROR, defaultURLError);
loader.addEventListener(IOErrorEvent.IO_ERROR, defaultURLError);
#end
}
catch(error:String)
{
trace("Cannot open URL.");
}
}
You can see there that there is an if stament for Flash where it adds event listeners for IO error events but it doesn't do the same or similar for mobile.
Digging a bit deeper and looking at the API documentation here:
http://static.stencyl.com/api/31/ I saw that there is a close() method that it closes any load operation in progress is immediately.
I couldn't get around using the visitURL block from Stencyl and adding a short piece of code to use the close() method but what I did is to remove the visitURL block completely and I added some code directly into Stencyl.
Basically what I did is to try to load a simple file that returns just a txt file with a number 1 as a response and if after 0.5 seconds a variable that I set to = site's response IS NOT variable = 1 then I assume that the connection was not successful and I couldn't set my variable equals to "1" as per the site response should be, therefore I close the connection and the game continues (previously notifying the user to check his/her internet connection ).
The code I used in the custom code block is as follows:
// I grabbed this code from the Stencyl API in github
function visitURL(URL:String, fn:Event->Void = null)
{
try
{
var request = new URLRequest(URL);
request.method = URLRequestMethod.GET;
var loader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, fn);
#if flash
loader.addEventListener(IOErrorEvent.NETWORK_ERROR, defaultURLError);
loader.addEventListener(IOErrorEvent.IO_ERROR, defaultURLError);
#end
//making sure the connection closes after 0.5 secs so the game doesn't freeze
runLater(500 * 1, function(timeTask:TimedTask):Void
{
loader.close();
});
}
catch(error:String)
{
trace("Cannot open URL.");
}
}
visitURL("
https://YOUR_URL_THAT_HOLDS_THE_SMALL_TEXT_FILE_1.txt", function(event:Event):Void
{
// I set my Game atribute "Connected" to the site's response which should be "1" as per the littler txt file
setGameAttribute("Connected", ("" + cast(event.target, URLLoader).data));
});
If I add a screenshot of my blocks in Stencyl it probably won't help and it could be confusing but if you've got any questions please let me know.
It worked for me calling that close() method after 0.5 seconds to interrupt the connection so the game doesn't freeze in mobile, only tested it in my mobile android 4.1.2.
Hope it helps.
Cheers,
David07