Cancelling a download before finished

I have an imageListener running and if it’s slow, I need a method to cancel when the user selects a new action (like going to another screen).

Specifically, if an image is slow downloading, and the screen has changed, the image is still downloading and then appears in the new screen.

So I need to know how to automatically cancel the download when a button is pressed.

Any ideas?

Well, there are a few ways. Here’s what I recommend :

  1. Cancel the download when changing scene
  1. Check whether graphics is still there before loading the image
  • After downloading the image, check whether the graphics image is still on-screen.

  • If not, then do NOT show the downloaded graphics

Well, there are a few ways. Here’s what I recommend :

  1. Cancel the download when changing scene
  1. Check whether graphics is still there before loading the image
  • After downloading the image, check whether the graphics image is still on-screen.

  • If not, then do NOT show the downloaded graphics

Hi,

The best method is to store the network ref that is returned from the network.download and then cancel with that.

[lua]

local dl_id = network.download( … )

– and then when you need to cancel…

network.cancel( dl_id )

[/lua]

Best.

Hi,

The best method is to store the network ref that is returned from the network.download and then cancel with that.

[lua]

local dl_id = network.download( … )

– and then when you need to cancel…

network.cancel( dl_id )

[/lua]

Best.