[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

XML and loading images

Posted on 2003-03-14
6
Medium Priority
?
251 Views
Last Modified: 2010-05-18
The code below loads 2 photos side by side into 2 movie clips via XML. I have two buttons used to navigate my photos, left and right. If I navigate to the end of XML nodes, it will continue to load the last image into both movie clips, instead of stopping. I'm using and if null break statement to prevent this but it's does not seem to help. I can send you a fla if you'd like to take a look.

Thanks


objMyVars=new LoadVars();
objMyVars.onload=myOnLoad;
objMyVars.load("flash_id.asp");
function myOnLoad(success)
{
 if(success)
 {
  flash_id =(this.id);
 }
 else
 {
 flash_id = "not loaded";
 }
}

slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;

// Show the first slide and intialize variables
function startSlideShow(success) {
     if (success == true) {
         
               rootNode = slides_xml.firstChild;
               totalSlides = rootNode.childNodes.length;
               firstSlideNode = rootNode.firstChild;
               currentSlideNode = firstSlideNode;
               currentIndex = 1;
               updateSlide(firstSlideNode);
               
               rootNode2 = slides_xml.firstChild;
               firstSlideNode2 = rootNode2.firstChild;
               currentSlideNode2 = firstSlideNode2;
               test = currentSlideNode2.nextSibling;
               updateSlide2(test);
               
     }
}
//
// Updates the current slide with new image and text
function updateSlide(newSlideNode) {
     imagePath = newSlideNode.attributes.jpegURL;
     slideText = newSlideNode.firstChild.nodeValue;
     left_link = (newSlideNode.firstChild.nodeValue);
     
     targetClip.loadMovie(imagePath);
     tellTarget ("/fader"){
          gotoAndPlay(1);
          }
         
               tellTarget ("/fader2"){
          gotoAndPlay(1);
          }

     
}



//
// Updates the current slide with new image and text
function updateSlide2(newSlideNode2) {
     imagePath2 = newSlideNode2.attributes.jpegURL;
     slideText2 = newSlideNode2.firstChild.nodeValue;
     targetClip2.loadMovie(imagePath2);
     right_link = (newSlideNode2.firstChild.nodeValue);

     
     
}




//
// Event handler for 'Next slide' button
next_btn.onRelease = function() {
     nextSlideNode = currentSlideNode.nextSibling;
     if (nextSlideNode == null) {
          break;
     } else {
          currentIndex++;
          updateSlide(nextSlideNode);
          currentSlideNode = nextSlideNode;
     }
     
     
     
     nextSlideNode2 = currentSlideNode.nextSibling;
     if (nextSlideNode2 == null) {
          break;
     } else {
          currentIndex++;
          updateSlide2(nextSlideNode2);
          currentSlideNode2 = nextSlideNode2;
     }
     
};
//
// Event handler for 'Previous slide' button
back_btn.onRelease = function() {
     previousSlideNode = currentSlideNode.previousSibling;
     if (previousSlideNode == null) {
          break;
     } else {
          currentIndex--;
          currentSlideNode = previousSlideNode;
          updateSlide(previousSlideNode);
     }
     
          previousSlideNode2 = currentSlideNode2.previousSibling;
     if (previousSlideNode2 == null) {
          break;
     } else {
          currentIndex--;
          currentSlideNode2 = previousSlideNode2;
          updateSlide2(previousSlideNode2);
     }
     
     
};
0
Comment
Question by:spamuel
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 8139193
send it along, and I will take a look...

in_fo@rascalpants.com

just take out the "_" underscore...


rp
0
 
LVL 6

Expert Comment

by:henryww
ID: 8140274
do u have live link for the asp & xml as well ...
so the loading will actually work with the live data...
send an extra copy here henryww@yahoo.com
if u don't mind :)

cheers
0
 

Author Comment

by:spamuel
ID: 8140411
Here is a link to my FLA..

http://216.119.64.208/xml_slides.zip


The asp page is not necessary, you just need to make sure the file structure is maintained when you unzip the files. It looks like this-

images/property_viewer/PHOTOS GO HERE

and the XML file and the SWF stay in the root folder.


Thanks vert much


0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Accepted Solution

by:
henryww earned 2000 total points
ID: 8142035
well, the order of checking is what u got mixed up, if the slide goes to the end then before u update the left window u should check if the right window (nextSlideNode2 == null) in stead ... vice versa for the back button

here's what u can do ...

copy & paste ... and see if for urself.

//
// Event handler for 'Next slide' button
next_btn.onRelease = function() {
     
     nextSlideNode = currentSlideNode.nextSibling;
     nextSlideNode2 = currentSlideNode.nextSibling.nextSibling;
// because we have to see if the right window is null therefore we need to do nextSibling.nextSibling
// HERE - check the right window !!
     if (nextSlideNode2!= null) {
          currentIndex++;
          updateSlide(nextSlideNode);
          currentSlideNode = nextSlideNode;
     }

     if (nextSlideNode2 != null) {
          currentIndex++;
          updateSlide2(nextSlideNode2);
          currentSlideNode2 = nextSlideNode2;
     }
     
};

// similar as in the next button - the previous button will check for the left window to see if previousSibling = null

//
// Event handler for 'Previous slide' button
back_btn.onRelease = function() {
     previousSlideNode = currentSlideNode2.previousSibling.previousSibling;
     if (previousSlideNode != null) {
          currentIndex--;
          updateSlide(previousSlideNode);
          currentSlideNode = previousSlideNode;
     }
     
     previousSlideNode2 = currentSlideNode2.previousSibling;
     if (previousSlideNode != null) {
          currentIndex--;
          currentSlideNode2 = previousSlideNode2;
          updateSlide2(previousSlideNode2);
     }

};



cheers
0
 

Author Comment

by:spamuel
ID: 8162947
Thank you very much henryww. I appreciate your assistance immensely. If I could give you more points for your help I would.

0
 
LVL 6

Expert Comment

by:henryww
ID: 8164487
:) pleasure
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question