Reputation: 545
I am developing a flash game and want to upload it to a site. The game has a bunch of text files (~200) that are read in for different purposes (Maps, characters, quests, etc).
Can the text files be embedded in the FLA?
Upvotes: 0
Views: 160
Reputation: 18747
Embed something in FLA? Google says the syntax is as of FlashDevelop, that is,
[Embed(source="relative/path/to/file.ext",mimeType="mime/type")]
const embeddedClass:Class;
So, for text files use relative path, and mimeType can be either "application/octet-stream", with the resultant class be a ByteArray (but you still declare the const as type Class), or "text/plain" (FlashDevelop does not have this available, so no experience, I expect that if this will work, the result will be of type String). After you do an embed, you can access your embedded data via simple
var yourData:YourType = new embeddedClass();
Of course, that "YourType" should be compatible, otherwise you'll get type coercion error. For ByteArrays (and text files) use String, since there is a ByteArray.toString()
method that retrieved the data as a string, which is what you seemingly need. The data will be available instantly.
Upvotes: 1