?
Solved

XML and loading images

Posted on 2003-03-14
6
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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…
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.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

771 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