Javascript error while changing value to an Array

0 favourites
  • 5 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • Error while changing value to an array after load from JSON

    Javascript error is showm when a value of an array ins changed after it was first filled with a load JSON.

    Attach a Capx

    https://www.dropbox.com/s/5xxbgdwfjy2pb ... .capx?dl=0

    Description of Capx

    Just open the project, it will autoload a JSON on an array, and after that, it makes a set value in (0,0,0) = 234;

    In chrome you should see a crash, in Firefox in simple doesn't change the value

    Steps to Reproduce Bug

      Just open the project

    Observed Result

    Javascript error or the value is not changed

    Expected Result

    Change the value in the position indicated.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)

    Operating System and Service Pack

    Windows 7 Ultimate

    Construct 2 Version ID

    216

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't think that is a bug. I tried it with another json-file and I had no problem. If you try to get a value from the array you got always a zero. I think the json-file is not correct and cause the problem.

  • But the Json loads the data correctly, is at the time of changing the value in any position that crashes.

    Here you can see the crash:

    https://www.dropbox.com/s/epq8kzivone10 ... o.png?dl=0

  • Okey you were right, I thinnk the JSON vas in 2D and construct 2 requires it in 3D.

    If anyone has the same problem, this was my first JSON:

    {"c2array":true,"size":[4,4,1],"data":[[0,50,100,150],[0,500,1000,2000],[0,1000,2000,3000],[0,1500,5000,10000]]}

    And this is the correct format:

    {"c2array":true,"size":[4,4,1],"data":[[[0,50,100,150]],[[0,500,1000,2000]],[[0,1000,2000,3000]],[[0,1500,5000,10000]]]}

    You can close it as it is not a bug, thanks everyone!

  • There is a program to generate arrays. Maybe it's helpful for you:

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