Flash从文本文件获得数据的详细操作
时间:2022-10-26 13:31
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从文本文件获得数据的详细操作方法。有需要的朋友赶快来看看本篇文章吧。