AsJSON am i doing it wrong ?

0 favourites
  • 11 posts
From the Asset Store
Be quick and choose whether the shown equation is right or wrong.
  • Hi

    Here i s the link

    odd

    Enter some text in the 3 boxes and press set

    Then click save. Restart the project and click load.

    I am trying to use do this

    AsJSON

    Save the object state to a string of data in JSON format, and return it. This can be downloaded or otherwise stored, and later the state of the object restored using the Set from JSON action.

    Thanks

  • can't load your example as I lack some plugin

    If you want to save it over multiple sessions, use this in combination with the webstorage object.

  • mindfaQ

    HI thanks.

    I can see how that might be useful but i dont really need the complexity. I just think what i have done should work but doesnt. Which means its either a bug or i dont understand how to use it.

  • Well not really sure what's going wrong since I can't open your project. But since this function is very simple, here a rundown how it would work if it is just supposed to be for one play session:

    variable1 = "" (text / string)

    s pressed: set variable1 = array.asjson

    l pressed: array json load from string variable1

    Not sure what can go wrong there except defining the variable as number instead of text.

  • mindfaQ

    Hi, sorry didnt realise i had used the extended textbox plugin, i have changed that now so you should be able to dl it.

    I cant see anything wrong with what i am doing tbh.

  • okay, two little things:

    • Set level to WebStorage.LocalValue("test")   -> the key is case-sensitive and you saved it as test, not Test
    • Set from JSON string level -> level is a variable, you don't want to load the word "level" as JSON

    then it works

  • mindfaQ

    Altered those two things but still doesnt work. I can see the data being saved in the webstorage but it doesnt load back in. Tried 3 browsers.

    Any other ideas?

    Thanks for helping btw <img src="smileys/smiley1.gif" border="0" align="middle" />

  • For me it works:

    s000.tinyupload.com/index.php

    (tested in Chrome, Opera)

    don't forget to press the set button before you save

  • I dont believe it. Yours is identical to mine but yours works. Which version of C2 are you running ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 152, I guess we must use the same version if we can open each others projects. Maybe you should upload your identical, not working version, so I can see if it doesn't work for me either.

  • mindfaQ

    Decided to re-boot the machine and mine works now.. very strange. Thanks for your help <img src="smileys/smiley20.gif" border="0" align="middle" />

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