Invoking a javascript command

Get help using Construct 2

Post » Mon Jan 06, 2014 12:48 am

Is there a way to invoke a javascript command without having to write a plugin? Basically what I plan on doing is building my own chrome based wrapper for Android. Within the Android SDK there is a way to call commands to the java level using Javascript commands (and its quite simple to set up)

So I'm curious if I could call these commands within Construct somehow.
B
4
S
1
G
3
Posts: 36
Reputation: 1,147

Post » Mon Jan 06, 2014 1:49 am

The C2 Manual describes calling Javascript using the Browser plugin.
B
21
S
5
Posts: 196
Reputation: 1,974

Post » Mon Jan 06, 2014 4:27 am

Thanks much! I now have C2 talking to Android's java code. Much easier than I thought it would be.BiznessMan2014-01-06 04:29:52
B
4
S
1
G
3
Posts: 36
Reputation: 1,147

Post » Mon Jan 06, 2014 12:27 pm

Just a heads up that performance will likely be really bad if you make your own wrapper.
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Mon Jan 06, 2014 2:13 pm

The newest version of the Android SDK uses Chrome instead of WebView, although its only for 4.4 devices.

There is an open source Chrome Webview though which I've been looking at. Seems like performance using Chrome over the network is pretty solid for the most part
B
4
S
1
G
3
Posts: 36
Reputation: 1,147

Post » Mon Jan 06, 2014 9:01 pm

I guess this will be part 2

Is there anyway for the Javascript to return its value back into Construct 2? What would be the best way to achieve this? Lets say for example, I have a javascript popup box ask me for text input. How would I get that value and set it to a text object?
B
4
S
1
G
3
Posts: 36
Reputation: 1,147

Post » Mon Jan 06, 2014 10:39 pm

You should use the Javascript SDK for anything beyond simple one-liners. You can also execute javascript in the ExecJS expression and have the result returned.

The Chrome web view in 4.4 is still very slow due to some bugs - we've tried it. Crosswalk is the Chrome-powered web view you are looking for, and it is backed by Intel.
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Mon Jan 06, 2014 11:00 pm

Understood on the web view. The only reason I would want to write my own wrapper is to utilize the Ouya IAP store. As far as I understand, there isn't any native way to utilize it at this point. You would need access to the java code to make those API calls if I'm not mistakenBiznessMan2014-01-06 23:01:16
B
4
S
1
G
3
Posts: 36
Reputation: 1,147

Post » Tue Jan 07, 2014 7:33 am

just to answer how to store data into a C2 var using Browser.


Action:
set variable name: Browser.execJS("
var ret;
ret = 100 * 100;
ret;
")

you might be able to get away with
set variable name: Browser.execJS("
var ret;
ret = 100 * 100;
")

There is a Cordova plugin for Ouya IAP. There is game called Sticky Sticky that's an HTML5 tech game.
http://caou.org/stickysticky/

and the thread there Caou talks about controller and IAP
http://forums.ouya.tv/discussion/797/fixed-webview-ouyacontroller

B
90
S
18
G
9
Posts: 2,455
Reputation: 15,028


Return to How do I....?

Who is online

Users browsing this forum: FabianB, ST314 and 34 guests