使用 flashvar 将请求文件传递到 Flex 应用程序
我正在尝试将包含数据的 xml 文件放入 Flex 应用程序中。我发现网上有很多将参数传递到 Flex 的示例非常有帮助。然而,它在我的情况下并没有真正起作用。
这是我的 HTML 代码:
var flashvars = {};
flashvars.storageStatsXML = "stats.xml";
var params = {};
swfobject.embedSWF("mySWF.swf", "mySWF", "1000", "500", "10.0.0", "js/expressInstall.swf", flashvars, params);
这是 mxml 中的代码:
[Bindable]
public var storageStats:XML;
protected function start(event:FlexEvent):void
{
storageStats = Application.application.parameters.storageStatsXML;
}
然后在应用程序中解析 XML 文件。
我认为代码有一些不正确的地方,有什么想法吗?
谢谢。
I am trying to get a xml file with data into Flex application. There are a lot of examples online passing parameter into flex I found very helpful. However, it doesn't really work in my case.
here is my code in HTML:
var flashvars = {};
flashvars.storageStatsXML = "stats.xml";
var params = {};
swfobject.embedSWF("mySWF.swf", "mySWF", "1000", "500", "10.0.0", "js/expressInstall.swf", flashvars, params);
here is the code in mxml:
[Bindable]
public var storageStats:XML;
protected function start(event:FlexEvent):void
{
storageStats = Application.application.parameters.storageStatsXML;
}
And then the XML file got parsed in the application.
I think there is something not right about the code, any thoughts?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Application.application.parameters.storageStatsXML
属性不是您期望的 XML 数据,它是一个包含文本"stats.xml"
的String
>。就像文件路径“c:\temp\info.txt”(或“/temp/info.txt”)不是文件本身一样,它只是告诉您如何在磁盘上查找该文件。
您需要使用 URLRequest加载由
storageStatsXML
属性指定的 XML 文件。查看 Actionscript 文档和 StackOverflow 上的示例,了解如何加载外部数据。
The
Application.application.parameters.storageStatsXML
property is not the XML data you are expecting, it is aString
containing the text"stats.xml"
.In the same way that the file path "c:\temp\info.txt" (or "/temp/info.txt") isn't the file itself, it just tells you how to find the file on disk.
You will need to use a URLRequest to load the XML file specified by the
storageStatsXML
property.Have a look at the Actionscript documentation and here on StackOverflow for examples on how to load external data.