bmcdaniel's Recent Forum Activity

  • Trying to run a Javascript function I have added into the body of the index.html to return a JSON string I can add into an Array inside of Construct2.

    [attachment=0:3l5z7udg][/attachment:3l5z7udg]

    Here is the javascript I add in the body of index.html:

    <script type="text/javascript">
    		function gameJSON()
    		{
    			var myGameJSON =  <cfoutput>#myJsonVar#</cfoutput>;
    			return myGameJSON;
    		}
    	</script>
    [/code:3l5z7udg]
    
    This code functions in the browser console and returns a correct JSON to the browser console. I also know it gets called in construct2 because I have added an alert and I have am seeing the alert.
    
    I have looked at the input from Browser.ExecJS("gameJSON();") by appending it to a text string and the value is just = "0".
    
    Questions:
    1. Can I use Browser.ExecJS to request a JSON string and then use that to load to my "ArrayInfo"?
    2. Is there a better method to reference a Javascript function on index.html accessed via the Browser object and get the JSON inside construct2?
    
    Any help is greatly appreciated.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley

    Trying to set up a way to get a Javascript function I add to the page where my construct2 game is to run and return a JSON string which can be used by Construct2 to create an array.

    I have a JSON string built. and I define that array in javascript and I am able to return the JSON using the console and asking for it using something like "window.myJSON();"

    I have been trying to get this JSON into construct2 using:

    ArrayJSON | Load from JSON string BROWSER.ExecJS("window.myJSON();")

    But no luck. Need help with what to do so I can get this JSON from the browser. Any ideas?

    Currently; I export the HTML5 code and then using Notepad++ add the <Script ... into the header of the index.html page and run the game on my server.

bmcdaniel's avatar

bmcdaniel

Member since 30 May, 2014

None one is following bmcdaniel yet!

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies