View Full Version : Random image display stop on key...
paulelvins
12-14-2004, 10:18 AM
Hey there...
I need to create (very quickly) a random image displayer(?) of around 80 photographs of people.
These photographs should be displayed for around .5 seconds each.
Upon keypress / mouse down, the display should stop on the current image.
I need some help... anyone??
Cheers, Paul
longedge
12-14-2004, 12:22 PM
Hello Paul,
First of all I take it you've got AMS5 Pro Version which will allow to create random numbers.
I would use IrfanView and resize all my pictures to the same dimensions and orientation then rename them image1.png through to image80.png.
Insert an image object on your page with image1.png already loaded.
In the pages On Show event do a Page.StartTimer(5000) for e.g. a 5 second display and then in the On Timer event enter use something like -
x = Math.Random(1, 80);
nextimage="AutoPlay\\Images\\image."..x.."png"
Image.Load("Image1", nextimage);
which will generate a number then build the number into a string to identify the image to load and load it.
Some of the more capable members of the forum would probably write code to enumerate the image names and use them directly without the first steps but this is just one possibility which is quick and easy.
TJ_Tigger
12-14-2004, 07:15 PM
Hey there...
I need to create (very quickly) a random image displayer(?) of around 80 photographs of people.
These photographs should be displayed for around .5 seconds each.
Upon keypress / mouse down, the display should stop on the current image.
I need some help... anyone??
Cheers, Paul
There are a few ways you can do this. If you don't want to rename your images I would suggest you use the File.Find to build a table of all your images. Those images will then be indexed numerically. Then you could use the Math.Seed/Math.Random to generate a random number between 1 and the Table.Count of the table containing your images. and then load that table[random] into your image object.
As loneedge said, use the timer to change your images every .5 seconds. Then on keypress/mouse stop the timer.
HTH
Tigg
paulelvins
12-15-2004, 03:29 AM
Thanks guys, but I can't seem to get it working.
I've done exactly as longedge suggested but it doesn't seem to work, just stays on the first picture.
Am I doing something wrong?... yep AMS5 PRO version being used.
Cheers
Paul
paulelvins
12-15-2004, 04:03 AM
Sorry guys... it was me!
Working brilliantly now... thanks for your help
Paul
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.