View Full Version : Change images on page using a button
CraigS
05-23-2005, 02:30 AM
I'm working on my first AMS project. It's a multi-media textbook. I'm stumped figuring out how to use a button to display an image and then, when clicked, display another image. Need to click through as many as 6 images. Also need to have a button to click Back to the previous image. I'm an absolute novice with scripts.
I've attached a screenshot and hope it shows well enough to help my lame description.
I have a paragraph on the left side of the page. I have images on the right. I need to be able to use the arrow buttons below the image to move from one image to another -- Next image, Back to previous image. The text does not need to change with the images.
Thanks!
Craig
longedge
05-23-2005, 03:05 AM
Hi,
The action that you need in your button's On Click event is Image.Load e.g.
Image.Load("Image1", "AutoPlay\\Images\\indigorose.png");
There are a couple of different approaches to determining what the next image is. The elegant way is to first enumerate the contents of the images folder and then work through them on each click.
Another way (the one I always use) is to have your images named sequentially i.e. 1.jpg, 2.jpg, 3.jpg etc. Then on each click, first increase a variable by 1 and use that to build the image name and then load it (note that you need to initialise the variable x before you use it i.e. in the page pre-load just put a statement x=0) - e.g. -
x=x+1
if x>5 then x=1 end
pic="AutoPlay\\Images\\"..x..".jpg"
Image.Load("Image1", pic);
Same thing for the "previous button" except of course x=x-1 and if x<1 then x=5.
Although you say you don't need to change the text, you can do that easily enough all on the click of your next and previous buttons.
TJ_Tigger
05-23-2005, 08:17 AM
Great solution longedge.
I have used something similar in the past were I didn't want to rename all my pics I built a table containing all image names and used a script similar to what you posted to load the images in order of the table.
-- Define table of images in the order that they are to be displayed
tbImages = {};
tbImages[1] = "AutoPlay\\Images\\imagename.jpg";
tbImages[2] = "AutoPlay\\Images\\magenamei.jpg";
tbImages[3] = "AutoPlay\\Images\\agenameim.jpg";
tbImages[4] = "AutoPlay\\Images\\genameima.jpg";
tbImages[5] = "AutoPlay\\Images\\enameimag.jpg";
tbImages[6] = "AutoPlay\\Images\\nameimage.jpg";
tbImages[7] = "AutoPlay\\Images\\ameimagen.jpg";
-- call the next and previous images
x=x+1;
if x>Table.Count(tbImages) then x=1 end
Image.Load(tbImages[x], pic);
-- or
x=x-1;
if x<1 then x=Table.Count(tbImages) end
Image.Load(tbImages[x], pic);
Tigg
CraigS
05-23-2005, 09:07 AM
Thank you longedge and TJ_Tigger. I'll get to working on this tonight. I can see I've got much to learn!
Craig
Bruce
05-23-2005, 10:54 AM
Man can you imagine useing that Flash page turn (http://www.diginetx.com/downloads/pageflip_v2dyn.zip) on this?! Sweet.
Nice job Craig.
stickck
05-24-2005, 11:24 AM
Hey Tigg,
A quick way to rename your images is to drag them all into Photoshop and use the Batch option under the FILE menu.
Thanks for the certificate you built thats posted on WWW.AMSUSER.COM
I changed it a little and added it to a training program I built.
Chris
TJ_Tigger
05-24-2005, 12:08 PM
Hey Tigg,
A quick way to rename your images is to drag them all into Photoshop and use the Batch option under the FILE menu.
Thanks for the certificate you built thats posted on WWW.AMSUSER.COM
I changed it a little and added it to a training program I built.
Chris
I use CompuPic Pro from www.photodex.com to do batch changes to most of my photos. If that is the way you want to go it is easy to rename them for use in a function like that. I sometimes want to keep then named a particular way for my own purposes and references.
Thanks for the pointer
Tigg
CraigS
05-24-2005, 10:44 PM
Bruce,
Thanks for the flash page turn. I'll need to play with it. Uncharted territory for me. I had been wondering if there was a way to have a page turning transition. I'm guessing that is what the Flash page turn does.
Craig
Corey
05-24-2005, 11:16 PM
Hmmm, seems to me someone created a page-turn add-on once but I can't remember what happened with that in the end. I remember seeing it once though, it was awesome. :yes
longedge
05-25-2005, 01:10 AM
Hmmm, seems to me someone created a page-turn add-on once but I can't remember what happened with that in the end. I remember seeing it once though, it was awesome. :yes
This is Ron territory :) - he's done some snazzy stuff along these lines along.
Cue RHOSK :-
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.