Browser.ExecJS return Date to Construct 2 var

Discussion and feedback on Construct 2

Post » Sat Jul 15, 2017 2:04 pm

I do not really understand how to work with Browser.ExecJS And I am trying to return a date value with the code.
var a = new Date();
I'm trying toreturn var a but without success

Image
B
13
S
2
Posts: 95
Reputation: 861

Post » Sat Jul 15, 2017 2:13 pm

i try :
Browser.ExecJS("var a = new Date(); alert(a);")
ane its work good but if i try to retun it :
Browser.ExecJS("var a = new Date(); return a;")
its dont work.
B
13
S
2
Posts: 95
Reputation: 861

Post » Sat Jul 15, 2017 2:16 pm

ooooops i use number it's OK now
B
13
S
2
Posts: 95
Reputation: 861

Post » Sun Jan 28, 2018 3:40 pm

maordany wrote:i try :
Browser.ExecJS("var a = new Date(); alert(a);")
ane its work good but if i try to retun it :
Browser.ExecJS("var a = new Date(); return a;")
its dont work.


In case someone run into this (C2 + C3) and it doesn't work for him.
What ExecJS does in Runtime 2.0 seems to be connect strings first and then just cast javascript eval function. So in case you have code like:

Image

where in each loop you want to increase timeL += dt, your code could look like this:

Image

notice core part with (function() { doYourThing; return whateverYouWant; })()
B
5
Posts: 2
Reputation: 249


Return to Construct 2 General

Who is online

Users browsing this forum: Rice games and 1 guest