is it possible to load pictures without loading in the setup (like example) ?

when i have too much pictures ( more than thousand in my website )
it’s too long to load all pictures whereas i need one randomly in draw() function.
But i can’t load picture in draw() function.

displayMode(FULLSCREEN)

function setup()
    
    flag={"Bd","Chronologie","Cinema","Geographie","Histoire",
    "Humour","Inventions","Litterature","Musique","Science","Sports","Television"}
    
    for i=1, 12 do
    str="icone"..i.."=nil ; "
    str=str.."http.get('http://gregory.thomas.free.fr/quizz/icones/"
    str=str..flag[i]..".jpg',didGetImage"..i..")"
    f=loadstring(str) ; ic1=f()
    end
    
end

    for i=1, 12 do
    str="function didGetImage"..i.."(theImage,status,head) icone"..i.."=theImage end"
    f=loadstring(str) ; ic1=f()
    end

function draw()
    
    background(20,20,40) ; spriteMode(CORNER) ; textMode(CORNER) ; fill(255, 241, 0, 255)
    
    for lig=1, 3 do
        for col=1,4 do
        j=600-((lig-1)*250+25) ; i=(col-1)*250+25 ; k=(lig-1)*4+col
        f=loadstring("if icone"..k.." ~=nil then sprite(icone"..k..",i,j,220,170) end")
        ic1=f() ; text(flag[k],i,j-40)
        end
    end
    
end

Can’t you create two images in your setup function, initialize one and then every so often in your draw loop - trigger a http request to download a new random image into the second image, then when the download is complete swap over the images and repeat?

Yes, you can defer loading of images. I wrote a library for deferred loading of anything (images,audio, 3d models) during runtime. I don’t remember if I posted it on github or not. It’s (poorly named) HTTPLoader.

Thanks do you have source code of HTTPloader please

I’ll clean it up and post soon. It’s not on GitHub.

thanks, it will allow me to make several projects without using dropbox