How do I load Images from Internet

Get help using Construct 2

Post » Mon Jan 25, 2016 8:55 pm

Hi, I need to Download an Image an set it to a sprite, using the load Image from Url command.
Is that possible? and How it is done?
B
23
S
3
G
1
Posts: 67
Reputation: 2,901

Post » Mon Jan 25, 2016 9:01 pm

If you are trying a cross-domain request:
(This is about Ajax, but I believe the same applies to "load from url")

Making AJAX requests cross-domain or in preview

By default, browsers block AJAX requests across domains. This means, for example, a game on scirra.com can request other pages on scirra.com, but cannot request pages on facebook.com. This is an important security feature of web browsers (it is not specific to Construct 2 or its AJAX object).

Also, when previewing in Construct 2 the game runs on localhost. This counts as a different domain to the rest of the internet, so typically AJAX requests to any web page will fail during preview, unless the server explicitly allows cross-domain requests.

If you want AJAX requests to your server to work from any domain, or in preview, you can configure it to send the following HTTP header:

Access-Control-Allow-Origin: *

This will enable AJAX requests from any domain, but you should still be aware of the possible security implications of this. For more information on cross-domain requests see HTTP access control on MDN.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: BlueGuy3, ColombageEnPLS, FlyingRam, Zaksoid and 3 guests