Posted By

garretjames on 12/02/08


Tagged

actionscript xml


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jslice390


ActionScript XML Parser


 / Published in: ActionScript
 

  1. gallery = "xml/"+ _root.xmlFileVariable + ".xml";
  2. photo = 0;
  3. Photos_xml = new XML();
  4. Photos_xml.onLoad = loadPhotos;
  5. Photos_xml.load(gallery);
  6. Photos_xml.ignoreWhite = true;
  7.  
  8. function loadPhotos(success) {
  9. if (success == true) {
  10. rootNodePhotos = Photos_xml.firstChild;
  11. totalPhotos = rootNodePhotos.childNodes.length;
  12. currentNodePhotos = rootNodePhotos.firstChild;
  13. descriptions = new Array(totalPhotos);
  14. PhotoUrl = new Array(totalPhotos);
  15. BigUrl = new Array(totalPhotos);
  16. links = new Array(totalPhotos);
  17. titles = new Array(totalPhotos);
  18. price = new Array(totalPhotos);
  19. swf = new Array(totalPhotos);
  20. dx = 0;
  21. for (i=0; i < totalPhotos; i++) {
  22. descriptions[i] = currentNodePhotos.firstChild.nodeValue;
  23. PhotoUrl[i] = currentNodePhotos.attributes.PhotoUrl;
  24. BigUrl[i] = currentNodePhotos.attributes.BigUrl;
  25. links[i] = currentNodePhotos.attributes.link;
  26. titles[i] = currentNodePhotos.attributes.title;
  27. price[i] = currentNodePhotos.attributes.price;
  28. swf[i] = currentNodePhotos.attributes.swf;
  29. _root.images.attachMovie("photo","img"+i,i+300);
  30. _root.images["img"+i]._x = dx;
  31. _root.images["img"+i]._y = 0;
  32. _root.images["img"+i].k = i;
  33. dx = dx + 330;
  34. _root.images["img"+i].Url = PhotoUrl[i];
  35. _root.images["img"+i].BigUrl = BigUrl[i];
  36. _root.images["img"+i].link = links[i];
  37. _root.images["img"+i].title = titles[i];
  38. _root.images["img"+i].swf = swf[i];
  39. if (!price[i]){
  40. _root.images["img"+i].price = "";
  41. }else{
  42. _root.images["img"+i].price = price[i];
  43. }
  44. currentNodePhotos = currentNodePhotos.nextSibling;
  45. }
  46. play();
  47. _root.Move = true;
  48. }
  49. }

Report this snippet  

You need to login to post a comment.