How do you embed a .txt file?

I’m working on a word-forming game and I need to embed a .txt file. In AS3, I would use this type of coding:

[Embed(source = "../lib/WordList.txt", mimeType = "application/octet-stream")]
public var wordListTxt:Class;

var wordList:ByteArray = new wordListTxt() as ByteArray;
var wordListString:String = wordList.toString(); 
var word:Array = wordListString.split("\n");   //dictionary
var counter:int= 0;
    word[counter] = word[counter].slice(0, -1);
    usedLetter[counter] = false;
}while (counter < word.length);

How would you do this using HaXe + OpenFL?

I think you can use

var wordListString:String = Assets.getText("assets/WordList.txt");

Great. I’ll give it a shot. Thanks hcwdikk!

1 Like

Note: if you want to use lib/ as your assets folder, add this tag to project.xml:

<assets path="lib" />

And you’ll need to access it accordingly:

var wordListString:String = Assets.getText("lib/WordList.txt");
1 Like

Sorry, the “lib” directory was from an AS3 project. It’s all up and going now. (Had a strange issue where it was adding an extra space to each word, but after playing, I removed them).