Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: XML Gallery Help (code fix)

  1. #11
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Hey Nate...

    It ended up being just some missed function closing tags. If you'll notice, the onRelease function within the loop isn't closed.

    Here is the fixed version:

    Code:
    myPhoto = new XML();
    myPhoto.ignoreWhite = true;
    var count:Number = 0; // Variable that counts how many movieclips have rendered thus far
    var yPos:Number = 0;  // Initial _y coordinate of the first row
    myPhoto.onLoad = function(success) {
    	//portfolioTag = this.firstChild;
    	numimages = this.firstChild.childNodes.length;
    	spacing = 70;
    	for (i=0; i<numimages; i++) {
    		this.picHolder = this.firstChild.childNodes[i];
    		this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
    		this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
    		this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
    		this.thumbHolder.title = this.picHolder.attributes.title;
    		this.thumbHolder.main = this.picHolder.attributes.main;
    		this.thumbHolder.onRelease = function() {
    			loader.loadMovie(this.main);
    			title_txt.text = this.title;
    		}
    		if (count == 4) {  // if count = 4, we're at the end of the row
    			count = -1;  // reset count to 0
    			yPos = yPos + 100;  // incease the _y coordinate for the next row (100 = height of element plus padding)
    		}
    		
    		this.thumbHolder._x = count*spacing // set _x coordinate
    		this.thumbHolder._y = yPos;  // set _y coordinate
    		count++; // increase count by 1
    	};
    };
    myPhoto.load("xmlphoto.xml");

  2. The Following User Says Thank You to Medyman For This Useful Post:

    nate51 (05-12-2008)

  3. #12
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    Medyman,

    Thanks for taking the time and sticking with my post, your work helped me fix the issue I was having. Also your description lines made it easy for me to understand what the functions do and how to use them.

    I had to change a few variables to space out the thuumbs and to run the lines vertically instead of horizontal. But the code was easy to understand and took seconds to change.

    Thanks a million!

    -- Nate

  4. #13
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Awesome. Glad you got it working.

Bookmarks

Posting Permissions

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