0
votes

Is it possible to package a XML file with a Flex app inside the .swf?

With a Silverlight application, you can do this quite easily but you have to do a http request in flash to grab it if you're using flash??

I've been wondering this ever since I did a pretty serious silverlight application and utilized local txt and xml files for settings\data all over the place in it.

And yes I know it can be done with AIR--Don't mention any adobe AIR specific packages PLEASE

2

2 Answers

5
votes

You can do this using the "application/octet-stream" type of Embed:

http://flexscript.wordpress.com/2008/08/02/embedding-text-file-into-flex/

The relevant code:

[Bindable]
[Embed(source="MyFile.txt", mimeType="application/octet-stream")]
private var myFileClass:Class;
...
var MyFileByteArray:ByteArrayAsset = ByteArrayAsset(new myFileClass());
var story:String = MyFileByteArray.readUTFBytes(MyFileByteArray.length)
0
votes

You could encode your xml as a string when you compile.

Depending on how you roll your builds, this string could be replaced every time you compile.