选择不同值时加载不同的外部文本文件
当不同的值发生更改时,我在尝试使用动作脚本加载不同的文件时遇到问题。我目前正在使用tilelist,它们有不同的值,所以代码是这样的:(标题就在那里,不相关)
if (startTileList.selectedItem.value == 1)
{
//textFile1 load here
txtTitle.text = "History";
}
else if (startTileList.selectedItem.value == 2)
{
//textFile2 load here
txtTitle.text = "Features";
}
else if (startTileList.selectedItem.value == 3)
{
//textFile3 load here
txtTitle.text = "Gallery";
}
所以我希望在选择不同的值时加载不同的文本文件,但我似乎无法得到它工作了。任何人都可以给我任何解决方案吗?非常感谢。提前致谢。
I am having trouble trying to use actionscript to load different files when different values are changed. I am currently using a tilelist and they have different values so the code is something like this: (the title is just there, non-related)
if (startTileList.selectedItem.value == 1)
{
//textFile1 load here
txtTitle.text = "History";
}
else if (startTileList.selectedItem.value == 2)
{
//textFile2 load here
txtTitle.text = "Features";
}
else if (startTileList.selectedItem.value == 3)
{
//textFile3 load here
txtTitle.text = "Gallery";
}
So I want different text files to be loaded when different value is selected but I cannot seem to get it working. Anybody can give me any solutions? Much appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是一个加载外部文本文件的简单示例:
在这个示例中,我使用 URLLoader 对象。这是一个本机 ActionScript3 对象,可让您下载外部资源。
在 AS3 中加载外部资源是一个异步过程,这就是为什么您必须监听 COMPLETE 事件。
加载后,您将在 URLLoader 对象的名为“data”的属性中找到数据。
Here is a simple example for loading external text file:
In this example, i use a URLLoader object. This is a native ActionScript3 object taht let you download external ressources.
Loading an external ressource in AS3 is an asynchronous process, that's why you must listen to the COMPLETE event.
Once loaded, you will find your data inside the property named 'data' of your URLLoader object.