4 Replies Latest reply on Apr 13, 2007 11:39 AM by IndieMonkey

    XML gallery problem

    IndieMonkey
      Hi,

      Im using a pretty straight forward script to import images with thumbs via XML, Thats below:

      myPhoto = new XML();
      myPhoto.ignoreWhite = true;
      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 ;
      this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
      this.thumbHolder._y = i*spacing;
      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;
      };
      }
      };
      myPhoto.load("xmlphoto.xml");

      Now all I need to do is create columns - what would be the best way!?

      Thanks for reading,

      Gavin

        • 1. Re: XML gallery problem
          kglad Adobe Community Professional & MVP
          first, decide how many images (say n) in a column. second, assign the _x property of thumbHolder[ i ] by horizontalSpacing*Math.floor(i/n) and the _y property by verticalSpacing*(i%n)
          • 2. Re: XML gallery problem
            IndieMonkey Level 1
            Hi, Thanks for the speedy reply! I tried changing to the suggestion u made, as below but it didn't work! I think I did it wrong? Can you take a look please?

            myPhoto = new XML();
            myPhoto.ignoreWhite = true;
            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 ;
            this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
            this.thumbHolder._y = i*verticalSpacing*(i%2);
            this.thumbHolder._x = i*horizontalSpacing*Math.floor(i/2);
            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;
            };
            }
            };
            myPhoto.load("xmlphoto.xml");


            THANKS AGAIN!

            Gavin
            • 3. Re: XML gallery problem
              kglad Adobe Community Professional & MVP
              you don't have verticalSpacing and horizontalSpacing defined. and when displaying code in this forum use that attach code option. otherwise your [ i ] is interpreted as encoding for italic font. and that breaks your code and makes it difficult to read:

              • 4. Re: XML gallery problem
                IndieMonkey Level 1
                Ah yeah of course!! It still dosn't work though! It's actually making me want to pop my eyes out of sockets with a teaspoon so I don't have to bother with it anymore. Any more suggestions?

                PS Thanks for all the help anyway if not!

                Gavin