Load .json file from the Files folder into Array Construct 3

  • Hi guys,

    I'm new to the forums and I apologize if this is the wrong place to post this question. I have also looked through the forums and Scirra manuals for info on this particular thing but haven't found anything or anyone that shows a specific example that can help.

    I'm on the paid plan for Construct 3 and so I have access to the Array Editor (which is awesome by the way!). What I did was right click on the Files folder in the Project navigation pane, and selected New -> Array. I then made my Array:

    Height: 2

    Width: 2

    Depth: 1

    So I saved the array as array.json (just for this example), and it appears in the Files folder.

    Now I create my Array object in my layout (double click in layout and add array object)

    So I want to load the contents of array.json in my Files folder into the new Array object. I tried to use the Load from JSON String, but there doesn't seem to be a way to specify that array.json file that I want to load. I'm guessing there is an easy way to do this without having to load the actual JSON String and just load the file since it is in the Files folder in my Project?

    Really would appreciate any help from folks who have done this before, and apologies again if this is the wrong place to ask or if someone has asked before, just couldn't find any info on this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi KitaWolf,

    This is the method I use:

    Add the AJAX object to your project.

    Add the following two events:

    1. On start of layout| AJAX: Request array.json (tag "yourArray")

    2. AJAX|On "yourArray" completed |Array Object: Load from JSON string AJAX.LastData

    You can leave the size of the array object at 0,0,0 - it will automatically resize to fit the array.json data.

    If you run the game in debug mode you can check that the json data is correctly being grabbed by the AJAX request and loaded into the Array object.

  • Hey mekonbekon,

    Excellent thank you that works great! Really appreciate your help and quick reply.

  • You're welcome!

  • Can I put into the file a lot of different arrays in json format? And after loading them as needed?

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