Tex box

Get help using Construct 2

Post » Sun Feb 03, 2013 10:13 pm

Hello i have downloaded the demo of cosntruc, i would like to show a text, from an url: http://www.mattepainting.be/index.txt inside the textbox.

How to do that?
thanks
B
32
S
9
G
6
Posts: 1,467
Reputation: 7,951

Post » Mon Feb 04, 2013 10:33 am

best to look through the basic tutorial
http://www.scirra.com/tutorials/37/beginners-guide-to-construct-2
B
10
S
1
G
1
Posts: 74
Reputation: 1,637

Post » Mon Feb 04, 2013 8:55 pm

Actually, the beginner tutorial won't be any help here...
You need to use the AJAX object in C2 to request the file as detailed here
(It won't work if you request it from another domain)
B
20
S
5
G
8
Posts: 325
Reputation: 6,473

Post » Fri Feb 08, 2013 3:50 pm

Thanks lemo :D
B
32
S
9
G
6
Posts: 1,467
Reputation: 7,951

Post » Fri Feb 08, 2013 6:37 pm

MMhh i have tried... actualy it look like this but its not working :s



here its the link of my app: http://mattepainting.be/test/run.html

nothing happens, that don't show the text from index.html imothep852013-02-08 18:37:46
B
32
S
9
G
6
Posts: 1,467
Reputation: 7,951

Post » Fri Feb 08, 2013 6:57 pm

Don't use AJAX.LastData as a tag (:
And also, I'm not sure that the On created is triggered if the object already exists in the layout
Try[code]On start of layout:
-> request "http://mattepainting.be/index.txt" tag "aSimpleString"
+AJAX On "aSimpleString" completed
-> Textbox: set text to AJAX.LastData[/code]
Also by renaming index.html to run.html you break a reference in the offline.appcache manifest.
You should either keep the index.html name or modify it inside the manifest.Yann2013-02-08 18:58:38
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Feb 08, 2013 7:08 pm

Ok i have done like you told me but :s result don't work :s



and the test: http://mattepainting.be/test/index.htmlimothep852013-02-08 20:16:36
B
32
S
9
G
6
Posts: 1,467
Reputation: 7,951

Post » Fri Feb 08, 2013 8:34 pm

Can someone help please?? i think the AJAX don't work.
So i have made everything, but the ajax don't want to show the link by requesting his url.

i don't know what to do, i want just to load an external text file in the text box.imothep852013-02-08 21:47:47
B
32
S
9
G
6
Posts: 1,467
Reputation: 7,951

Post » Fri Feb 08, 2013 10:16 pm

In the console you can read:
[code]XMLHttpRequest cannot load http://www.mattepainting.be/index.txt. Origin http://mattepainting.be is not allowed by Access-Control-Allow-Origin[/code]
try to put the index.text in the same folder as your "game" maybe (: (and change the url queried accordingly

The other solution would be to create a .htaccess with the proper things in it to set Access-Control-Allow-Origin properly. But it's not a good thing security-wise.Yann2013-02-08 22:17:15
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Feb 08, 2013 10:22 pm

no that change nothing, that don't work at all
B
32
S
9
G
6
Posts: 1,467
Reputation: 7,951

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, armaldio, plinkie and 19 guests