Actionscript 读取 XML 并写入列表
我正在尝试将 XML 文件的内容保存在列表中,但收到此错误:1084: 语法错误:冒号前需要 rightparen。
注意:我认为我缺少 >导入
东西,但我尝试了flash.net.List
但没有做任何事情。
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class Main extends MovieClip
{
public function Main()
{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
function loadXML(e:Event):void
{
var xml:XML = new XML(e.target.data);
var nodes = xml.firstChild.childNodes;
for(var i:int =0;i<nodes.length;i++) {
lista.addItem(label: nodes[i].firstChild.nodeValue, data: i);
}
}
loader.load(new URLRequest("http://127.0.0.1:8090/NewProj/index.php?tipo=get"));
}
}
}
有什么想法吗?谢谢
I'm trying to save the contents of a XML file on a list, but I'm getting this error: 1084: Syntax error: expecting rightparen before colon.
Note: I think Im missing an import
stuff, but I tried flash.net.List
and didnt do a thing.
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class Main extends MovieClip
{
public function Main()
{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
function loadXML(e:Event):void
{
var xml:XML = new XML(e.target.data);
var nodes = xml.firstChild.childNodes;
for(var i:int =0;i<nodes.length;i++) {
lista.addItem(label: nodes[i].firstChild.nodeValue, data: i);
}
}
loader.load(new URLRequest("http://127.0.0.1:8090/NewProj/index.php?tipo=get"));
}
}
}
Any ideas? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题在于这一行:
您需要将此语法 (
key: value, key: value
) 包装在大括号中,它使用表示的属性初始化
及其对应的值由Object
>keyvalue
表示。addItem()
还应该期望一个Object
作为其第一个也是唯一的必需参数。Your issue is on this line:
You need to wrap this syntax (
key: value, key: value
) in curly braces, which initializes anObject
with properties represented bykey
and their corresponding values represented byvalue
.addItem()
should also expect anObject
as its first and only required argument.