A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: multiple xml galleries

  1. #1
    Member
    Join Date
    Jun 2004
    Posts
    32

    multiple xml galleries

    Okay, so I did what I was supposed to do. I've looked through hundreds of posts for the answer to this. many come close to addressing/resolving my question but not dead on. I have the typical XML enabled photo gallery. I am using this format to display different themed galleries. So for example, one will be pictures from 2004, another from 2005 and so on. I want a button to load the appropriate .xml file and begin to display the images while still being able to use the same previous and next buttons that are already on the page. Can anyone help? I thought about assignign each gallery to it's own frame and having a 2004 button just go to the appropriate frame, but I am trying to really make this dynamic. Any help would greatly be appreciated. Below is the code I have so far. Thanks in advance!



    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    //declare image and description as array
    image = [];
    description = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    }
    firstImage();
    } else {
    content.text = "file not loaded!";
    }
    }
    xmlAlbum = new XML();
    xmlAlbum.ignoreWhite = true;
    xmlAlbum.onLoad = loadXML;
    xmlAlbum.load("images.xml");
    //////////////////////////////////////////////
    p = 0;
    function nextImage() {
    if (p<(total-1)) {
    p++;
    photo_mc.loadPhoto(image[p]);
    desc_txt.text = description[p];
    picture_num();
    }
    }
    function prevImage() {
    if (p>0) {
    p--;
    photo_mc.loadPhoto(image[p]);
    desc_txt.text = description[p];
    picture_num();
    }
    }
    function firstImage() {
    photo_mc.loadPhoto(image[0]);
    desc_txt.text = description[p];
    picture_num();
    }
    ///////////////////////////////////////////////
    var SPACING = 10
    photo_mc._alpha = 0;
    MovieClip.prototype.loadPhoto = function(photo) {
    photo_mc._alpha = 0;
    this.loadMovie(photo);
    _level0.onEnterFrame = function() {
    // modified the total and loaded so as to round it up
    // to smaller number.
    var total = photo_mc.getBytesTotal();
    var loaded =photo_mc.getBytesLoaded();
    if (total != 0 && Math.round(total/loaded) == 1 && photo_mc._width>0)
    {
    var w = photo_mc._width+SPACING, h = photo_mc._height+SPACING;
    border.resize(w, h, pic);
    delete this.onEnterFrame;
    }
    };
    };
    MovieClip.prototype.resize = function(w, h, pic)
    {
    //the higher the slower the resize of the border
    var speed = 2;
    photo_mc._alpha = 0;
    this.onEnterFrame = function()
    {
    this._width += (w-this._width)/speed;
    this._height += (h-this._height)/speed;
    if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1)
    {
    this._width = w;
    this._height = h;
    photo_mc._x = this._x-this._width/2+SPACING/2;
    photo_mc._y = this._y-this._height/2+SPACING/2;
    photo_mc._alpha += 20;
    if (photo_mc._alpha>90)
    {
    photo_mc._alpha = 100;
    delete this.onEnterFrame;
    }
    }
    };
    };
    previous_btn.onRelease = function() {
    prevImage();
    };
    next_btn.onRelease = function() {
    nextImage();
    };

    function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
    }
    if (p == 0) {
    previous_btn._alpha = 100;
    previous_btn.enabled = true;
    } else {
    previous_btn._alpha = 100;
    previous_btn.enabled = false;
    }
    if (p == (total-1)) {
    next_btn._alpha = 50;
    next_btn.enabled = false;
    } else {
    next_btn._alpha = 100;
    next_btn.enabled = true;
    }

  2. #2
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    Just make a seperate gallery for all your 'years'. Publish each of those galleries as their own swf. Then load the movie's with the correct buttons.
    Each of your movies will be coded to load a different xml file with those images in them. So, when you load the correct 'year gallery', it will load the correct images for that year!
    It's probably the easiest way to use 'the same page' for all your galleries.
    Understand this?

  3. #3
    Member
    Join Date
    Jun 2004
    Posts
    32
    I'm pretty sure I get it, but I guess what I was looking to do was to use the same buttons that are present on the main timeline. Know what I mean? the next_btn and prev_btn indicated in the code i posted earlier, right now, are constants. Only pictures and descriptions are being called.

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