0 Favourites

Loading image from the internet.

  • This feature of the sprite object doesn't seem to work at all!

    I need to have an image loaded from a URL and displayed in my application, however i cannot get this to work properly with the default sprite object.

    Here's what i'm trying to do:

    Keyboard | On Space pressed --- sprite | Load image from "http://gamemakerblog.com/wp-content/uploads/2011/02/construct-2-logo.png" (Resize to image size)

    I even tried to add a text object which would show when the image is supposed to show, but this shows me that the event fired by pressing the space triggers, however the "On image URL loaded" never triggers. Testing in Chrome without WebGL, internet connection is fine.

    The test image i use:

    <img src="http://gamemakerblog.com/wp-content/uploads/2011/02/construct-2-logo.png" border="0" />

    Nothing is displayed. What am i doing wrong?

  • Update (and a shameless bump), the console of the chrome browser shows the following:

    Cross-origin image load denied by Cross-Origin Resource Sharing policy.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I think the problem is with permissionsof the server, some website let you do that, others don't, the manual says:

    Load image from URL

    Load an image from a given URL. The current animation frame will be replaced with the image. It is not shown until the image has finished downloading, and On image URL loaded triggers. Images loaded from different domains are subject to the same cross-domain restrictions as AJAX requests - for more information see the section on cross-domain in the AJAX object. Data URIs can also be passed as an image, e.g. from a canvas snapshot or webcam image. The Size parameter sets whether the Sprite object will be set to the image size when it loads, or whether to keep its current size and stretch the image.

    and so the part about cross domain request here counts: scirra.com/manual/107/ajax

    EDIT:Ninja'd by the OP,that was weird

  • Aphrodite I already checked the manual, but i've also tried about 4 or 5 different images including ones from Photobucket, which supposedly allow cross-requesting. A google search turned up a StackOverflow page, in which people claim that this is a bug with chrome... >_>

    Edit: However, images can easily be loaded from a base64 string. Any idea how i could convert an image to such a string somewhere online and then just retrieve the string to be loaded?

    also, ninja'd

  • It works perfectly in Node-Webkit (and probably other browsers). It appears that i might have to switch browsers (assuming that this is isolated to chrome). >_>

    Update: It appears that it indeed might have been have a problem with the host, as images from dropbox load just fine. But why did the Webkit work, then?

  • It works perfectly in Node-Webkit (and probably other browsers). It appears that i might have to switch browsers (assuming that this is isolated to chrome). >_>

    Update: It appears that it indeed might have been have a problem with the host, as images from dropbox load just fine. But why did the Webkit work, then?

    One theory (I can be wrong) could be that Node Webkit applications don't suffer from the same restriction, as the C2 manual stated that browser manufacturers havechosen to do this (for security reasons)

  • *sigh*

    I am now considering making something in CC that would parse the content of such sites. Either way, i guess i'll just stick to the dropbox for now.

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