I am currently working on an XML Gallery for my girlfriend's brother who is a photographer. I have created a flash front end template and am using an XML database to load the images and accompanying captions.
The gallery has more than one image and the user can navigate the gallery by clicking forward and backward buttons to take then through the images:
Expand|Select|Wrap|Line Numbers
- var galleryXML = new XML();
- galleryXML.ignoreWhite = true;
- galleryXML.load("gallery.xml");
- var currentIndex:Number = 0;
- galleryXML.onLoad = function(success) {
- if (success) {
- total = galleryXML.firstChild.childNodes.length;
- var galleryXML:Array = galleryXML.firstChild.childNodes;
- //For creating the block-thumbnails to link to the pictures in the gallery
- for (var i:Number = total; i>0; i--) {
- myClip.duplicateMovieClip("thumbnail_mc"+i, i, {_x:i*20, _y:i*20});
- }
- image_holder1_mc.loadMovie("images/"+galleryXML[currentIndex].attributes.filename1);
- image_holder2_mc.loadMovie("images/"+galleryXML[currentIndex].attributes.filename1);
- caption1_txt.text = galleryXML[currentIndex].attributes.caption1;
- caption2_txt.text = galleryXML[currentIndex].attributes.caption2;
- //testing to see if it is grabbing the correct template/scene in the XML file
- template_txt.text = galleryXML[currentIndex].attributes.template;
- //testing to see if it is calculating the correct number of entries in the XML file
- total_txt.text = total;
- }
- };
- listen = new Object();
- listen.onKeyDown = function() {
- if (Key.getCode() == Key.LEFT) {
- prevImage();
- } else if (Key.getCode() == Key.RIGHT) {
- nextImage();
- }
- };
- Key.addListener(listen);
- previous_btn.onRelease = function() {
- prevImage();
- };
- next_btn.onRelease = function() {
- nextImage();
- };
- function nextImage() {
- if (currentIndex<(total-1)) {
- currentIndex++;
- var currentNode = galleryXML.firstChild.childNodes[currentIndex];
- trace(currentNode);
- current_pos = currentIndex+1;
- image_holder1_mc.loadMovie("images/"+currentNode.attributes.filename1);
- image_holder2_mc.loadMovie("images/"+currentNode.attributes.filename2);
- caption1_txt.text = currentNode.attributes.caption1;
- caption2_txt.text = currentNode.attributes.caption2;
- next_imageNumber();
- }
- }
- function prevImage() {
- if (currentIndex>0) {
- currentIndex--;
- var currentNode = galleryXML.firstChild.childNodes[currentIndex];
- trace(currentNode);
- image_holder1_mc.loadMovie("images/"+currentNode.attributes.filename1);
- image_holder2_mc.loadMovie("images/"+currentNode.attributes.filename2);
- caption1_txt.text = currentNode.attributes.caption1;
- caption2_txt.text = currentNode.attributes.caption2;
- previous_imageNumber();
- }
- }
- function next_imageNumber() {
- current_pos = currentIndex+1;
- nextImageOfX.text = current_pos+" / "+total;
- //caption2_txt.text = current_pos;
- }
- function previous_imageNumber() {
- current_pos = currentIndex+1;
- nextImageOfX.text = current_pos+" / "+total;
- }
The code that I am using (that's not working on any dynamic images loaded from the XML file) is as follows:
In the main actionScript in frame 1 of the timeline I have:
Expand|Select|Wrap|Line Numbers
- _root.image_holder1_mc.onEnterFrame = function() {
- if (mouse_over_image_holder1_mc) {
- _root.image_holder1_mc.nextFrame();
- } else {
- _root.image_holder1_mc.prevFrame();
- }
- };
Expand|Select|Wrap|Line Numbers
- on (rollOver) {
- _root.mouse_over_image_holder1_mc = true;
- }
- on (rollOut) {
- _root.mouse_over_image_holder1_mc = false;
- }
Is this a case of image_holder1_mc being changed due to the file name of the image that gets loaded or is image_holder1_mc always going to be image_holder1_mc regardless of the image name?
This seemed like it would be a simple thing to do but it isn't turning out that way.
Thank you in advance for your time and patience.
Brent a.k.a. numbnutz