Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex3: Load contents of an embedded text file into a variable

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.

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

like image 587
SorcyCat Avatar asked Jan 26 '10 17:01

SorcyCat


1 Answers

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)
like image 68
Tyler Egeto Avatar answered Oct 05 '22 23:10

Tyler Egeto