How do I load an Image from a URL after the game starts

Get help using Construct 2

Post » Wed Apr 01, 2015 8:14 pm

What I would like to do is load images from a server into a sprite dynamically based off of options the user chooses. Basically an image viewer. I don't know if it would be possible without custom plugin. It definitely doesn't look like you can use a sprite.
B
11
S
2
Posts: 6
Reputation: 585

Post » Wed Apr 01, 2015 8:24 pm

Nevermind I saw the option to load image from URL
B
11
S
2
Posts: 6
Reputation: 585

Post » Thu Apr 02, 2015 2:46 pm

Can I use data uri as the url for the image as a way to cache images to be viewed offline, i.e. I can save the data uri's in an array and load them offline. Edit I dont have enough street cred to post url's I am using a article on css tricks about data uri's as a point of reference
B
11
S
2
Posts: 6
Reputation: 585

Post » Thu Apr 02, 2015 2:50 pm

Yes if you mean use a "C:\image.jpg" etc that will work. However it is a bit bugged it seems, if you try to reload using "load from url" at the moment. but hopefully it will be fixed.
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,826

Post » Sat May 30, 2015 1:25 pm

@danhezee

"Nevermind I saw the option to load image from URL"

Where is this option? i want load gmae background from url but i dont know where find this event
B
104
S
25
G
43
Posts: 1,879
Reputation: 33,418

Post » Sun May 31, 2015 10:50 pm

delgado wrote:
Where is this option? i want load gmae background from url but i dont know where find this event


Add a blank sprite to the layout call it e.g. "photoHolder" and then within events select "photoHolder" and then select load image from url
B
9
S
3
Posts: 146
Reputation: 1,150

Post » Tue Nov 24, 2015 3:42 pm

'
Last edited by danieltpt on Tue Dec 15, 2015 1:59 pm, edited 1 time in total.
B
9
S
2
G
5
Posts: 33
Reputation: 3,194

Post » Tue Nov 24, 2015 3:47 pm

danieltpt wrote:Hi

I am trying to learn how to Load Image from URL. Here is my project file.

https://drive.google.com/open?id=0B19-3 ... W5DRU5XbUU

I cant seem to get it working after several tries.

Please could I get your help on this?

Thanks


Are you sure you linked the right capx?
I don't see any event or action regarding load from url..
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

Post » Wed Nov 25, 2015 9:00 am

,
Last edited by danieltpt on Tue Dec 15, 2015 1:59 pm, edited 1 time in total.
B
9
S
2
G
5
Posts: 33
Reputation: 3,194

Post » Wed Nov 25, 2015 9:08 am

danieltpt wrote:Sorry here is the correct file. thanks. https://drive.google.com/open?id=0B19-3 ... mF0QW1PbTg


Check your browser console. You'll see that you have a CORS issue, i.e. cross domain problem.

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.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
78
Posts: 5,202
Reputation: 54,811

Next

Return to How do I....?

Who is online

Users browsing this forum: AkbarAsgharMG, lwgames and 4 guests