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

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

问题描述

我有一块 html 文本,它在 TextArea 中显示给用户.目前,我已将 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;

需要注意的是,这是作为 ByteArray 嵌入的,因此您需要将其读出.类似于以下内容:

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天全站免登陆