PDA

View Full Version : This is a tricky one ?


octane6228
06-07-2005, 03:15 PM
Hi Guys...I'm trying to display images like a slide show but without a predetermined amount of images. I want AMS to be able to look in a directory and figure out how many slides are in the directory and display that info to a text box and an image object.

I have a hard coded version now...

if e_Key == 39 then
picnumber = picnumber + 1;
if picnumber >=5 then
picnumber = 5
end
Image.Load("SlideImage", "AutoPlay\\Images\\pic."..picnumber..".jpg");
Paragraph.SetText("output", "Now Showing Slide "..picnumber.." of 5");
end

if e_Key == 37 then
picnumber = picnumber - 1;
if picnumber <=1 then
picnumber = 1;
end
Image.Load("SlideImage", "AutoPlay\\Images\\pic."..picnumber..".jpg");
Paragraph.SetText("output", "Now Showing Slide "..picnumber.." of 5");
end

I want to automate the loading of the images and the text output (ex."5") so that if i have 5,6,10,etc.. images I can add or delete the images externally from AMS and it updates automatically.

Any help is greatly appreciated.

Thanks

yosik
06-07-2005, 04:27 PM
Octane,

You can try the following:

--Populate a table with jpg files from the Image directory and count their numbers

tbl_path = File.Find("AutoPlay\\Docs\\Images", "*.jpg", false, false, nil, nil);
img_nbr = Table.Count(tbl_path);

--Load and show the images
for count = 1, img_nbr do
Image.Load("SlideImage", "AutoPlay\\Docs\\Images\\pic."..count..".jpg");
Paragraph.SetText("output", "Now Showing Slide "..count.." of"..img_nbr);
end

Of courses, you would need to decide on your trigger.

Good luck
Yossi

octane6228
06-09-2005, 08:44 AM
Thanks Yossi...It worked but one problem....I'm using this code on a key press...Right now it whips through each of the images. How do I get it to stop on each image and wait for the next key press?

Here's what I have with your help so far...(On Key)

--Populate a table with jpg files from the Image directory and count their numbers
tbl_path = File.Find("AutoPlay\\Images\\slides", "*.jpg", false, false, nil, nil);
img_nbr = Table.Count(tbl_path);

if e_Key == 39 then

--Load and show the images
for count = 1, img_nbr do
Image.Load("SlideImage", "AutoPlay\\Images\\slides\\pic."..count..".jpg");
Paragraph.SetText("output", "Now Showing Slide "..count.." of"..img_nbr);
end
end

if e_Key == 37 then

--Load and show the images
for count = 1, img_nbr do
Image.Load("SlideImage", "AutoPlay\\Images\\slides\\pic."..count..".jpg");
Paragraph.SetText("output", "Now Showing Slide "..count.." of"..img_nbr);
end
end

yosik
06-09-2005, 04:35 PM
Octane,
WHat you should do is NOT use the "for" loop onkey. Instead, just increase/decrease the count index and load the relevant image/text in paragraph.
Yossi

octane6228
06-10-2005, 07:55 AM
Sorry to be a pain, but what would that look like? Is it just a simpler counter?

Thanks

yosik
06-11-2005, 02:49 PM
Something like that, yes.
You should use the actions:

if e_Key == 39 then

--Load and show the images
count = count +1;
Image.Load("SlideImage", "AutoPlay\\Images\\slides\\pic."..count..".jpg");
Paragraph.SetText("output", "Now Showing Slide "..count.." of"..img_nbr);


Yossi