A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [CS3] Need help with thumbnail gallery

  1. #1
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197

    [CS3] Need help with thumbnail gallery

    I'm having a problem which I can't seem to solve....

    I'm using a Tree menu filled from a XML file,
    in the EventListener, a function gets called which loads the thumbnails from the selected node, into a movieclip like this:

    PHP Code:
    graphicXML = new XML();
    graphicXML.ignoreWhite true;
    graphicXML.onLoad = function(success) {
        if (
    success) {
            
    tofillTreeGraphicdesign();
        } else {
            
    trace("The XML could not be loaded");
        }
    };
    graphicXML.load("content/content.xml");

    function 
    tofillTreeGraphicdesign() {
        
    graphicdesign.dataProvider graphicXML.firstChild.childNodes[1].childNodes[0];
        
    graphicdesign.addEventListener("change",listChanged_G);
    }

    listChanged_G = new Object();
    listChanged_G.change = function(evt_obj) {
        var 
    node evt_obj.target.selectedNode;
        if (
    graphicdesign.getIsBranch(node)) {
            
    thumbnails = [];
            
    total node.childNodes[4].childNodes.length;
            for (
    i=0i<totali++) {
                
    image[i] = node.childNodes[4].childNodes[i].firstChild.nodeValue;
                
    thumbnails[i] = node.childNodes[4].childNodes[i].firstChild.nodeValue;
                
    thumbnails_fn(i);
            }
            } else {
            }
        } else {
        }
    };

    function 
    thumbnails_fn(k) {        detail_mc.thumbnails_mc.createEmptyMovieClip("t"+k,detail_mc.thumbnails_mc.getNextHighestDepth());
        
    tlistener = new Object();
        
    tlistener.onLoadInit = function(target_mc) {
            
    target_mc._x detail_mc.hit_left._x+(target_mc._width+5)*k;
            
    target_mc.pictureValue k;
            
    target_mc.onRelease = function() {
                
    this.pictureValue-1;
                
    nextImage();
            };
            
    target_mc.onRollOver = function() {
                
    this._alpha 50;
                
    thumbNailScroller();
            };
            
    target_mc.onRollOut = function() {
                
    this._alpha 100;
            };
        };
        
    image_mcl = new MovieClipLoader();
        
    image_mcl.addListener(tlistener);    
    image_mcl.loadClip("content/projects/thumb_icon.swf","detail_mc.thumbnails_mc.t"+k);

    But, if the first selected node contains 5 thumbnails for example, and you select another node which contains only 2 thumbnails, the other 3 thumbnails (from the first selected node) stay visible...

    Somehow, the movieclip needs to be unloaded first or the thumbnail array needs to be cleared, I'm not quit sure how to do this?

    I hope I explained it right like this...
    Does anyone have an idea?

    Any help is very very welcome!
    Thanks!
    Toine Kamps | Design & Coding
    toinekamps.com

  2. #2
    Senior Member Alluvian's Avatar
    Join Date
    Jun 2006
    Posts
    967
    Does this code compile?

    In the 'listChanged_G.change' function I see two empty else clauses and only one if...

  3. #3
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197
    Hi Alluvian,

    I'm not quit sure what you mean with if the code compiles...
    I modified an excisting Tree Eventlistener, which looked like this:

    PHP Code:
    listChanged_G = new Object();
    listChanged_G.change = function(evt_obj) {
        var 
    node evt_obj.target.selectedNode;
        
        
    //If it is a folder…
        
    if (graphicdesign.getIsBranch(node)){
            
    //If this is a branch, expand/collapse it.
            
    if (graphic.getIsOpen(node)){
                
    graphic.setIsOpen(nodefalsetrue);
            }
            
    //We opened it if this closed 
            
    else{
                
    graphic.setIsOpen(nodetruetrue);
            }
        }
        
    //If it is a bond…
        
    else{
            
    loadMovie(selectedNode.attributes.img"_root.picholder");
        }

    However, the Treenodes aren't really branches, but because they contain childNodes (for the thumbnails), Flash 'sees' them as branches.
    So therefore the code is between the if (graphicdesign.getIsBranch(node))...

    The second } else { is from the for (i=0; i<total; i++) part,
    I could take the } else { out, but I don't think that's where the problem is.....

    Thanks for your time!
    Toine Kamps | Design & Coding
    toinekamps.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