XML Slider - Basic

Hi Everyone,

I’ve spent the past few days tinkering with XML and attachmovie etc…

Kirupa’s Gallery is a great start but I needed something different.

This Gallery Parses an XML file which includes:

  • Caption
  • Image URL
  • Image Width

The Gallery currently:

  • Loads each image consecutively
  • Loads each caption into a stylized movieclip
  • Contains two buttons, each which slide the ‘Container’ movieclip in either direction(hard coded) using the MC Tween Class. Grab that class if you dont have it already installed. Its similar to the Laco tween.

What I have works great, but I need some help extending it.
**
I would like to:**

  • Create a function that slides the ‘Container’ clip in either direction using an incremental value that slides to the next (or previous) image in the array. If you are at the last image the ‘Container’ will then slide back to the first.
  • The width is defined in the XML file, though it would be great if it could be found dynamically rather than hard coded.

Any help or tips to extend this would be greatly appreciated.

I have attached a .zip file of both the .fla (flash 8) and xml as well as each file separately.

Thanks!

Hope all is well.

// Matt

Heres the initial AS if you don’t want to grab the files right away:


//Include MC Tween Class
#include "mc_tween2.as"


//XML Action...           
importXML = new XML();
importXML.ignoreWhite = true;
importXML.onLoad = function(success) 
    {
    if (success) 
        {
        var depth = 5;
        var nextX = 0;
        count = 0;
            _root.createEmptyMovieClip("container",2);
        var root = this.firstChild; // The root node
        for (var i = root.firstChild; i != null; i = i.nextSibling) 
            {
            var tempMC = _root.container.attachMovie ("box", "box" + count, depth ++, {_x : (nextX) , _y : (15)} );
            nextX+= tempMC._width + Number(i.attributes.width) + 20;
            tempMC.caption.name_txt.text = i.attributes.name;
            tempMC.holder.loadMovie(i.attributes.image, depth*20);

            count ++;        
            }
        } 
    }
importXML.load("xml_slider.xml");


//Movie Clip Button Functions
         
//Show More Images
more.onRelease = function() {
           container.tween('_x', -1000, .5, 'easeoutquad');
         }
//Show More Images
less.onRelease = function() {
           container.tween('_x', 0, .5, 'easeoutquad');
         }