3 Replies Latest reply on Oct 26, 2009 5:43 AM by Ned Murphy

    Need help with this xml gallery !!!


      i have build a gallery but its very simple...... it takes images from xml file.


      i have attached all files in zip.


      i just want two things if anyone can help.


      first when i press next button it goes to next image but with no effect. it just displays next image ... i want to incorporate a sliding effect when the image is changed to another.


      and second i want to use autoplay feature.


      as soon as swf starts the images came one by one with difference of few seconds.


      thx in advance... i really need help in this....!

        • 1. Re: Need help with this xml gallery !!!
          Ned Murphy Adobe Community Professional & MVP

          For the sliding effect look into using the actionscript Tween class.  This allows you to create motion tweens using code.  The example below will tween the _x property of the instance named anObject from 0 to 300 in 3 seconds...


          // import classes before using

          import mx.transitions.Tween;
          import mx.transitions.easing.Regular;


          var tw = new Tween(anObject, "_x", Regular.easeIn, 0, 300, 3, true);


          To successfully implement an autorun feature you will have to import all of the images first, sequentially, then you will need to use some form of controlled timer, such as setInterval (with clearInterval as needed) in order to have things switched out automatically per some time basis

          • 2. Re: Need help with this xml gallery !!!
            Leo_kami Level 1

            Thx man .... it really helps your tweening .... example.....


            can u plz also give me an example for the autorun as well ...... thanks.... !

            • 3. Re: Need help with this xml gallery !!!
              Ned Murphy Adobe Community Professional & MVP

              You're welcome.


              I don't have an example to offer for the autorun.  You should be able to think it thru.  One key, as I mentioned is to preload all of the images first, that will allow for smooth playing of the show--no waiting for images to load between changes.  You can load them into empty movieclips and hide them (_viisible = false) until they are needed.  You could load them when called for, but you would have to put conditions on the displaying of things until the image loads, which will change when they are all loaded, so I recommend just loading them all first.


              For the timing you can use setInterval.  If something is going to be allowed to interupt the autorun, then you will need to make use of the clearInterval function as well, so that you stop the clock.


              Since you will be wanting to know when things are loaded, you will need to use the MovieClipLoader.loadClip method for loading the images instead of using loadMovie.  This is because the MovieClipLoader class supports having an event listener.  If you look in the help documents in the MovieClipLoader.addListener section, there is an example there that provides a fairly good complete overview of using the code.  The only difference is you'd be looking for the onLoadComplete event rather than the onLoadInit event.