Dasat's Forum Posts

  • Yann, the jsonDasat capx is still not updated

  • Yann, the capx on foreachproperty

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm trying to set a list and another text box from a dictionary by using the st from json action with the expression dictionary.asjson but none of them seems to respond

  • Yann,

    Wow, you are a good teacher!!!, at the beginning i was feeling dumb realizing what i was actually doing, but i think i have a better understanding now.

    But, for the capx you sent, in the third method, if you check the debugger you would see its only adding the first property object and not the second, also, if you don't mind i would appreciate you shedding light also on retriving values by using the json.value expression:

    i expect setting text to json.value(0,"path","to","an","object") to spilll out all the contents of the object, or adding a key after the object to return the value of the key, but i keep getting undefined, when i attempt this

    Dasat

    If you run the capx in the debugger (Ctrl+F5) you should see that:

    {
      "name": "dasat",
      "properties": {
        "property_name": "thermal"
      }
    }[/code:1zc6eo4u]
    which is not nothing, but yeah, not what you want for now
    
    Let's comment what you did line by line so I explain a few things:
    
    [code:1zc6eo4u]
    + System: on start of layout
       // in javascript it could be represented as: var root = {};
       -> JSON: new Object at root@    
       + [empty]
          // here you are redoing: root = {}; which basically discard the first object
          -> JSON: new Object at root@ 
          // here current and root are the same, so you are doing:  root["name"] = "Dasat";
          -> JSON: set "Dasat" at current@"name" 
          // you set the current path to the current path, so nothing changes
          -> JSON: Set Current Path to current@  
          // here you do root["properties"] = [];
          -> JSON: new Array at currentapg@properties 
          // here that make sens, now current is root["properties"]
          -> JSON: Set Current Path to current@"properties" 
          // you do root["properties"] = {}; so your array gets discarded
          -> JSON: new Object at current@  
          // root["properties"]["property_name"] = "electrical"
          -> JSON: set "electrical" at current@"property_name" 
          // root["properties"]["property_unit"] = "wareva"
          -> JSON: new "wareva" at current@"property_unit" 
          // here you basically discard the object at root["properties"] and replace it by an empty one
          -> JSON: new Object at current@ 
          // root["properties"]["property_name"] = "thermal"
          -> JSON:  new "thermal" at current@"property_name" 
    [/code:1zc6eo4u]
    To summurize I'll write in javascript only what you did
    [code:1zc6eo4u]
    var root = {};
    root = {};     //which basically discard the first object
    root["name"] = "Dasat";
    root["properties"] = [];
    root["properties"] = {}; // discard the array
    root["properties"]["property_name"] = "electrical";
    root["properties"]["property_unit"] = "wareva";
    root["properties"] = {}; // discard the previous object
    root["properties"]["property_name"] = "thermal";
    [/code:1zc6eo4u]
    So here the result showing in the debugger makes sens
    
    Let's travel from javascript back to the JSON plugin
    What you want to generate is:
    
    I'm trying to have something like let's build a basic addition and multiplication table, like what we learnt whe we were young (but yeah, 0-based for simplicity):
    [code:1zc6eo4u]
    [
    >    {"name": "dasat,
    >     "properties": [
    >           {"property_name": "conductivity", "property_unit": "wareva" },
    >           {"property_name": "restitivity", "property_unit": "ohmmeter"}
    >       ]
       }, 
       {"name": "dasat2,
       "properties":[
    >          {"property_name": "conductivity2", "property_unit": "wareva2" }
    >          {"property_name": "restitivity2", "property_unit": "ohmmeter2"}
    >       ]
       }
    ]
    [/code:1zc6eo4u]
    
    in javascript you can do it like that:
    [code:1zc6eo4u]
    var root = [];
    root[0] = {};
    root[0]["name"] = "Dasat";
    root[0]["properties"] =  [];
    root[0]["properties"][0] =  {};
    root[0]["properties"][0]["property_name"] = "conductivity";
    root[0]["properties"][0]["property_unit"] = "wareva";
    root[0]["properties"][1] =  {};
    root[0]["properties"][1]["property_name"] = "restitivity";
    root[0]["properties"][1]["property_unit"] = "ohmmeter";
    root[0] = {};
    root[1]["name"] = "Dasat2";
    root[1]["properties"] =  [];
    root[1]["properties"][0] =  {};
    root[1]["properties"][0]["property_name"] = "conductivity2";
    root[1]["properties"][0]["property_unit"] = "wareva2";
    root[1]["properties"][1] =  {};
    root[1]["properties"][1]["property_name"] = "restitivity2";
    root[1]["properties"][1]["property_unit"] = "ohmmeter2";
    [/code:1zc6eo4u]
    
    Some equivalents with the JSON plugin would be:
    [url]https://dl.dropboxusercontent.com/u/23551572/C2/JSONDasat.capx[/url]
    
  • Yann, I'm here again, i tried creating the sample json you used for the inspection capx with the plugin and i'm having some issues.

    In a bit to achieve the nested array and objects, when i get to the debug mode somethings my json is just empty. what i'm I doing wrong? My sample capx is here

  • septeven, some of us are still looking out for the plugin

    Fimbul

    After this message, I dediced to make quickly a new plugin - It should be compiled in the week.

    Here is what you can expect to do (fully customizable - colors, dimensions, fonts, styles...)

  • Yann, I've handled access origin. I fugured out the problem was with my content type header. Its form instead of Json. I tried using ajax set header to set the content type to app/Jason, but its like its appending it so I get something like content type: xxx-form blabla,application/Json. I posted this on the how do I forum butbim yet to get any help. So my server keeps returning bad request, which implies it knows the data coming is Jason but the header says its form. That is what I need to fix now:the ajax set header action!! Thanks for all the help.

    Dasat

    Well to debug your problem you have a lot of options:

    - you can print the resulting string by inserting the browser plugin and in the action Browser: log(JSON.AsJson(0)) Then you can copy paste the result in http://jsonlint.com/ to see if the json is valid

    - you can check if the javascript console gives any error like the famous [quote:r0tn3ua6]XMLHttpRequest cannot load http://scirra.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.google.com' is therefore not allowed access.

    whose solution is to either host your game on the same server you are querying, or, make the server send the Access-Control-Allow-Origin: * header

    • you can check your own server side code to se if everything is ok

    And well, if the problem persist, give more detail.

    What would you do if a friend was asking for help on an arithmetic problem without showing you the actual problem? <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> (considering you have enough arithmetic knowledge, but that's not the point here)

  • Bump

  • I'm currently trying to pass a json data, and i want to change my ajax request header to application/json. This is waht i keep getting on my server Content-Type: application/x-www-form-urlencoded, application/json.

    I used the ajax action of set request header, but it seems to be appending or so. How do i fix this, i only want the application/json, because django is still seeing it as a form

  • brunopf, were you able to find a way aroun thism i found out the ajax, action set request header is suppose to do this, but mine keeps sending application/x-www-form-urlencoded,application/json. I need to get rid of the x-www part. any ideas

    Hello,

    I am developing an educational game which consists in both the game and a web platform for the teachers to register new questions and have feedback from the students.

    I am trying to send the data from the in-game (user registering form) to the rails application using JSON & AJAX. My problem is that rails needs the post request with the content-type headers as JSON, which is not possible natively in construct 2.

    Is there any alternative AJAX plugin that let me change the headers content? Any other solution?

    I appreciate any help.

    Thanks

  • Yann, please i'm trying to pass the data in my json object to a database using ajax post, what would be data format be, i used "data="&Json.Asjson(0), but i keep getting error, am I wrong?

  • caiorosisca, I'll try it out, thanks. But i guess it should work, with some other ideas i can input

    I,ve never used this lists but my Idea would be to spawn/update a list depending on what your mouse cursor is above. Like on your second image, Mouse is over NavigationItem3 on dropdown1, so have your dropdownlist2 set to visible(or spawn it), update its position to navigationItem3Y and navigationItem3+navitaionItem.width, update it's values accordingly. Hardest part would be preparing all the values, you can use arrays and a xml/json file with all the info.

  • Bump

  • You could also right click on your layout and choose edit event sheet

  • Please, how do i achieve this type of multiselection as shown in the attachments.

    I want the user to be able to select more than one option, and note that each option has some children that should be displayed. Also the number of options is dynamic. Not necessarily 5 through out, it could change depending on a variable.