How do I use project files in Construct 3 ?

Get help using Construct 3!

Post » Tue Jul 11, 2017 7:36 pm

Message: fooodap can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hi folks,

I have read this blog of Ashley : https://www.scirra.com/blog/192/new-edi ... onstruct-3

Okey, it's cool, we can create and edit files but how I can use my files ?

Let's take for example the stylesheet file, I added this code for my button but doesn't work...
Code: Select all
.myButton {
        background: red;
}


I have tried also with the ajax plugin, no result...

There is an absolute path to access to our project files ?

Recently, I have bought the personal license of Construct 3 and I need to style my buttons like in Construct 2...

I'have searched a lot on the web, no answer for the moment.

Thank you for yout help
B
5
S
2
Posts: 3
Reputation: 437

Post » Thu Jul 13, 2017 10:47 am

First off, no need to post multiple times the same topics in the forums (I'm talking about the two topics you posted in the C3 forums, now all duplicates are removed).
Once is enough and will gather the required information.

Project files are files embedded within your project. You can check this tutorial - https://www.scirra.com/tutorials/328/using-project-files-in-construct-2 - to have an exact idea of what they are and what they do. The tutorial is for C2 but still applies to Construct 3.

Now it seems that what you are looking to do is actually different. You are willing to modify the CSS display of a button.
That has nothing to do with project files. Or at least not just as adding a css file.

As you can see in the button manual article (still from C2 but still applies currently until C3 has its own documentation) the button has a "Set CSS style" action.
Use this action to apply the CSS style you want.

You can possibly still use project file, but the thing is you would read the content of the file and apply it to the various elements you want, using the Set CSS style as you go.
We're now entering text manipulation you can read about and find some examples in the How do I FAQ for C2.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Thu Jul 13, 2017 12:11 pm

@ Kyatric
Thank you for the answer.

The duplication of topic is not my mistake, when I have tried to post the first topic, I got error "You can't post now, you have posted recently" (something like this, because I have posted in C2 forum) so I waited about 1 hour or 2 and tried again.
I think the first topic was posted and the error was not considered by your scripts...
Sorry however
B
5
S
2
Posts: 3
Reputation: 437

Post » Fri Sep 22, 2017 12:55 pm

For use my custom stylesheet I use the Browser Plugin.

Code: Select all
+ System: On start of layout
-> Browser: Execute javascript "
var nameFileCSS = 'myStyle.css';
var realUrlCSS = this.runtime.getProjectFileUrl(nameFileCSS );
var styleCSS = document.createElement('link');
styleCSS .rel = 'stylesheet';
styleCSS .href= realUrlCSS ;
document.head.appendChild(styleCSS );"

myStyle.css is the file's name.

Code: Select all
var realUrlCSS = this.runtime.getProjectFileUrl(nameFileCSS );

That gives you the real URL to request.

Code: Select all
var styleCSS = document.createElement('link');
styleCSS .rel = 'stylesheet';
styleCSS .href= realUrlCSS ;
document.head.appendChild(styleCSS );

That append the stylesheet to the header.

For JS I use:

Code: Select all
-> Browser: Execute javascript "
var nameScript = 'myJSfile.js';
var realUrl = this.runtime.getProjectFileUrl(nameScript );
var jsFile= document.createElement('script');
jsFile.src = realUrl;
document.head.appendChild(jsFile);"
B
22
S
9
G
12
Posts: 134
Reputation: 8,292


Return to How do I...?

Who is online

Users browsing this forum: No registered users and 0 guests