XML Load事件触发时需要返回一个值actionscript

发布于 2024-12-28 09:00:22 字数 355 浏览 3 评论 0原文

Actionscript 真的让我压力很大!我的代码太混乱了,无法发布,因为我已经尝试了从设计模式到程序方法的所有内容。简而言之,有什么方法可以在加载 URL 请求后检索变量中的 XML 数据吗?

        var req:URLRequest = new URLRequest(url);
        this.loader = new URLLoader(req);
        this.loader.addEventListener(Event.COMPLETE, readXML);

基本上我试图捕获我的 XML 输出,以便我可以将其放在一个列表中。似乎没有办法将其分配给变量而不在事件结束时失去作用域。

Actionscript is really stressing me out! My code is too messy to post as I have tried everything from design patterns to procedural approaches. In short, is there any way i can retrieve my XML data in a variable after loading the URL request?

        var req:URLRequest = new URLRequest(url);
        this.loader = new URLLoader(req);
        this.loader.addEventListener(Event.COMPLETE, readXML);

Basically I am trying to capture my XML output so I can place it a list. There doesn't seem to be a way to assign it to a variable without it losing scope when the event is over.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪恋 2025-01-04 09:00:24

在 readXML 函数中,您可以将 xml 写入 var

私有变量 xml:XML;

私有函数 readXML(e:Event):void{

 xml = new XML(e.target.data);
 跟踪 (xml.toXMLString());

}

in your function readXML you can write the xml into a var

private var xml:XML;

private function readXML(e:Event):void{

 xml = new XML(e.target.data);
 trace (xml.toXMLString());

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文