473,471 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

[Flash8] Image MouseOver in XML Gallery

2 New Member
Hi,

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
  1. var galleryXML = new XML();
  2. galleryXML.ignoreWhite = true;
  3. galleryXML.load("gallery.xml");
  4. var currentIndex:Number = 0;
  5. galleryXML.onLoad = function(success) {
  6.     if (success) {
  7.         total = galleryXML.firstChild.childNodes.length;
  8.         var galleryXML:Array = galleryXML.firstChild.childNodes;
  9.         //For creating the block-thumbnails to link to the pictures in the gallery
  10.         for (var i:Number = total; i>0; i--) {
  11.             myClip.duplicateMovieClip("thumbnail_mc"+i, i, {_x:i*20, _y:i*20});
  12.         }
  13.         image_holder1_mc.loadMovie("images/"+galleryXML[currentIndex].attributes.filename1);
  14.         image_holder2_mc.loadMovie("images/"+galleryXML[currentIndex].attributes.filename1);
  15.         caption1_txt.text = galleryXML[currentIndex].attributes.caption1;
  16.         caption2_txt.text = galleryXML[currentIndex].attributes.caption2;
  17.         //testing to see if it is grabbing the correct template/scene in the XML file
  18.         template_txt.text = galleryXML[currentIndex].attributes.template;
  19.         //testing to see if it is calculating the correct number of entries in the XML file
  20.         total_txt.text = total;
  21.     }
  22. };
  23. listen = new Object();
  24. listen.onKeyDown = function() {
  25.     if (Key.getCode() == Key.LEFT) {
  26.         prevImage();
  27.     } else if (Key.getCode() == Key.RIGHT) {
  28.         nextImage();
  29.     }
  30. };
  31. Key.addListener(listen);
  32. previous_btn.onRelease = function() {
  33.     prevImage();
  34. };
  35. next_btn.onRelease = function() {
  36.     nextImage();
  37. };
  38. function nextImage() {
  39.     if (currentIndex<(total-1)) {
  40.         currentIndex++;
  41.         var currentNode = galleryXML.firstChild.childNodes[currentIndex];
  42.         trace(currentNode);
  43.         current_pos = currentIndex+1;
  44.         image_holder1_mc.loadMovie("images/"+currentNode.attributes.filename1);
  45.         image_holder2_mc.loadMovie("images/"+currentNode.attributes.filename2);
  46.         caption1_txt.text = currentNode.attributes.caption1;
  47.         caption2_txt.text = currentNode.attributes.caption2;
  48.         next_imageNumber();
  49.     }
  50. }
  51. function prevImage() {
  52.     if (currentIndex>0) {
  53.         currentIndex--;
  54.         var currentNode = galleryXML.firstChild.childNodes[currentIndex];
  55.         trace(currentNode);
  56.         image_holder1_mc.loadMovie("images/"+currentNode.attributes.filename1);
  57.         image_holder2_mc.loadMovie("images/"+currentNode.attributes.filename2);
  58.         caption1_txt.text = currentNode.attributes.caption1;
  59.         caption2_txt.text = currentNode.attributes.caption2;
  60.         previous_imageNumber();
  61.     }
  62. }
  63. function next_imageNumber() { 
  64. current_pos = currentIndex+1; 
  65. nextImageOfX.text = current_pos+" / "+total;
  66. //caption2_txt.text = current_pos;
  67. }
  68. function previous_imageNumber() { 
  69. current_pos = currentIndex+1; 
  70. nextImageOfX.text = current_pos+" / "+total;
Everything is working so far except the following: The effect that I want to achieve is when the user mouses over the image, the image shades (I am just going to use a simple rectangle the size of the photo and put it at a 30% alpha transparency) and the caption appears over the image. When the user's mouse leaves the photo, the shade and caption disappears.

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
  1. _root.image_holder1_mc.onEnterFrame = function() {
  2. if (mouse_over_image_holder1_mc) {
  3. _root.image_holder1_mc.nextFrame();
  4. } else {
  5. _root.image_holder1_mc.prevFrame();
  6. }
  7. };
On the invisible button over the image I have:
Expand|Select|Wrap|Line Numbers
  1. on (rollOver) {
  2. _root.mouse_over_image_holder1_mc = true;
  3. }
  4. on (rollOut) {
  5. _root.mouse_over_image_holder1_mc = false;
  6. }
In image_holder1_mc (where the image is loaded into), the first frame does not have the shaded rectangle nor the caption but frame 2 has both. When the user mouses over the invisible button in the root timeline, frame 2 of the image_holder1_mc movie clip SHOULD be played but it does not. I have been able to make it work with just a static image not loaded from XML but as soon as I use the dynamically loaded image, the feature does not work (it also does not grab the captions that's associated with the image).

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
Jul 16 '07 #1
0 4175

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Perttu Pulkkinen | last post by:
Does anybody know a php-based image gallery, where final looks of the actual site would not be determined by the application? I mean that there would only be a php-library of objects/functions that...
5
by: Deepster | last post by:
Hi all, I have searched the internet for this but havent found what I am looking for exactly, found similar items but I am not that familiar with asp to go and do this myself. So here I am .......
8
by: Chris Dewin | last post by:
Hi. I run a website for my band, and the other guys want an image gallery. I'm thinking it would be nice and easy, if we could just upload a jpg into a dir called "gallery/". When the client...
4
by: RE Kochanski | last post by:
I have attempted to use the CSS techniques from two or three sites to create a CSS only image gallery. I am muddling the affair by placing the thumbnails in one float, the page text in another...
3
by: Annette Acquaire | last post by:
I have and image map with a dozen hotspot links on it that I'm trying to get to open a new image over existing one on mouseover of each COORD. The only thing I was able to do was swap image on...
1
by: gescom | last post by:
My goal is to create essentially two galleries on a single page, in which the first gallery determines what the second gallery displays. For instance, the first gallery refers to the contents of the...
5
by: dabhand | last post by:
Hi This page http://www.dabhand.co.nz/ayupdev/gallery-riders.html works great in IE but not in Firefox... any help would be appreciated. It refers to an external javascript file which I have...
10
by: cjparis | last post by:
Hello everyone. If anyone can give me a hand I would be gratefull Am doing a site which requires a moving element and have used DHTML to do it. Have a simple Browser detect script to sort IE...
11
by: Evolution445 | last post by:
I got this code, and it somehow doesnt work. <TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center"> <TR> <TD background="{image-path}navfiller.gif" HEIGHT=40...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.