bking20
November 11, 2016, 1:10pm
#1
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;
do{
word[counter] = word[counter].slice(0, -1);
usedLetter[counter] = false;
counter++;
}while (counter < word.length);
How would you do this using HaXe + OpenFL?
hcwdikk
November 11, 2016, 5:17pm
#2
I think you can use
var wordListString:String = Assets.getText("assets/WordList.txt");
bking20
November 11, 2016, 5:34pm
#3
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
bking20
November 13, 2016, 7:11pm
#5
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).
Thanks!