Ultrashock Forums > Flash > Flash Professional
[Source] Sorting XML Thumbnails into Grid

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
[Source] Sorting XML Thumbnails into Grid
Old 2007-02-15

I've made a simple FLA which loads from XML thumbnails into a grid which you can set:

the starting x and y positions
right padding
bottom padding
thumbnails per row

Get it here: http://gridflare.com/aen/FLAs/xmlthumbsgrid.zip
Qgeis Visual Apparatus
Coming Soon...
postbit arrow 5 comments | 395 views postbit arrow Reply: with Quote   
Registered User
egeis is offline
seperator
Posts: 190
2003-10-16
Age: 27
seperator

Ultrashock Member Comments:
egeis egeis is offline 2007-02-15 #2 Old  
Here's the AS if you want to know before you download.

ActionScript Code:
  1. // Specify your XMl file path
  2. var xmlPath:String = "thumbs.xml";
  3.  
  4. // You can control the starting x and y positions, left/right paddings and top/bottom paddings
  5. function loadThumbs(xmlObj,startX,startY,thumbsPerRow,lrPad,tbPad) {
  6.     // Defaults
  7.     if(!startX) { var startX = 0; }
  8.     if(!startY) { var startY = 0; }
  9.     if(!rows) { var rows = 0; }
  10.     if(!lrPad) { var lrPad = 0; }
  11.     if(!tbPad) { var tbPad = 0; }
  12.     // Setup
  13.     var thumbWidth:Number = 130;
  14.     var thumbHeight:Number = 97;
  15.     // Grid setup
  16.     var nbrPosInit:Array = [startX, startY];
  17.     var nbrColMax:Number = thumbsPerRow;
  18.     var nbrIcr:Array = [lrPad, tbPad];
  19.     // XML Parsing
  20.     var nodes = xmlObj.firstChild.childNodes;
  21.     numThumbs = nodes.length;
  22.     for (var i = 0; i<numThumbs; i++) {
  23.         var t = _root.attachMovie("mc_thumb", "mc_thumb"+i, i+1);
  24.         // Grid positioning
  25.         t._y = Math.floor(nbrPosInit[0]+Math.floor(i/nbrColMax)*(nbrIcr[0]+thumbHeight));
  26.         t._x = Math.floor(nbrPosInit[1]+(i%nbrColMax)*(nbrIcr[1]+thumbWidth));
  27.         t.thumb = nodes[i].firstChild.nodeValue;
  28.         t.loadMovie(t.thumb);
  29.         trace(t.thumb);
  30.     }
  31. }
  32. // XML Object
  33. var xmlObj = new XML();
  34. xmlObj.ignoreWhite = true;
  35. xmlObj.onLoad = function(ok) {
  36.     if (ok) {
  37.         // load thumbbnails for "this" xml object placing them at start x0 and y0, with 5 thumbnails per row, without any padding
  38.         loadThumbs(this, 0, 0, 5, 0, 0);
  39.     } else {
  40.         trace("error loading xml");
  41.     }
  42. };
  43. xmlObj.load(xmlPath);
Reply With Quote  
v-x v-x is offline v-x lives in Bulgaria 2007-02-15 #3 Old  
now that's weird...
the whole morning i've been workin'on just a thing like that, and finally i decided to take a brake and see what's goin' on in here, andd....here it is ....


so...may i use that mate
Reply With Quote  
egeis egeis is offline 2007-02-15 #4 Old  
Feel free to use it for anything. It's on me.
Reply With Quote  
pixelone pixelone is offline pixelone lives in United States 2007-05-08 #5 Old  
Thank you for this tutorial or file.. I really like it. How can I add spacing between the images? Is it possible to make each image into a button where you can define the URL in the XMl file for each image?
Reply With Quote  
depi depi is offline 2008-09-05 #6 Old  
is it possible put a navigation to see only 15(p.e.) thumbs each time?
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: