Dictionary - on loaded?

  • Hi.

    I'm working on a project where I load the dictionary from JSON.

    How can I know when the data from JSON is loaded into the dictionary? I use "function" to get data, and load from "function.call" (return value).

  • Dictionary.Load is immediate. It's not technically "loading" from a stream. It's taking the already stored JSON string in memory and then converting the JSON into the Dictionary storing mechanism. So there is no need for when Dictionary is finished as it's finished the moment the action is done. you can start using data in the same event.

    So

    Start -> AJAX.Load( file )

    AJAX.OnLoad -> Dictionary.Load( Ajax.lastdata )

    -> Dictionary is ready to use.

  • Seems right ... But it sometimes happens that, if I have "Dictionary|Is empty" condition just after the "Load" action, it recognizes it as empty. Is it possible that it's because I'm calling function?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Seems right ... But it sometimes happens that, if I have "Dictionary|Is empty" condition just after the "Load" action, it recognizes it as empty. Is it possible that it's because I'm calling function?

    Do you mean within the same event, or two different events?

  • Here's my code:

    But if I do like this, it doesn't work (sometimes works, usually not):

  • grigrizljac that looks pretty funky. I am having trouble determining exactly why you are doing, what you are doing with that fragment. Do you have your capx to look at?

  • I get the data from Local Storage, then call a function to decrypt it, and what is returned, I load into the Dictionary.

    With "Is empty" I want to check if the data was OK, not corrupted.

  • I get the data from Local Storage, then call a function to decrypt it, and what is returned, I load into the Dictionary.

    With "Is empty" I want to check if the data was OK, not corrupted.

    Yes, but how are you storing it? When are you calling the store/retrieval? I don't see anything wrong with that snippet of code. I could be overlooking something, but the issue could be elsewhere.

  • It seems everything works now. Thanks for help and replies.

  • It seems everything works now. Thanks for help and replies.

    Glad it worked out. What was the solution

    ?

  • > It seems everything works now. Thanks for help and replies.

    >

    Glad it worked out. What was the solution

    ?

    Actually, I haven't changed nothing (at least I don't remember anything). Probably I had a bug somewhere or something.

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