How to keep Array values upon re-loading?

0 favourites
  • 3 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi community,

    I have an array, and in the layout one I request it with Ajax and load the Ajax.LastData... as usual.

    But I also need to use this array in layout two, so I do the same thing in the start of layout two.

    In layout two I change some values in the Array, till here, all okay. But when I come back to layout one, all values return to the initial value. Does it means that every time that I load the Array, it will be loaded with the initial values?

    And if so, please shoot me a tip on how to work around it. I'm probably missing something.

    Thank you very much!

    Isaac

  • Arrays are global and you dont need to load them in every layout. If you do it once it can be used on every layout. If you load an array on start of layout, you have to check if this has already happened. You can give your array an instance variable/boolean and set it to 1/true after it loaded the json. Then add a second condition to your event like: 'On AJAX completed' AND 'Array Variable = 0' / 'Array Boolean is false'.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes kriand , this works! Thank you :)

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