I want to embed all xml files of a given folder. For now I’m doing something like this:
[Embed(source="../somefolder/file1.xml", mimeType="application/octet-stream")]
private var MyClass1:Class;
[Embed(source="../somefolder/file2.xml", mimeType="application/octet-stream")]
private var MyClass2:Class;
[Embed(source="../somefolder/file3.xml", mimeType="application/octet-stream")]
private var MyClass3:Class;
and
var file:XML;
var bytes:ByteArray;
switch (fileId) {
case 1:
bytes = new MyClass1();
break;
case 2:
bytes = new MyClass2();
break;
case 3:
bytes = new MyClass3();
break;
}
file = new XML(bytes.readUTFBytes(bytes.length));
The list of XML files will grow to 10+ files, so I’m looking for a more elegant and dynamic way to embed those files.
The files should be embedded on compilation, to load them via URLLoader is not an option.
Any ideas?
I don’t think there is a way to do something like :
But you could use a Zip file and access to his content. I use often http://nochump.com/blog/archives/15 to do this kaind of things :
This exemple will display all XML File content contained in embeded files.zip