FLEX3:加载嵌入文本文件的内容到一个变量 [英] Flex3: Load contents of an embedded text file into a variable

查看:139
本文介绍了FLEX3:加载嵌入文本文件的内容到一个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个其上显示给用户的TextArea HTML文本的块。目前,我已经嵌入HTML作为在我班的一个XML对象,但是这似乎是一个可怕的设计。我希望把HTML中嵌入的文件,并加载到一个XML或String对象。

I have a block of html text which is displayed to the user in a TextArea. Currently, the I have embedded the HTML as an XML object within one of my classes, but this seems like a terrible design. I would like to put the HTML in an embedded file and load it into an XML or String object.

我试图寻找如何做到这一点,但我的搜索返回有关嵌入图像和字体,而不是文字可以被加载到字符串。

I've tried to search for how to do this, but my searches return information on embedding images and fonts, not text which can be loaded into Strings.

是否有可能嵌入文本或XML文件,并将它们加载到变量中的Flex?

Is it possible to embedded text or xml files and load them into variables in Flex?

推荐答案

您可以嵌入一个文本文件与以下内容:

You can embed a text file with the following:

[Embed(source="myFile.txt",mimeType="application/octet-stream")]
private var myFile:Class;

重要的是要注意,这是嵌入一个字节数组,所以你需要读出。类似如下:

It's important to note that this is embedded as a ByteArray, so you will need to read it out. Something like the following:

var b:ByteArray = new myFile();
var s:String = b.readUTFBytes(b.length)

这篇关于FLEX3:加载嵌入文本文件的内容到一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆