ActionScript 3 ActionScript 3中的XML循环

Posted

tags:

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

// XML LOAD
var myXML:XML = new XML();
var XML_URL:String = "newsXML.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);


// HEADLINE
var headLineFormat:TextFormat = new TextFormat();
var headLineX:Number = 0;
var headLineY:Number = 0;

headLineFormat.color = 0xFFFFFF;
headLineFormat.font = "Arial";
headLineFormat.size = 36;
headLineFormat.bold = true;


var shadowHL:DropShadowFilter = new DropShadowFilter();
shadowHL.color = 0x000000;
shadowHL.blurY = 12;
shadowHL.blurX = 12;
shadowHL.alpha = 1;
shadowHL.distance = 0;
var filtersArray:Array = new Array(shadowHL);


function xmlLoaded(event:Event):void
{
	myXML = XML(event.target.data);
	for (var i:Number = 0; i < myXML.news.headline.length(); i++)
	{
		// HEADLINE
		var headLine:TextField = new TextField();
		addChild(headLine);
		headLine.text = myXML.news[i].headline;
		headLine.y = headLineY;
		headLine.x = headLineX;
		headLine.width = 70;
		headLineY -= 50;
		headLine.wordWrap = true;
		headLine.autoSize = TextFieldAutoSize.LEFT;
		headLine.setTextFormat(headLineFormat);
		headLine.filters = filtersArray;
	}
}

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

在 JavaScript 和 ActionScript 之间共享数组引用

MXML 和用于移动设备的 ActionScript 之间的真正区别是啥?

ActionScript 3 使用ActionScript 3暂停框架

ActionScript 3 ActionScript 3延迟功能

ActionScript 3 ActionScript 3 SliceBitmap类

ActionScript 3 ActionScript 3中的XML循环