How do I call a C2 function from Html ?

Get help using Construct 2

Post » Thu Mar 20, 2014 3:05 pm

Hi !

I need to call a C2 function in JS from my html page.

I know this question has already been asked, I went through a few posts about this on the forum.
But I only found a short clear answer : you should make a plugin.

Is there really no other way to do this ?
The opposite (calling a JS function from C2) is really easy with Browser.ExecuteJavascript.

I need to open a custom html login form from C2, and when logged in, I must send back to C2 that "we're logged in".
I could make an ajax call in C2 every X seconds to check if we're logged in or not, but for me it's not a proper way to do this.

If I must use a plugin to communicate from my page to C2, is there any demo / tutorial for this ?
I don't have too much time to implement this feature so I'm looking for the quickest way.
I know there are plugins like clay.io but I need to keep all the data in my own DB and I don't want any reference to an external service in my forms.
B
4
Posts: 5
Reputation: 210

Post » Fri Mar 21, 2014 9:18 am

Yes, the only way is to make a plugin. It should not be difficult if you have any knowledge of Javascript.
Scirra Founder
B
397
S
236
G
88
Posts: 24,389
Reputation: 194,448

Post » Fri Mar 21, 2014 9:23 am

When your loginpage is in HTML and not in C2, why don't you just login first and then open the index.html from c2 (Where you could also check if you're logged in).
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Fri Mar 21, 2014 9:24 am

Pass informations from the HTML page to the C2 application - LINK

From the How do I FAQ

Some kind of hack, but could be useful.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
291
S
114
G
95
Posts: 7,290
Reputation: 70,138

Post » Fri Mar 21, 2014 11:40 am

Message: clemorphy is not yet permitted to post plain text URLS (300 rep required). 2 URLS removed. Why?
Ashley wrote:Yes, the only way is to make a plugin. It should not be difficult if you have any knowledge of Javascript.

Yes, that's what I thought, the plugin system seems to fit my need, but I would have to spend some time to read the plugin documentation, watch some examples, do some tests etc ...
I'll definitely look into that, but for now I think I'll go for a less elegant but quicker solution.

Vuuv wrote:When your loginpage is in HTML and not in C2, why don't you just login first and then open the index.html from c2 (Where you could also check if you're logged in).

Actually it's a game where you can play the first level without being logged in, and then at the end of this first level, you must log in or create an account to continue.

Kyatric wrote:
Pass informations from the HTML page to the C2 application -

From the Some kind of hack, but could be useful.


Interesting, I could use this to know when I have to do my Ajax request from C2.
B
4
Posts: 5
Reputation: 210


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests