ActionScript 3中的XML循环

Posted

tags:

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

and DropShadow Filter :)
  1. // XML LOAD
  2. var myXML:XML = new XML();
  3. var XML_URL:String = "newsXML.xml";
  4. var myXMLURL:URLRequest = new URLRequest(XML_URL);
  5. var myLoader:URLLoader = new URLLoader(myXMLURL);
  6. myLoader.addEventListener("complete", xmlLoaded);
  7.  
  8.  
  9. // HEADLINE
  10. var headLineFormat:TextFormat = new TextFormat();
  11. var headLineX:Number = 0;
  12. var headLineY:Number = 0;
  13.  
  14. headLineFormat.color = 0xFFFFFF;
  15. headLineFormat.font = "Arial";
  16. headLineFormat.size = 36;
  17. headLineFormat.bold = true;
  18.  
  19.  
  20. var shadowHL:DropShadowFilter = new DropShadowFilter();
  21. shadowHL.color = 0x000000;
  22. shadowHL.blurY = 12;
  23. shadowHL.blurX = 12;
  24. shadowHL.alpha = 1;
  25. shadowHL.distance = 0;
  26. var filtersArray:Array = new Array(shadowHL);
  27.  
  28.  
  29. function xmlLoaded(event:Event):void
  30. {
  31. myXML = XML(event.target.data);
  32. for (var i:Number = 0; i < myXML.news.headline.length(); i++)
  33. {
  34. // HEADLINE
  35. var headLine:TextField = new TextField();
  36. addChild(headLine);
  37. headLine.text = myXML.news[i].headline;
  38. headLine.y = headLineY;
  39. headLine.x = headLineX;
  40. headLine.width = 70;
  41. headLineY -= 50;
  42. headLine.wordWrap = true;
  43. headLine.autoSize = TextFieldAutoSize.LEFT;
  44. headLine.setTextFormat(headLineFormat);
  45. headLine.filters = filtersArray;
  46. }
  47. }

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

ActionScript 3 如何在eclipse中的工作区之间移动片段

动作脚本 3.0;循环音频文件

在Adobe Animate ActionScript 3.0中循环

ActionScript 3 很短的片段:cutString()

ActionScript 3 基本的JSFL片段

ActionScript 3 修复AS3中的循环声音暂停问题