Reading text from a .txt file on the internet.

0 favourites
  • 9 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Does anyone know of a way to read text into a string from a .txt file stored on the internet?

    The idea is to be able to dynamically change strings (holding information) in a game posted on many different web sites without having to manually change the strings and then re-upload the game to all the websites it is hosted on. If I could pull the information to be displayed in the strings from the internet all I would have to do is change the .txt file containing the information on the internet and this would change all the games on the internet.

    Jason

  • I guess you can look for XMLHttpRequest...

  • Yes it's possible. I remember Yann posting a example of doing this. I don't remember how he did it though. Most likely through Ajax. You can waif for him to read this thread or play with Ajax

  • It's possible with ajax, but ajax works on the same domain the page is on.

    Won't work to call .txt from other domains.

    dialog.capx

    Works fine here

    http://dl.dropbox.com/u/23551572/C2-Gam ... index.html

    But I'm pretty sure it won't work if you export the .capx in your own webhost.

  • Would XMLHttpRequest work cross domain? What ever is used has to work cross domain.

    Jason

  • It's possible with ajax, but ajax works on the same domain the page is on.

    Won't work to call .txt from other domains.

    http://dl.dropbox.com/u/23551572/C2/externalFile/dialog.capx

    Works fine here

    http://dl.dropbox.com/u/23551572/C2-Games/dialog/index.html

    But I'm pretty sure it won't work if you export the .capx in your own webhost.

    Yann, sorry to bore you, but it's common to fail when in preview mode?

    After editing the source file link

    Your capx is returning fail even if exporting it with the pre-configured address..

    dl.dropbox.com/u/47035927/temp/multi_language_test/index.html

    Edited: the issue was caused by caching it with the first try ^^

    So! People who is wondering use it, edit the TXT link before exporting it, if you export it before editing it, clear your Cache.

  • well now we should use the import files features of c2 so that it will work in preview mode.

    The preview mode doesn't work because because browsers or server (I don't remember) block ajax's cross domain requests unless the server sends header that allow it.

    But using the import files, the files are exported when preview in the same place as the script and accessible via localhost.

    Should update my old capx maybe...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The cross-domain AJAX restrictions and how to work around them (including in preview mode) are described in the AJAX manual entry.

  • well now we should use the import files features of c2 so that it will work in preview mode.

    The preview mode doesn't work because because browsers or server (I don't remember) block ajax's cross domain requests unless the server sends header that allow it.

    But using the import files, the files are exported when preview in the same place as the script and accessible via localhost.

    Should update my old capx maybe...

    Thx buddy!

    The cross-domain AJAX restrictions and how to work around them (including in preview mode) are described in the AJAX manual entry.

    Ashley, I had read the "Access-Control-Allow-Origin: *" on the manual, but still not figuring out how to configure it to send the following HTTP header.

    I tried these steps, with the conditional "When in preview":

    • Writing it on the first line of the txt;
    • Posting, with Ajax, "Access-Control-Allow-Origin: *" to "Localhost";

    Stupid tries, no idea of what I'm doing =\

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)