Project files & Cordova

For developers using the Construct 2 Javascript SDK

Post » Tue Jan 13, 2015 4:00 am

My plugin loads a lot of external resources included as project files, mostly using XMLHttpRequest. The problem is, even though everything works in browsers / NW, when i build using XDK and cordova / crosswalk, the project files users include for stuff like models which are normally loaded just fine using responseText and .open() aren't ever found when running on an android device. Even more strangely, everything works fine in the XDK device emulators.

I'm really trying to get around this issue but I've hit a wall since i have very little experience with xdk / crosswalk / mobile wrappers. I don't know if construct does something special with the project files specifically in crosswalk, but i've had no luck figuring out the issue thus far.

I would be so greatful for any help from @Ashley or anyone with some more intuition than me on how crosswalk / cordova work with these kinds of local files.
B
75
S
13
G
8
Posts: 1,973
Reputation: 9,841

Post » Tue Jan 13, 2015 1:00 pm

AFAIK AJAX requests to local files work on all platforms (apart from Windows Phone 8.1, but you can work around it using the old-fashioned ActiveX based HTTP request). However they can complete with a status code of 0 as opposed to 200, which kind of makes sense given there wasn't actually a HTTP response. Some code snippets assume that any response other than 2xx is a failure, so make sure your code accepts 0 as success.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240

Post » Tue Jan 13, 2015 4:35 pm

Im already checking both, it gets through but responseText is null/empty. Am i requesting a bad url? From what i gather all files are in tge assets/www/ folder which means relative urls to files should properly work. Indeed they do in the emulator but not on actual devices. Its perplexing behaviour.
B
75
S
13
G
8
Posts: 1,973
Reputation: 9,841


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests