I have a scene with a number of images loaded remotely. I call for those images on scene:show and in their listener I check if the user is still on that scene, if not, I simply remove the event.target.
My problem is that the user can enter->exit->enter the scene quick enough, so that the listener would load and show the images from the first entrance.
I would like to be able to pass an ID when I call loadRemoteImage, so that when it comes back in the listener I can check if it is still relevant.
Any ideas?
You could try wrapping the loadRemoteImage in a new function that overrides the callback like this
function loadRemoteImgWithData(data, url, method, listener, params, destFilename, baseDir, x, y)
if type(data) ~= "table" then
error("first argument must be data table", 2)
end
if type(params) ~= "table" then
y = x
x = baseDir
baseDir = destFilename
destFilename = params
params = nil
end
local function listenerOverride(event)
event.data = data
listener(event)
end
display.loadRemoteImage( url, method, listenerOverride, params, destFilename, baseDir, x, y )
end