FLEX3:加载嵌入文本文件的内容到一个变量变量、文本文件、加载、内容

由网友(一个人熬过所有孤单日子)分享简介:我有一个其上显示给用户的TextArea HTML文本的块。目前,我已经嵌入HTML作为在我班的一个XML对象,但是这似乎是一个可怕的设计。我希望把HTML中嵌入的文件,并加载到一个XML或String对象。I have a block of html text which is displayed to the u...

我有一个其上显示给用户的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)
阅读全文

相关推荐

最新文章