Get variable in Execute Javascript Action

Get help using Construct 2

Post » Fri Feb 21, 2014 6:51 pm

Hello, I have a problem.

I need to know how to define this existing variable in event sheet before call this javascript function.

This .capx

https://dl.dropboxusercontent.com/u/762 ... oblem.capx


I tried to click anywhere, then I got an error that this variable is undefined.


Could you help me how to solve it?


Thanks!
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Sat Feb 22, 2014 12:16 am

B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Sat Feb 22, 2014 12:21 am

Global Text ThePlace = "World"

Mouse On any click - Browser Execute javascript
"alert( 'Hello "&ThePlace&"')"
B
10
S
2
G
1
Posts: 202
Reputation: 1,555

Post » Sat Feb 22, 2014 1:11 am

@Noncentz705 I've tried with your method and I got an error as Unexpected identifier.

This is snippet that I've used.
Code: Select all
"window.open ('http://maps.google.co.uk/maps?q=' + "& ThePlace &" + '&iwloc=A&hl=en', "& ThePlace &"); "


Unusual connotation?
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Sat Feb 22, 2014 2:15 am

"window.open ('http://maps.google.co.uk/maps?q="&ThePlace&"')"
B
10
S
2
G
1
Posts: 202
Reputation: 1,555

Post » Sat Feb 22, 2014 4:08 am

@Noncentz705 Thanks! It worked.

It seems it doesn't use operators such as +, does eval(); would work with operators? maybe not.

I understand this method, I will implement Google Analytics event track to send report data, when ga.js is implemented on index.html, according to https://developers.google.com/analytics ... ntTracking

Code: Select all
"_gaq.push(['_trackEvent', 'Game', 'Win', ' "& Variable1 & " ',  ' " & Variable2 & " ', false]);"


Does this string look correct to you?
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Wed Feb 26, 2014 4:59 am

Im here again, it seems working, but I would like to do a callback.


How to make a callback using Browser Execute javascript ?
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361


Return to How do I....?

Who is online

Users browsing this forum: alextro, Ryan Kocourek and 6 guests