Embedding external files using [embed]
Posted on oldhawk reading (43) Comments (0) EDIT favorites category: Flex
OK, I learned this trick a few weeks ago from a co-worker. A user emailed me and asked if it was possible to embed an HTML/text file in a flex application rather than having to load the files at runtime, similar to how you can embed images or whatnot.
Not being certain, I asked the Team and got this response...
Foobar.
Package {
Import flash. utils. bytearray;
[Embed (Source = "test. mxml", mimetype = "application/octet-stream")]
Public class foobar extends bytearray
{
}
}
test. mxml XML version = "1.0" encoding = "UTF-8" ?>
mx: application xmlns: MX = "http://www.adobe.com/2006/mxml" creationcomplete =" testme () " >
mx: script >
Public var mytext: foobar = new foobar ();
Public Function testme (): void {
trace (mytext. tostring ();
}< br> ]>
mx: script >
</MX: Application>
Reprinted: http://www.cnblogs.com/taobataoma/archive/2008/01/13/1037021.html