dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: load multiple xml files from buttons / please help!

  1. #1
    Junior Member
    Join Date
    Apr 2005
    Posts
    14

    load multiple xml files from buttons / please help!

    Does anyone know how to swap out different xml files into a single xml object by use of buttons on the stage? I am trying to set up a page where by clicking on different buttons a user can call up various photo albums that would load that album into a single xml object, swapping one out for another.

    so that button 1 would load "album1.xml"
    button 2 "album2.xml and so on into my one xml object called, myXML;

    here is the code I am currently using:

    var urls:Array = new Array();
    var caps:Array = new Array();
    var whoIsOn:Number;

    // this calls up the default album #1 //

    var myXML:XML = new XML();
    myXML.ignoreWhite = true;

    myXML.onLoad = function () {
    var album:Array = this.firstChild.childNodes;
    for(i=0;i<album.length;i++) {
    urls.push(album[i].attributes.url);
    caps.push(album[i].attributes.caption);}
    attachMovie("imageHolder", "imageHolder", 1)
    imageHolder._x=452.6;
    imageHolder._y=291.2;
    imageHolder.loadMovie(urls[0]);
    imageCaption.text = caps[0];
    whoIsOn = 0;
    }

    myXML.load("xmlfolder/album1.xml");

    when i create button w/ this script:

    button2.onRelease = function (){
    myXML.load("xmlfolder/album2.xml");
    }

    it just adds the xml data to the existing xml object, by extending
    the arrays instead of replacing one for the other.

    I tried creating an seperate object for each album, but then i also
    have to rename and create all new arrays "urls2, caps2", etc and
    this seems like a very lengthy workaround... please help! if anyone
    out there knows of a way I can simply bring in my separate xml docs
    and display them one at a time in the imageHolder i have attached
    to the stage.

    thank you so much for any insight or advice!
    +stephen

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Why don't you create a gallery object that contains all the urls caps etc and then just swap the gallery object when you want to change galleries.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center