A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: XML slideshow loop

  1. #1
    Member
    Join Date
    Nov 2000
    Location
    Hollywood, FL
    Posts
    41

    XML slideshow loop

    Im building a flash portfolio/slideshow using XML to dynamically load external .swfs.
    The problem is with gettingthe .swfs( displayed in a center slider ) to display themselves in a loop...

    I think it starts with comparing the length of the childnodes with the numbered ID attribute - to see if its come to the last one - and then reset the node atribute to loop, in order to display the beginning to the sequence.
    Im not sure of the logic/syntax to resolve.

    for example, there might be 5 swfs to display in sequence. The movie clip they are displayed in has spaces for 12 images, so id like the first 5 images to repeat, by loop to fill up the spaces.

    Thanks for reading my post!

    the files are at:
    http://www.mikehalak.com/example/DDG...0_scroller.fla
    http://www.mikehalak.com/example/DDG...0_scroller.swf
    http://www.mikehalak.com/example/por...t_category.xml

    the main peice of actionscript:

    //start XML object
    testXML = new XML();
    testXML.ignoreWhite = true;
    testXML.load ("portfolio_list_category.xml");
    testXML.onLoad = startSlideShow;
    function startSlideShow(success)
    {
    if (success == true)
    {
    rootNode = testXML.firstChild; // this is the 'DDGportfolio' from XML...same as output_XMLroot =this.firstChild.nodeName;
    totalCategories = rootNode.childNodes.length;
    firstCategory = rootNode.childNodes[0].attributes.name;
    currentCategory = firstCategory;
    //nextCategory = rootNode.firstChild.nextSibling;
    currentcategoryIndex = 1;
    updateCategory(firstCategory);
    categoryPortfolioitems = rootNode.firstChild.childNodes.length;// counts portfolio items total within category
    firstSlideNode = rootNode.childNodes[0]. firstChild;
    currentSlideNode = firstSlideNode;
    currentIndex = 1;
    updateSlide(firstSlideNode);
    nextSlide = rootNode.firstChild.childNodes[j].attributes.jpegURL;


    } else {
    output += "Loading Error!";
    }
    }
    //
    function updateSlide(newSlideNode){
    //use VAR j to count# of nodes (ie the last node)
    for(var j = 0; j<rootNode.firstChild.childNodes.length; j++){
    trace (j + " nodeinfo = "+rootNode.firstChild.childNodes[j].attributes.jpegURL+ " var info C = "+ C +" var showItemID value= "+showItemID);
    var c = 0;
    //use showItemID to synch ID attribute in XML with VAR j (measures # of nodes, to cause end of nodes to loop)
    showItemID = rootNode.childNodes[0].lastChild.attributes.id;
    //if (showItemID = undefined) {showItemID=0};
    //if (showItemID == j) {startshowItemLoop = "true"};
    nextimagePath = rootNode.childNodes[0];
    //loadMovie(imagePath, scrollBox.sliderClip.previewClip1);

    //if (startshowItemLoop = "true"){};
    if (showItemID !== j) {startshowItemLoop = 1}
    if (showItemID == j) {startshowItemLoop = 0}

    if (showItemID !== j) {loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip1)};
    //if(showItemID = j) {loadMovie(nextimagePath.childNodes[0].attributes.jpegURL, scrollBox.sliderClip.previewClip1)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip2)};
    //if(showItemID = j) {loadMovie(nextimagePath.childNodes[0].attributes.jpegURL, scrollBox.sliderClip.previewClip2)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip3)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip4)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip5)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip6)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip7)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip8)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip9)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip10)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip11)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip12)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip13)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip14)};

    if (showItemID !== j){loadMovie(nextimagePath.childNodes[c++].attributes.jpegURL, scrollBox.sliderClip.previewClip15)};
    }

    slideText = newSlideNode.firstChild.attributes.txt;
    imagePath = newSlideNode.attributes.jpegURL;
    //imagePath = newSlideNode.attributes.jpegURL;
    //nextimagePath0 = rootNode.firstChild.childNodes[0].attributes.jpegURL;
    //nextimagePath1 = rootNode.firstChild.childNodes[1].attributes.jpegURL;
    //nextimagePath2 = rootNode.firstChild.childNodes[2].attributes.jpegURL;
    //nextimagePath3 = rootNode.firstChild.childNodes[3].attributes.jpegURL;
    //nextimagePath4 = rootNode.firstChild.childNodes[4].attributes.jpegURL;


    // below are the original previews
    loadMovie(imagePath, previewClip);
    loadMovie(imagePath, targetClip);
    } // End of the function


    // thing to select category from xml and display corresponding content
    // end of


    // control for 'Next' button
    next_category_btn.onRelease = function ()
    {
    _root.alert = ""; //this compares the current slide with the total number of slides in its category
    if (currentIndex == (categoryPortfolioitems-1)) // -1 in order to keep count synchronized.

    {_root.alert = "last item in category";}

    slideText = currentSlideNode.firstChild.attributes.txt;
    nextSlideNode = currentSlideNode.nextSibling;
    if (nextSlideNode == null)
    {//nextSlideNode = nextCategory.firstChild;
    }
    else
    {
    currentIndex++;
    updateSlide(nextSlideNode);
    currentSlideNode = nextSlideNode;
    }
    }

    // control for 'back' button
    back_category_btn.onRelease = function ()
    {
    slideText = currentSlideNode.firstChild.previousSibling.attrib utes.txt;
    previousSlideNode = currentSlideNode.previousSibling;
    if (previousSlideNode == null)
    {
    }
    else
    {
    currentIndex--;
    currentSlideNode = previousSlideNode;
    updateSlide(previousSlideNode);
    }
    }
    Attached Files Attached Files
    www.mikehalak.com

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