4 Replies Latest reply on May 9, 2009 10:41 AM by mmichelles

    Slide Show Question

    mmichelles

      Greetings and first let me thank you for your help. I certainly hope that I can get the answer to this question.

       

      I am new to Flash and get stumped by action script.

       

      I have created a slide show that has two buttons, Next and Back. It works perfectly going forward, it comes to the end and stops continuing to show the last picture. The back button also works until it gets to the the first picture of the array. When you click when it on first picture of the array rather than just stopping the picture disappear and a error happens.

       

      This error shows up in Flash:

       

      TypeError: Error #2007: Parameter url must be non-null.
          at flash.display::Loader/_load()
          at flash.display::Loader/load()
          at slideshow_fla::MainTimeline/imagePrev()

       

       

       

      The following is the part of the code that I know the problem occurs in.

       

      function imagePrev( pEvent:MouseEvent ):void

      {

      --count;

      if (count == imgArray.length)
      {
      count = imgArray.length - 1;
      }
      else

      {

      imageLoader.unload();

      imageRequest.url = imgArray[count];
      imageLoader.x = 100;
      imageLoader.y = 120;

      imageLoader.load(imageRequest);

      txt.text = txtArray[count];
      }
      }

       

       

      I attached the .swf file in case you want to see what it does.

      I hope someone can help.

      Thanks much,

      Michelle

        • 1. Re: Slide Show Question
          kglad Adobe Community Professional & MVP

          in the next button listener function, when you increment count, if it's equal to imgArray.length, reset it to zero.

           

          in the prev button listener function, when you decrement coutn, if it's less then 0, reset it to imgArray.length-1.

          • 2. Re: Slide Show Question
            mmichelles Level 1

            Thanks so much for your response, KGlad. I apologize because I am not understanding what you are saying. I am not having a problem with the thing working. It is just the error. I think I have it set as you advised. What am I missing?

             

             

            function imagePrev( pEvent:MouseEvent ):void

            {

            --count;
            if (count == imgArray.length)
            {
            count = imgArray.length - 0;            // isn't this line setting the count at -0? Isn't that what you said I should do?
            }
            else
            {
            imageLoader.unload();
            imageRequest.url = imgArray[count];
            imageLoader.x = 100;
            imageLoader.y = 120;
            imageLoader.load(imageRequest);
            // change text
            txt.text = txtArray[count];
            }
            }

             

            btn_next.addEventListener(MouseEvent.CLICK, imageNext );  //These are my listeners and they both work Do I really need to change them?
            btn_back.addEventListener(MouseEvent.CLICK, imagePrev );

            • 3. Re: Slide Show Question
              kglad Adobe Community Professional & MVP

              i don't see the code for the next button.  but for your prev button:

               


               

               

              function imagePrev( pEvent:MouseEvent ):void

              {

              --count;
              if (count == -1)
              {
              count = imgArray.length - 1;      
              }

              imageLoader.unload();
              imageRequest.url = imgArray[count];
              imageLoader.x = 100;
              imageLoader.y = 120;
              imageLoader.load(imageRequest);
              // change text

              }

               

              btn_next.addEventListener(MouseEvent.CLICK, imageNext );  //These are my listeners and they both work Do I really need to change them?
              btn_back.addEventListener(MouseEvent.CLICK, imagePrev );

              • 4. Re: Slide Show Question
                mmichelles Level 1

                You are very much appreciated. I didn't put the next button function in  because I wasn't having any problems with it. The file is now fixed thanks to you. I really appreciate your effort.

                 

                Some day I hope action script is easier for me. At this time I am good at finding files that use a script that will work for me. It is the fine tuning that causes me hours of grief! You just moved me closer to clearer understanding!

                 

                Thank you!

                Michelle