16 Replies Latest reply on Jun 4, 2006 6:20 AM by fanmap81

    Autoplay in xml Slideshow

    fanmap81
      Can anyone tell me what actionscript coding i should use in order to get this gallery to autoplay instead of the use of previous and next buttons? I just want my pics to load up, then fade in and fade out, while going at a set timing rate. Any and all help is appreciated, Thanks

      Heres the link to the tutorial

      The XML Tutorial
        • 1. Re: Autoplay in xml Slideshow
          Level 7
          var myNextInterval:Number;
          var myMillis:Number = 2000;// 1000 = 1 second
          function nextSlide()
          {
          nextSlideNode = currentSlideNode.nextSibling;
          if (nextSlideNode == null) {
          clearInterval( myNextInterval);
          break;
          } else {
          currentIndex++;
          updateSlide(nextSlideNode);
          currentSlideNode = nextSlideNode;
          }
          }

          function autoPlay()
          {

          myNextInterval = setInterval(nextSlide, myMillis);
          }

          next_btn.onRelease = function() {
          clearInterval( myNextInterval); nextSlide();};Add clearInterval(
          myNextInterval); to the
          back_btn.onRelease = function() {clearInterval( myNextInterval);
          previousSlideNode = currentSlideNode.previousSibling;
          if (previousSlideNode == null) {
          break;
          } else {
          currentIndex--;
          currentSlideNode = previousSlideNode;
          updateSlide(previousSlideNode);
          }}

          next_btn.onRelease = function() {
          clearInterval( myNextInterval); nextSlide();};autoPlay_btn.onRelease =
          function() {
          autoPlay();
          }


          autoPlay();


          --
          Lon Hosford
          www.lonhosford.com
          May many happy bits flow your way!
          "fanmap81" <webforumsuser@macromedia.com> wrote in message
          news:e43hjd$f4b$1@forums.macromedia.com...
          Can anyone tell me what actionscript coding i should use in order to get
          this
          gallery to autoplay instead of the use of previous and next buttons? I just
          want my pics to load up, then fade in and fade out, while going at a set
          timing
          rate. Any and all help is appreciated, Thanks

          Heres the link to the tutorial

          http://www.adobe.com/support/flash/applications/jpeg_slideshow_xml/


          • 2. Re: Autoplay in xml Slideshow
            fanmap81 Level 1
            Thanks for the reply, but I dont really understand this code. Im using Flash 8 and im getting syntax errors when i copy and paste the code in. Where should i place it? in the frame? the buttons? I also want the gallery to act as if there are no buttons at all. In the actionscript i see on (release) button handlers. I want just a plain box that displays the pictures that fade in and out on a set timing. Thats pretty much it. Thanks again sir. Appreciate your help
            • 3. Re: Autoplay in xml Slideshow
              Level 7
              >>Im using Flash 8 and im getting syntax errors when i copy and paste the
              >>code in.
              The code is correct. I suspect you did not recognize the following as being
              part of the post message and not actionscript:

              "Add clearInterval( myNextInterval); to the "


              >>I also want the gallery to act as if there are no buttons at all.
              Then you will want to exclude the code in the article on this page
              http://www.adobe.com/support/flash/applications/jpeg_slideshow_xml/jpeg_slideshow_xml08.ht ml
              and replace with this

              var myNextInterval:Number;
              var myMillis:Number = 2000;// 1000 = 1 second
              function nextSlide()
              {
              nextSlideNode = currentSlideNode.nextSibling;
              if (nextSlideNode == null)
              {
              clearInterval(myNextInterval);
              break;
              }
              else
              {
              currentIndex++;
              updateSlide(nextSlideNode);
              currentSlideNode = nextSlideNode;
              }
              }
              function autoPlay()
              {
              myNextInterval = setInterval(nextSlide, myMillis);
              }

              autoPlay();



              --
              Lon Hosford
              www.lonhosford.com
              May many happy bits flow your way!
              "fanmap81" <webforumsuser@macromedia.com> wrote in message
              news:e45od4$4a3$1@forums.macromedia.com...
              Thanks for the reply, but I dont really understand this code. Im using
              Flash 8
              and im getting syntax errors when i copy and paste the code in. Where should
              i
              place it? in the frame? the buttons? I also want the gallery to act as if
              there
              are no buttons at all. In the actionscript i see on (release) button
              handlers.
              I want just a plain box that displays the pictures that fade in and out on a
              set timing. Thats pretty much it. Thanks again sir. Appreciate your help


              • 4. Autoplay in xml Slideshow
                fanmap81 Level 1
                I dont know Motion Maker, i cant get it to work for some reason. The first picture loads and then just stays there. It dosent fade out or anything. here is the entire code that i am using on the first frame of the movie:

                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);

                }
                }
                //
                // Updates the current slide with new image and text
                function updateSlide(newSlideNode) {
                imagePath = newSlideNode.attributes.jpegURL;
                slideText = newSlideNode.firstChild.nodeValue;
                loadMovie(imagePath, targetClip);
                }




                //-----------------------newest code(Motion Maker)-----------------------//



                var myNextInterval:Number;
                var myMillis:Number = 2000;// 1000 = 1 second
                function nextSlide()
                {
                nextSlideNode = currentSlideNode.nextSibling;
                if (nextSlideNode == null)
                {
                clearInterval(myNextInterval);
                break;
                }
                else
                {
                currentIndex++;
                updateSlide(nextSlideNode);
                currentSlideNode = nextSlideNode;
                }
                }
                function autoPlay()
                {
                myNextInterval = setInterval(nextSlide, myMillis);
                }

                autoPlay();


                What am i doing wrong?
                • 5. Re: Autoplay in xml Slideshow
                  Level 7
                  1. The next_btn.onRelease = function() name I changed to nextSlide for
                  clarity. The setInterval(nextSlide, myMillis); is looking for that function
                  named nextSlide. Here it is and add to frame 1:
                  nextSlide = function() {
                  nextSlideNode = currentSlideNode.nextSibling;
                  if (nextSlideNode == null) {
                  break;
                  } else {
                  currentIndex++;
                  updateSlide(nextSlideNode);
                  currentSlideNode = nextSlideNode;
                  }
                  };
                  2. In the function startSlideShow(success) after the
                  updateSlide(firstSlideNode); line add the line autoPlay();
                  ...
                  currentIndex = 1;
                  updateSlide(firstSlideNode);
                  autoPlay();
                  }


                  3. Remove the autoPlay(); line from the end of the script.


                  --
                  Lon Hosford
                  www.lonhosford.com
                  May many happy bits flow your way!
                  "fanmap81" <webforumsuser@macromedia.com> wrote in message
                  news:e47tlm$j2q$1@forums.macromedia.com...
                  I dont know Motion Maker, i cant get it to work for some reason. The first
                  picture loads and then just stays there. It dosent fade out or anything.
                  here
                  is the entire code that i am using on the first frame of the movie:

                  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);

                  }
                  }
                  //
                  // Updates the current slide with new image and text
                  function updateSlide(newSlideNode) {
                  imagePath = newSlideNode.attributes.jpegURL;
                  slideText = newSlideNode.firstChild.nodeValue;
                  loadMovie(imagePath, targetClip);
                  }




                  //-----------------------newest code-----------------------



                  var myNextInterval:Number;
                  var myMillis:Number = 2000;// 1000 = 1 second
                  function nextSlide()
                  {
                  nextSlideNode = currentSlideNode.nextSibling;
                  if (nextSlideNode == null)
                  {
                  clearInterval(myNextInterval);
                  break;
                  }
                  else
                  {
                  currentIndex++;
                  updateSlide(nextSlideNode);
                  currentSlideNode = nextSlideNode;
                  }
                  }
                  function autoPlay()
                  {
                  myNextInterval = setInterval(nextSlide, myMillis);
                  }

                  autoPlay();


                  What am i doing wrong?


                  • 6. Autoplay in xml Slideshow
                    fanmap81 Level 1
                    mmm...... still no dice. i cant get it to autoplay. Heres what my code looks like after using your suggestions motion maker:

                    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);
                    autoPlay();

                    }
                    }

                    // Updates the current slide with new image and text
                    function updateSlide(newSlideNode) {
                    imagePath = newSlideNode.attributes.jpegURL;
                    slideText = newSlideNode.firstChild.nodeValue;
                    loadMovie(imagePath, targetClip);
                    }


                    //-----------------newest code Motion Maker------------------//

                    nextSlide = function() {
                    nextSlideNode = currentSlideNode.nextSibling;
                    if (nextSlideNode == null) {
                    break;
                    } else {
                    currentIndex++;
                    updateSlide(nextSlideNode);
                    currentSlideNode = nextSlideNode;
                    }
                    };



                    var myNextInterval:Number;
                    var myMillis:Number = 2000;// 1000 = 1 second
                    function nextSlide()
                    {
                    nextSlideNode = currentSlideNode.nextSibling;
                    if (nextSlideNode == null)
                    {
                    clearInterval(myNextInterval);
                    break;
                    }
                    else
                    {
                    currentIndex++;
                    updateSlide(nextSlideNode);
                    currentSlideNode = nextSlideNode;
                    }
                    }
                    function autoPlay()
                    {
                    myNextInterval = setInterval(nextSlide, myMillis);
                    }

                    //-----------------/newest code Motion Maker------------------//

                    What do you think the culprit is?
                    • 7. Re: Autoplay in xml Slideshow
                      fanmap81 Level 1
                      Motion Maker are u there?
                      • 8. Re: Autoplay in xml Slideshow
                        DownWithOOP
                        Not sure if this is what you ment. From the original tutorial you provided, do the following...
                        I removed the event handlers, so you can delete the button graphics, or you can add the event
                        handlers

                        Copy the code below into the actions frame of the .fla.

                        Change the delay variable (second line) to the desired seconds of delay.

                        This slide show will loop, if you want it to play once, kill the interval. Good Luck!


                        ******* Copy Below ************************

                        //on my machine, declaring and initalizing the variable
                        //at the same time would make the setInterval oversee it. I don't know Why

                        var yourDesiredDelayInSec:Number = new Number();
                        yourDesiredDelayInSec = 3



                        slides_xml = new XML();
                        slides_xml.onLoad = startSlideShow;
                        slides_xml.load("slides.xml");
                        slides_xml.ignoreWhite = true;
                        //
                        // Show the first slide and intialize variables
                        var intervalVariable = setInterval(nextImage,(1000 * yourDesiredDelayInSec));

                        function startSlideShow(success) {
                        if (success == true) {
                        rootNode = slides_xml.firstChild;
                        totalSlides = rootNode.childNodes.length;
                        firstSlideNode = rootNode.firstChild;
                        currentSlideNode = firstSlideNode;
                        currentIndex = 1;
                        updateSlide(firstSlideNode);

                        }
                        }
                        //
                        // Updates the current slide with new image and text
                        function updateSlide(newSlideNode) {
                        imagePath = newSlideNode.attributes.jpegURL;
                        slideText = newSlideNode.firstChild.nodeValue;
                        loadMovie(imagePath, targetClip);
                        }
                        //
                        // Was the Event handler for 'Next slide' button, now just a function
                        function nextImage() {

                        nextSlideNode = currentSlideNode.nextSibling;

                        if(nextSlideNode == null){
                        rootNode = slides_xml.firstChild;
                        totalSlides = rootNode.childNodes.length;
                        firstSlideNode = rootNode.firstChild;
                        currentSlideNode = firstSlideNode;
                        currentIndex = 1;
                        updateSlide(firstSlideNode);
                        }else{
                        currentIndex++;
                        updateSlide(nextSlideNode);
                        currentSlideNode = nextSlideNode;
                        }

                        };

                        • 9. Re: Autoplay in xml Slideshow
                          fanmap81 Level 1
                          thank you sir, that code works just like i intended.....one last thing, could u tell me how i can go about fading in and out my pics instead of them just cutting straight to the next pic? Thanks, o and one more thing, if i wish to make each pic a different link wen u click it, how do i do that? Thanks again
                          • 10. Re: Autoplay in xml Slideshow
                            DownWithOOP Level 1
                            A while back I wrote a nice easy-to-use program for my employer call the Facility Tour, which had a series of images, zooming in or zooming out (your desision of which and how much), and fading between one another. It used .mp3 files used for voice over audio to determine how long the image would appear and how fast it must zoom in order to be finished by the time the audio was up. There is also a feature to have a text pallet roll out on stage and display some external text as a foot note. The program does not loop, and will auto unload when all of the images have been viewed. The size is 1280x800, but you can size it down through the .fla. And all of the images are loaded at the beginning, with no preloaded. This program is ment to be stand-alone, and probably won't work well on the internet. It also has the famous Image Quality bug that is found in Flash (even in 7). This is the old version of my program, the new one keeps the images in the library and they are set with smoothing. This is still a good start. Good Luck.

                            Tour Program at: http://www.atdportfolio.com/Tour Program.zip
                            More Information/Demo: http://www.atdportfolio.com/tour/
                            • 12. Re: Autoplay in xml Slideshow
                              fanmap81 Level 1
                              thanks downwithoop but for what im trying to achieve, and with what i already have, wouldnt it be just a couple more lines of code here or there, to achieve the entire effect? your latest example looks to me like sumthing totally different from where im trying to go. And a whole lot more different code than what I was dealing with previous. The previous movie code works fine, i just want to add that one extra behavior where the pics will fade in, then out to reveal the next one, and make each pic go to its own seperate external link when i click on it. Thats pretty much it.

                              Your tour program is something for a more advanced project that i can probably see myself looking into at a later time, but for now i just want to get the final tweaks on the simple one. Thanks again OOP, you have been alot of help so far. I look forward to your reply. Speak to you soon.
                              • 13. Re: Autoplay in xml Slideshow
                                Level 7
                                Sorry, I was and still am traveling on business/pleasure trip.

                                I see two nextSlide functions. They look the same but lets remove this one.
                                nextSlide = function ()
                                {
                                ...
                                }
                                Keep this one
                                function nextSlide()
                                {
                                ...
                                }
                                >>mmm...... still no dice. i cant get it to autoplay
                                I am relying on the posted code from the web site being correct.

                                To check if the autoPlay function is working add a trace statement inside of
                                nextSlide
                                function nextSlide()
                                {
                                trace ("nextSlide() - " + getTimer());
                                ...
                                }

                                If you see that firing over and over inside the Output window when you do
                                Control->Test Movie, then the rest of the debugging has to do with the XML
                                parsing. If you do not see those trace statements, then the script may not
                                be loading the XML file.

                                In the latter case add a trace statement to startSlideShow
                                function startSlideShow(success)
                                {
                                trace ("startSlideShow - success:"+success);

                                }
                                You are looking for true in the Output window.


                                --
                                Lon Hosford
                                www.lonhosford.com
                                May many happy bits flow your way!
                                "fanmap81" <webforumsuser@macromedia.com> wrote in message
                                news:e4ivk5$3r3$1@forums.macromedia.com...
                                Motion Maker are u there?


                                • 14. Re: Autoplay in xml Slideshow
                                  fanmap81 Level 1
                                  anything downwithoop?
                                  • 15. Re: Autoplay in xml Slideshow
                                    adamdill
                                    Sorry for the delay. Infact it isn't just a few more lines of code to make it fade from one image to another. You see, how it is set up now, one image is loaded, knocking the other image out of the movie clip. You will need to restructer the code to load into individual layers inside of the 'target_mc'. _level1 and _level2 for instance. Once _level2._alpaha == 0, _level1 needs to be moved up to _level2, and your new image needs to bump _level1. So on and so forth till the end of time. You will also need a setInterval to account for the _alpha change. Set interval are a little tricky if you don't know what you are doing, just remember to delete it once _alpha == 0. I have also had problems with the file I downloaded from your original post. It seems to be a little buggy. If I were you, I would trash that file, slap the author, and start over. He may be using components, which I have experienced problems with data transfer and dynamic creations when components get envolved. Tutorials are great to read through, but copy/paste code in any language gets really confusing and becomes more trouble than if you were to start from scratch. Good Luck.
                                    • 16. Re: Autoplay in xml Slideshow
                                      fanmap81 Level 1
                                      i would love to be able to say i know exactly what you mean, but unfortunately i dont.........using the code that exist on this page already, could you show me how it should be typed to get a working example? Thanks alot, appreciate it