ActionScript XML解析器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript XML解析器相关的知识,希望对你有一定的参考价值。

  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. }

以上是关于ActionScript XML解析器的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 使用换行符解析XML!

ActionScript 3 解析XML文件

ActionScript 3 xml解析

ActionScript 3 基本的外部XML加载器

ActionScript 3 XML管理器类

ActionScript 3 xml加载器类