I am using display.newImage( name , system.DocumentsDirectory , true ) to make a image object to show in front .
I want change the file from remote server. So I try to load a black.png at first , after donwload realy png file form server , I want exchange old img to use new png file the sample code like this
function load_img(remote_file)
local img_tmp = display.newImage( ‘black.png’ , system.DocumentsDirectory , true )
download_function = function (remote_file)
local saveName = “/img/save.png”
download_finished = function (event)
local img_remote = display.newImage( saveName, system.DocumentsDirectory , true )
img_tmp = img_remote
end
network.download(
remote_file,
“GET”,
download_finished ,
{ progress=false },–params
(saveName),–保存先
system.DocumentsDirectory
)
end
return img_tmp
end
local pic = load_img("http://12.212.121.12/a.png")
local t = display.newGroup()
t:insert(pic)
The Problem is , after I download a png , I can’t change the tmp png .
please help
