How to loop through a table of images

If I have a table with images like this:

local imageTbl = {"img1.png", "img2.png", "img3.png"}  

How do I loop through them endlessly with a nice fade in/fade out transition?

I know it might be a noob question, but I got serious case of brainfreeze right now.

Thanks
Cin [import]uid: 65840 topic_id: 21408 reply_id: 321408[/import]

i may be wrong but what you posted would just be a table with strings called “img1.png”, “img2.png” and “img3.png” [import]uid: 114118 topic_id: 21408 reply_id: 84773[/import]

Hmm maybe :

[code]
local imageTbl = {“img1.png”, “img2.png”, “img3.png”}
local imgs = {}
local imgNo = 1

for i = 1, #imageTbl do
imgs[i] = display.newImage(imgTbl[i])
imgs[i].alpha = 0
end

local function transitionImages()
local transitionOut

local function onCompleteDo(event)
imgNo = imgNo + 1

if imgNo > #imgs then
imgNo = 1
end

transition.to(imgs[imgNo], {alpha = 1, onComplete = transitionOut})
end

transitionOut = function(event)
transition.to(imgs[imgNo], {alpha = 0, onComplete = onCompleteDo})
end

transition.to(imgs[imgNo], {alpha = 1, onComplete = transitionOut})
end

–Run it
transitionImages() [import]uid: 84637 topic_id: 21408 reply_id: 84784[/import]

You could always do something like this

[code]require(“movieclip”)

local imageTbl = movieclip.newAnim{ “img1.png”, “img2.png”, “img3.png” }

local function transitions()
local function transComplete()
– call next frame to change image
imageTbl:nextFrame()

– fade new image in and call original function again to repeat
transition.to(imageTbl, {time=2000, alpha = 1, onComplete = transitions})
end

– Start fading out with a slow delay between fades then call transComplete
transition.to(imageTbl, {time=2000, delay=500, alpha = 0, onComplete = transComplete})

end

– Call to start transitions
transitions()
[/code] [import]uid: 69700 topic_id: 21408 reply_id: 85134[/import]