How to update display.loadeRemoteImage

Hi there,

I’m loading a remote image from a series of remote images and placing it in the scene.

But I also have have 2 buttons - one left arrow , one right arrow - and those two buttons need to loade either the next , or previouse, remote image.

So my question is - how do I update the existing remote image to a new one ?

Hope this makes sense, else please just let me know - and I’ll try to elaborate :slight_smile:

Best Wishes

/Thomas

Hi @thomas1,

Loading a remote image essentially creates a normal display object (assuming that the image was successfully downloaded). So, once it’s on screen, it’s just like a normal display object… and that means you can’t “update” it, but instead, you’ll need to remove that one and load another one in its place as a separate object.

Hope this helps,

Brent

Hi Brent,

Thank you very much for you’r reply - unfortunatly I can’t get it to work.

I tried the following ( using storyboard ):

  1. At the start of the script I call : local windImage

  2. Before scene:createScene I have a function with windImage:removeSelf()

3)with in scene:createScene I call : windImage = display.loadeRemoteImage(…)

And later I have a remote listener for the function in step 2.

When I fire the windImage:removeSelf() I get a an error “Attempt to index upvalue ‘windImage’ (a nil value)”

Which lead me to the doc’s where I noticed that the display.loadeRemoteImage has a return type of none - which pretty much explains the nil error.

My question therefor is - how do I remove the display.loadeRemoteImage correctly.

Best WIshes

/Thomas

Thomas,

I think you missed out something in the docs (http://docs.coronalabs.com/api/library/display/loadRemoteImage.html)

This a convenience method, similar to network.download(), which returns a display object containing the image, as well as saving the image to a file.

You do get back the image @ the network listener thru ‘event.target’. You can also access the image as a downloaded file. I am using it and works fine.

Thomas,

I think you missed out something in the docs (http://docs.coronalabs.com/api/library/display/loadRemoteImage.html)

This a convenience method, similar to network.download(), which returns a display object containing the image, as well as saving the image to a file.

You do get back the image @ the network listener thru ‘event.target’. You can also access the image as a downloaded file. I am using it and works fine.

Perfect yosu !

Setting assigning the windImage local to event.target in the Networklistner solved the problem.

Thank you so much :smiley:

Best Wishes

/Thomas

Hi @thomas1,

Loading a remote image essentially creates a normal display object (assuming that the image was successfully downloaded). So, once it’s on screen, it’s just like a normal display object… and that means you can’t “update” it, but instead, you’ll need to remove that one and load another one in its place as a separate object.

Hope this helps,

Brent

Hi Brent,

Thank you very much for you’r reply - unfortunatly I can’t get it to work.

I tried the following ( using storyboard ):

  1. At the start of the script I call : local windImage

  2. Before scene:createScene I have a function with windImage:removeSelf()

3)with in scene:createScene I call : windImage = display.loadeRemoteImage(…)

And later I have a remote listener for the function in step 2.

When I fire the windImage:removeSelf() I get a an error “Attempt to index upvalue ‘windImage’ (a nil value)”

Which lead me to the doc’s where I noticed that the display.loadeRemoteImage has a return type of none - which pretty much explains the nil error.

My question therefor is - how do I remove the display.loadeRemoteImage correctly.

Best WIshes

/Thomas

Thomas,

I think you missed out something in the docs (http://docs.coronalabs.com/api/library/display/loadRemoteImage.html)

This a convenience method, similar to network.download(), which returns a display object containing the image, as well as saving the image to a file.

You do get back the image @ the network listener thru ‘event.target’. You can also access the image as a downloaded file. I am using it and works fine.

Thomas,

I think you missed out something in the docs (http://docs.coronalabs.com/api/library/display/loadRemoteImage.html)

This a convenience method, similar to network.download(), which returns a display object containing the image, as well as saving the image to a file.

You do get back the image @ the network listener thru ‘event.target’. You can also access the image as a downloaded file. I am using it and works fine.

Perfect yosu !

Setting assigning the windImage local to event.target in the Networklistner solved the problem.

Thank you so much :smiley:

Best Wishes

/Thomas