As I understand it, you basically want to do two things:
1. Dynamically load photo .jpgs from an array into a photo gallery using the
loader component
and
2. When a thumbnail is clicked, have a larger version of the photo appear
Here's one way to do it...
One the stage, drag as many instances of the loader component as you have
thumbnails. Properly size them and make each instance have a sequential name
(thumbnail0) starting with 0.... Also, drag another loader for the main photo,
and make its instance name "main."
To load these thumbnails, use this code:
//Establish array of thumbnails
photo_box=new
Array("0001.jpg","0002.jpg","0003.jpg","0004.jpg","0005.jpg","0006.jpg");
//Load images listed in array into pre-existing thumbnails, which have
instance names
//thumbnail0,thumbnail1,thumbnail2...thumbnail6
// using a loop
for (i=0; i<7; i++){
//build photo to load name based on number in loop
photo_to_load=photo_box;
//build instance name of loader component dynamically based on position in
array
thumb_to_load="thumbnail"+i;
//establish the content path
//note syntax includes no "." after "_root"
//that's how you path dynamic variables
_root[thumb_to_load].contentPath=photo_to_load;
_root[thumb_to_load].load;
}
In a new layer above the layer used for the loaders, make one invisible button
with the code:
on (release){
//for each button, set the button number here
//the number is the only thing that changes in the button instance
//in line 5 of this code
_root.button_pushed=0;
//call a function that can then use the button number
_root.load_main_pic();
}
Copy that button to cover the other thumbnail loaders, changing line 5 of the
code for the thumbnail number... so over thumbnail2, the _root.button_pushed=2,
etc.
Back in the first frame action, add the function:
// function for loading main picture when invisible buttons are pressed
function load_main_pic(){
// set main photo to load based on button pushed variable
// note: you may want to have a separate array for the full size pics
// in which case you would adjust the following line for that array name
main_to_load=photo_box[_root.button_pushed];
_root.main.contentPath=main_to_load;
// load that main photo
_root.main.load;
}
I've posted the result at
www.lehman-meyer.com/flash/loader.html Click on any thumbnail and see the main pic appear.
You can also download the source .fla by just going to
www.lehman-meyer.com/flash There's also some code in there to make the scale of the thumbnails enlarge on
rollover...
The nice thing about this approach is that the invisible buttons are re-usable
over and over again, and the only thing that has to change on them is the
thumbnail number in lines 5 and 11 of the code... and the loaders remain
invisible if not used.
This can also be improved in many ways, including using .xml as sam alluded
to... or parallel arrays, so you have file names and other pic information
popping up dynamically... and once you decide on a number of thumbnails per
page, you can have Flash dynamically build more pages on the fly based on the
length of the array...
Hope this helps