15 Replies Latest reply on Apr 8, 2009 4:33 PM by kglad

    Image Slideshow help w/ actionscript

    Pasta Man

      Hello, I found a tutorial online to help me do a Image Slideshow.

       

      http://www.republicofcode.com/tutorials/flash/slideshow/index.php

       

      But, I can not get anything to work.  I am new to this and unfortunately do not have time to do any formal training right now.  Probably when this project is done.

       

      When I "test movie"  I just get a white screen w/ nothing on it.  I should be getting a box 500x500 w/ a box that is 400x400 for my frame.

       

      I just finished step 3, and I do not get my frame box like a should.

       

      Here is what my .xml document says:

       

      <slideshow width="400" height="400" speed="5">
      <image url="images/1.jpg" />
      <image url="images/2.jpg" />
      <image url="images/3.jpg" />
      <image url="images/4.jpg" />
      <image url="images/5.jpg" />
      <image url="images/6.jpg" />
      <image url="images/7.jpg" />
      <image url="images/8.jpg" />
      <image url="images/9.jpg" />
      <image url="images/10.jpg" />
      </slideshow>

       

      and here is the action script.

       

      var myShowXML = new XML();
      myShowXML.ingoreWhite = true;
      myShowXML.load("slideshow.xml");

      myShowXML.onLoad = function() {
      _root.myWidth = myShowXML.firstChild.attributes.width;
      _root.myHeight = myShowXML.firstChild.attributes.height;
      _root.mySpeed = myShowXML.firstChild.attributes.speed;

       

      _root.myImages = myShowXML.firstChild.childNodes;
      _root.myImagesNo = myImages.length;
      };

      function createContainer() {
      _root.createEmptyMovieClip("myContainer_mc",_root.getNextHighestDepth());

       

      myContainer_mc.lineStyle(5,0x000000,100);
      myContainer_mc.lineTo(_root.myWidth,0);
      myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
      myContainer_mc.lineTo(0,_root.myHeight);
      myContainer_mc.lineTo(0,0);

       

      myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
      myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;

       

      createContainer();
      }

       

      Am I going down the wrong path?  If anyone has any other suggestions in making this, please feel free to let me know.

        • 1. Re: Image Slideshow help w/ actionscript
          kglad Adobe Community Professional & MVP

          createContainer() is in the wrong spot.

           

          remove it from its current line and put it at the end of your onLoad() function.

          • 2. Re: Image Slideshow help w/ actionscript
            Pasta Man Level 1

            You da man!!!

             

            I have the box now.  I never would have figured that out.

             

            I is not centered on the stage, or at least I don't think it is.  I attached a .jpg  screen show of what my output is.

             

            Should it be off to the right a bit like the image, or in the center?

             

            I believe "centered on the stage"  doesn't necessarily mean "centered on the screen".

             

            Thanks again.

            • 3. Re: Image Slideshow help w/ actionscript
              kglad Adobe Community Professional & MVP

              your attached image is listed as queued (and i can't view it).  possibly you "sent" your message before the attached file was completely uploaded.

              • 4. Re: Image Slideshow help w/ actionscript
                Pasta Man Level 1

                Hmm... Try again...

                • 5. Re: Image Slideshow help w/ actionscript
                  kglad Adobe Community Professional & MVP

                  your code will center the rectangle but the image you posted isn't centered.

                   

                  additionally,  i can't tell where your stage is.  and the stage properties are reported inaccurately in the test environment.  so, for testing, you should hard-code stage properties.

                  • 6. Re: Image Slideshow help w/ actionscript
                    Pasta Man Level 1

                    I believe in the action script I have it has a section to handle the stage:

                     

                    var myShowXML = new XML();
                    myShowXML.ingoreWhite = true;
                    myShowXML.load("slideshow.xml");

                    function createContainer() {
                    _root.createEmptyMovieClip("myContainer_mc",_root.getNextHighestDepth());

                    myContainer_mc.lineStyle(1,0x000000,100);
                    myContainer_mc.lineTo(_root.myWidth,0);
                    myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
                    myContainer_mc.lineTo(0,_root.myHeight);
                    myContainer_mc.lineTo(0,0);

                    myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
                    myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;
                    }
                    myShowXML.onLoad = function() {
                    _root.myWidth = myShowXML.firstChild.attributes.width;
                    _root.myHeight = myShowXML.firstChild.attributes.height;
                    _root.mySpeed = myShowXML.firstChild.attributes.speed;

                    _root.myImages = myShowXML.firstChild.childNodes;
                    _root.myImagesNo = myImages.length;

                    createContainer();
                    };

                    • 7. Re: Image Slideshow help w/ actionscript
                      kglad Adobe Community Professional & MVP

                      so, this thread is closed?  if so, please mark the answer.

                      1 person found this helpful
                      • 8. Re: Image Slideshow help w/ actionscript
                        Pasta Man Level 1

                        Sure I guess the initial question was answered.

                         

                        I still can not get the stage working correctly even though it is coded in the action script, but the box now shows up.

                         

                        Thank You for the help on the box.

                        • 9. Re: Image Slideshow help w/ actionscript
                          kglad Adobe Community Professional & MVP

                          again,  the stage properties are reported inaccurately in the test environment.  so, for testing, you should hard-code stage properties.

                          • 10. Re: Image Slideshow help w/ actionscript
                            Pasta Man Level 1

                            Ok, but I though they are already hard coded in my action script.  Or am I wrong?  If so, where can I go to do this?

                             

                            Thank You

                            • 11. Re: Image Slideshow help w/ actionscript
                              kglad Adobe Community Professional & MVP

                              no, you're using stage properties of width and height when you use:

                               

                              Stage.width and Stage.height.

                               

                              what you should do is, on your main timeline use something like:

                               

                              var stageW:Number = 550;

                              var stageH:Number = 400;  // use numbers that match your publish settings and use stageW and stageH in your subsequent code

                               

                              then when testing is complete you can just change those two lines:

                               

                               

                              var stageW:Number = Stage.width;

                              var stageH:Number = Stage.height;

                              1 person found this helpful
                              • 12. Re: Image Slideshow help w/ actionscript
                                Pasta Man Level 1

                                Like so?

                                 

                                var myShowXML = new XML();
                                myShowXML.ingoreWhite = true;
                                myShowXML.load("slideshow.xml");

                                var stageW:Number = 500;
                                var stageH:Number = 500;

                                function createContainer() {
                                _root.createEmptyMovieClip("myContainer_mc",_root.getNextHighestDepth());

                                myContainer_mc.lineStyle(1,0x000000,100);
                                myContainer_mc.lineTo(_root.myWidth,0);
                                myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
                                myContainer_mc.lineTo(0,_root.myHeight);
                                myContainer_mc.lineTo(0,0);

                                myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
                                myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;
                                }
                                myShowXML.onLoad = function() {
                                _root.myWidth = myShowXML.firstChild.attributes.width;
                                _root.myHeight = myShowXML.firstChild.attributes.height;
                                _root.mySpeed = myShowXML.firstChild.attributes.speed;

                                _root.myImages = myShowXML.firstChild.childNodes;
                                _root.myImagesNo = myImages.length;

                                createContainer();
                                };

                                 

                                It didn't shrink my stage up at all, but am I getting close?

                                • 13. Re: Image Slideshow help w/ actionscript
                                  kglad Adobe Community Professional & MVP

                                  no.  try:

                                   


                                  var myShowXML = new XML();
                                  myShowXML.ingoreWhite = true;
                                  myShowXML.load("slideshow.xml");

                                  var stageW:Number = 500;
                                  var stageH:Number = 500;

                                  function createContainer() {
                                  _root.createEmptyMovieClip("myContainer_mc",_root.getNextHighestDepth());

                                  myContainer_mc.lineStyle(1,0x000000,100);
                                  myContainer_mc.lineTo(_root.myWidth,0);
                                  myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
                                  myContainer_mc.lineTo(0,_root.myHeight);
                                  myContainer_mc.lineTo(0,0);

                                  myContainer_mc._x = (stageW-myContainer_mc._width)/2;
                                  myContainer_mc._y = (stageH-myContainer_mc._height)/2;
                                  }
                                  myShowXML.onLoad = function() {
                                  _root.myWidth = myShowXML.firstChild.attributes.width;
                                  _root.myHeight = myShowXML.firstChild.attributes.height;
                                  _root.mySpeed = myShowXML.firstChild.attributes.speed;

                                  _root.myImages = myShowXML.firstChild.childNodes;
                                  _root.myImagesNo = myImages.length;

                                  createContainer();
                                  };

                                   

                                   

                                  • 14. Re: Image Slideshow help w/ actionscript
                                    Pasta Man Level 1

                                    Thank You,

                                     

                                    It centered my box.

                                     

                                    That is great.

                                     

                                    I glanced at your code and mine, but couldn't find any differences.  I just copy and pasted yours in and now it centers my box on the stage.  I will have to go over the two tomorrow morning and see what I did wrong.

                                     

                                    Thank YOu again,

                                     

                                    I am sure I will be back w/ more questions.....:)

                                    • 15. Re: Image Slideshow help w/ actionscript
                                      kglad Adobe Community Professional & MVP

                                      you're welcome.

                                       

                                      the difference is towards the bottom where you used Stage.width and Stage.height and i used stageW and stageH.