Change Images By Timer
Posted: Thu Mar 09, 2017 1:31 pm
Hi, how do this :
First try : (stupid way)
Second way : more than stupid, it's a dumb way
How do 2nd way in smart way ?
Thanks
First try : (stupid way)
Code: Select all
f = createForm()
f.Width = 500
f.Height = 500
i1 = createImage(f)
i1.Width = 500
i1.Height = 500
i1.Stretch = true
i1.Picture.loadFromStream(findTableFile('mainWall.jpg').Stream)
t_index = 1
counter = 3
c=createTimer(nil)
c.Interval= 5000
c.OnTimer=function(c)
if t_index <= counter then
i1.Picture.loadFromStream(findTableFile('mainWall1.jpg').Stream)
t_index = t_index + 1
else
i1.Picture.loadFromStream(findTableFile('mainWall2.jpg').Stream)
t_index = 1
end
end
c.Enabled=true
function closeGLP()
c.destroy()
closeCE()
return caFree
end
f.onClose = closeGLP
f.show()
-- result : Images change as timer provided, but only display 2 images from 3 images want to show
Second way : more than stupid, it's a dumb way
Code: Select all
t = {}
t[1] = 'mainWall.jpg'
t[2] = 'mainWall1.jpg'
t[3] = 'mainWall2.jpg'
t[4] = 'mainWall3.jpg'
f = createForm()
f.Width = 400
f.Height = 400
img = createImage(f)
img.Width = 400
img.Height = 400
img.Stretch = true
timer=createTimer(nil, false)
timer.Interval=3000
timer.OnTimer=function(timer)
for i=1, 4 do
img.Picture.loadFromStream(findTableFile(t[i]).Stream)
i=i+1
end
end
timer.Enabled=true
result : only image t[4] shown
Thanks