[Plugin] Call Javascript

Post your completed addons to share with the community

Post » Mon Dec 09, 2013 9:38 pm

Evening!
Great plugin, just got it hooked up like a charm. Just wondering one thing though and this may be me being totally stupid, but I take it that we can't run this using preview mode?

I mean, the project has to be exported every time we update anything such as event sheets on the capx?

It got me wondering as I've been trying to get it working from the preview side, but wasn't sure if Construct has things in place that prevented one from doing so.

(hopefully it's not too late to post on this thread!) :P

Cheers!
B
5
Posts: 22
Reputation: 278

Post » Wed Dec 11, 2013 12:35 pm

You could use the "execute javascript" action available through browser object instead of this plugin. As a bonus, it works in preview!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Mon Mar 17, 2014 5:56 pm

You could open an external audio file and play it using this plugin?
if possible .... how?
Thank you.
B
4
S
1
Posts: 5
Reputation: 462

Post » Tue Dec 30, 2014 8:41 am

I want give my feedback to this plugin.

First I created a Javascript file which contain a functional Javascript code.

It works and load like a charm when the JS file is located to the SAME folder of index.html file
..
Meaning that the Scriptfile parameter of the CallJS plugin is set to:
Code: Select all
myScripts.js


But give a reference error when I want use sub-folders like: (created a 'g' subfolder and put myScript.js file into it).

Then
I set the Scriptfile parameter of the CallJS plugin to:
Code: Select all
/g/myScripts.js

OR
Code: Select all
g/myScripts.js


It won't load the file and give instead a ReferenceError error.

Want precise I use
Scirra Construct 2 BETA 192 (since I want have the Cordova Export option later!)

And Free Version.

Is it functionnal through a Personal paid Version or not too ?
Why ?
How fix it or workarounding it ?
B
9
S
1
Posts: 10
Reputation: 512

Post » Tue Dec 30, 2014 9:02 am

Atanacius wrote:I want give my feedback to this plugin.

First I created a Javascript file which contain a functional Javascript code.

It works and load like a charm when the JS file is located to the SAME folder of index.html file
..
Meaning that the Scriptfile parameter of the CallJS plugin is set to:
Code: Select all
myScripts.js


But give a reference error when I want use sub-folders like: (created a 'g' subfolder and put myScript.js file into it).

Then
I set the Scriptfile parameter of the CallJS plugin to:
Code: Select all
/g/myScripts.js

OR
Code: Select all
g/myScripts.js


It won't load the file and give instead a ReferenceError error.

Want precise I use
Scirra Construct 2 BETA 192 (since I want have the Cordova Export option later!)

And Free Version.

Is it functionnal through a Personal paid Version or not too ?
Why ?
How fix it or workarounding it ?


Oh... I found that it is only not functionnal in Node-Webkit preview or HTML 5 preview...
Well, same problem like the Load file action from Request URL within AJAX plugin.

Don't think you can do anything for that, but, look at this useful post for make a workaround for making it working:
(
I asked this question : Why we can't locally load files in Preview Mode in Node-Webkit ??

Then I got a working answer from R0j0hound:
We can though. In node-webkit preview if you use "document.xml" as the file it will look here:
"http://localhost:50000/document.xml"

If you want to get the file from the same folder as the capx you need to type it in explicitly:
"C:\Users\rojo\Documents\c2projects\document.xml"

And to make it work in preview or in export you could use a global like this:

global text AppPath = "C:\Users\rojo\Documents\c2projects\"
Start of layout
System: [NEGATE] is in preview
--- set AppPath to NodeWebkit.AppFolder

And then request any files with:
AppPath & "document.xml"

)

So If you can give us the ability to SET the Scriptfile url dynamically within a Construct 2 Action like:
-- Set Scriptfile url to

We can then be able to do this :
global text ScriptFileAppPath = "C:\my\external\path\with\subFolders\"
Start of layout
System: [NEGATE] is in preview
--- set ScriptFileAppPath to NodeWebkit.AppFolder

And then requesting our files with the new Action I talking about:

-- Set Scriptfile url to ScriptFileAppPath & "myScripts.js"
B
9
S
1
Posts: 10
Reputation: 512

Post » Sat Apr 18, 2015 3:57 am

You could just add the script file to Construct 2 by right clicking on files then left click import files then locate the script file you want to add to c2 on click open BOOM :!: :!: :!: ; that is it should work in preview mode now.
Image
This is to show that it works on my computer.
Image
P.S. Should work in any version of C2 you are using and also sometime you may get an error, it not perfect but it works.
B
26
S
5
G
1
Posts: 15
Reputation: 1,824

Post » Thu Mar 10, 2016 3:51 pm

Hello.
I use the plugin but nothing happens. The plugin is loaded by construct but the function is not read.
Any ideas?
Is it possible to have an example to download?
Thank you.


It's ok... need () after name of function.
B
4
Posts: 12
Reputation: 224

Post » Mon Oct 31, 2016 6:11 pm

I am curious, will this work if for example I have a speed variable and I want that variable to be set prior to the game starting by for example a teacher? My need is for the user to be able to set the speed of 1 or more variables prior to the game. or would this be better to do within construct setting the variable values at start of game?
B
19
S
4
G
3
Posts: 57
Reputation: 2,574

Post » Mon Oct 31, 2016 10:05 pm

luvleggs wrote:I am curious, will this work if for example I have a speed variable and I want that variable to be set prior to the game starting by for example a teacher? My need is for the user to be able to set the speed of 1 or more variables prior to the game. or would this be better to do within construct setting the variable values at start of game?



.just use the browser execute javascript function... plus this topic is from 2011 and OP is never seen online since then
ImageImageImageImage
B
47
S
12
G
43
Posts: 1,096
Reputation: 28,028

Post » Mon Oct 31, 2016 10:07 pm

gamecorpstudio wrote:
luvleggs wrote:I am curious, will this work if for example I have a speed variable and I want that variable to be set prior to the game starting by for example a teacher? My need is for the user to be able to set the speed of 1 or more variables prior to the game. or would this be better to do within construct setting the variable values at start of game?



.just use the browser execute javascript function... plus this topic is from 2011 and OP is never seen online since then


Thanks, I thought I saw recent activity but I was searching two topics and it was the other.
B
19
S
4
G
3
Posts: 57
Reputation: 2,574

Previous

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 6 guests