Load image from url bug

0 favourites
  • 9 posts
From the Asset Store
Elevate your games with our AI Chatbot Integration! Seamlessly connect your Construct 3 projects with GPT-4 for dynamic,
  • 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

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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.

  • 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 ?

  • 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.

  • 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 ?

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)