Load image from url bug

Bugs will be moved here once resolved.

Post » Thu Jul 16, 2015 3:52 pm

Problem Description
Load Image from URL doesn't load anything

Attach a Capx
https://www.dropbox.com/s/hgy691sk8sgj5 ... .capx?dl=0

Description of Capx
a button that set a URL into a variable
the variable is read to load image from URL into a sprite
the same variable is read to open the link in a new web page

Steps to Reproduce Bug
  • Clic on the button

Observed Result
the webpage open and show an image.
the sprite doesn't load anything

in IE: it opens the new page but there is an error message that popup:

Javascript error!
SecurrityError
http://localhost:50000/glwrap.js,line 2127 (col 4)

This may be a bug in Construct2 or something else, please reports blabla bla

Expected Result
espected the image to be loaded into the sprite

Affected Browsers
  • Chrome: YES
  • FireFox: YES
  • Internet Explorer: YES

Operating System and Service Pack
windows 7

Construct 2 Version ID
r209
B
16
S
3
Posts: 104
Reputation: 1,404

Post » Thu Jul 16, 2015 4:25 pm

@blackant

I can see possibly two problems with this:

1. Cross-domain error (have you checked browser console?)
2. You are not using the load url action correctly, i.e. you are supposed to wait for 'On image URL loaded' to trigger before trying to load an image (not essential, I think, but good practice).

If you try an image from one of the usual image hosting sites, such as 'http://i.imgur.com/QZhRLp7.jpg' then it will work.

So, essentially, not a bug, but a cross-domain issue.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Thu Jul 16, 2015 10:12 pm

zenox98 wrote:2. You are not using the load url action correctly, i.e. you are supposed to wait for 'On image URL loaded' to trigger before trying to load an image (not essential, I think, but good practice).

Actually, 'On image URL loaded' triggers once the image is successfully loaded.

The correct way would be to put the 'Load from URL' action in the clicked button event.

I agree though that is not a bug.
B
9
S
2
Posts: 19
Reputation: 660

Post » Fri Jul 17, 2015 7:36 am

hi thanks for your answers, but

what means cross domain error precisely?

because effectively if i test using the image link you give, it works...

have you checked the attached capx ? because the action is attached to the click button event

i did absolutely nothing complicated, and think the logic is good, but looks not...
i also tryed to use trigger On Image URL Loaded but it's not working because the image is not loading..

i have modified the capx to test differently but it's always not working in the r210

https://www.dropbox.com/s/drh69brjk03ax ... .capx?dl=0
B
16
S
3
Posts: 104
Reputation: 1,404

Post » Fri Jul 17, 2015 5:25 pm

Ajax requests are subject to the cross domain policy. Basically, you can only make an ajax request from the same domain. If you need something from another domain you have to have access to that server so as to explicitly tell it to allow requests from other domains. Read the Ajax object manual entry.
B
9
S
2
Posts: 19
Reputation: 660

Post » Mon Jul 20, 2015 6:45 am

i really don't understand, what makes the images from imgur accessible, comparing to those i want to use that are linked to my own site ?
B
16
S
3
Posts: 104
Reputation: 1,404

Post » Mon Jul 20, 2015 3:28 pm

@blackant please read these:

enable-cors.org/ (here you will find instructions on how to serve CORS enabled content)
developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

I can't explain it better than I already have.
B
9
S
2
Posts: 19
Reputation: 660

Post » Wed Jul 22, 2015 6:04 am

reading all this explications about cross domains doesn't really helped.

why?

because all images i want to load into my game are from my own website, into a subfolder directory...
so i can understand that they are locked from localhost, but why should they be from this subfolder ?
B
16
S
3
Posts: 104
Reputation: 1,404

Post » Thu Aug 06, 2015 12:41 pm

Closing as not a bug. The server for the given URL does not respond with the "Access-Control-Allow-Origin" header, indicating that you do not have permission to use that image remotely. This is a basic principle of web security: by default only content on the same origin (domain, protocol, port) can access resources from that origin, and outside access must be specifically whitelisted. See the manual entry on AJAX for more information about cross-domain access.
Scirra Founder
B
387
S
229
G
87
Posts: 24,245
Reputation: 192,160


Return to Closed bugs

Who is online

Users browsing this forum: BackendFreak and 1 guest