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.


function setup()
    for i=1, 12 do
    str="icone"..i.."=nil ; "
    f=loadstring(str) ; ic1=f()

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

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)

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