Using Loaded *.js resources

Post » Mon May 15, 2017 12:59 pm

I see you can load *.js files to your project in the full version of C3. What can you actually do with these *.js files? I don't see any way that you can actually call a function inside a *.js file resource using the Function object, though that would be handy for snippets that are too small and game-specific to justify a full-blown addon.
B
16
S
5
G
3
Posts: 30
Reputation: 2,245

Post » Mon May 15, 2017 8:43 pm

The use is probably identical to what you can do in C2. You use the browser object to be able to run js code. However to use code in a file you need to load it first.

Here is a c2 example that uses jquery to load the file:
nima-web-based-2d-bone-and-mesh-animation-app_p1110744?#p1110744

This one does it without jquery which is important since c3 no longer has jquery included.
https://www.dropbox.com/s/7ueb6v9l7395o ... .capx?dl=0
It still won't work if imported to c3. The c2_callFunction needs to be changed to c3_callFunction.

It has the benefit of being a way to try javascript code with your project without making a plugin. However it's much less readable and more error prone.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Tue May 16, 2017 3:53 am

Thank you. I didn't even think of trying the browser object.
B
16
S
5
G
3
Posts: 30
Reputation: 2,245

Post » Thu May 18, 2017 3:25 am

Looks like trying to load the *.js in preview mode is blocked by not knowing the location and name of the resource for use in URL to load. Anyone know if there is a way to dynamically get the location and name of a resource file? Then I could pass that on to the JavaScript to let me load the *.js file for use.
B
16
S
5
G
3
Posts: 30
Reputation: 2,245


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests