Flash从文本文件获取数据的具体操作
时间:2022-10-26 17:54
小伙伴们你们知道在Flash从文本文件获取数据呢?今天小编很乐意与大家分享在Flash从文本文件获取数据的技巧,感兴趣的可以来了解了解哦。
Flash从文本文件获取数据的具体操作
1、创建一个记事本文件,输入flash要获取的文本。

2、创建一个Flash档,把文本文件和Flash文档都保存在服务器网站的同一个目录中。

3、把Flash的图层1重命名为代码图层,打开动作面板。先定义一个字符串变量Path,用以保存文本文件的网站地址。

4、定义一个URLRequest类型变量Request和一个URLLoader型变量txtget。

5、创建一个动态文本实例,用变量txt引用它。

6、把实例txt添加到显示例表中,如图所示。

7、获取文本的网站路径即网址,保存在变量Path中。

8、创建URLRequest和URLLoader类型实例,实例名为Request和txtget。

9、用try方法尝试获取文本文件中的数据,若失败显示“加载文本文件失败”。

10、注册实例txtget的complete事件的侦听器,接收者函数为onComplete。

11、最后,定义函数onComplete,具体实现Flash文件从文本中获取数据,若获取成功,Flash舞台将显示文本文件中的诗句。

12、运行程序,在Flash舞台显示文本文件中的诗句,成功实现Flash从文本文件获取数据。

上文就讲解了Flash从文本文件获取数据的详细步骤,希望有需要的朋友都来学习哦。