我正在將sowpods字典嵌入AS3中的數組中,然後使用indexOf()提交搜索以驗證該單詞的存在。AS3:在數組上具有indexOf()的大型文本文件
當我加載一個較小的文本文件,它似乎工作,但不是更大。由於該文件是在編譯過程中嵌入的,因此不應該有加載的事件來正確地進行聆聽?
代碼:
package {
import flash.display.MovieClip;
public class DictionaryCheck extends MovieClip {
[Embed(source="test.txt",mimeType="application/octet-stream")] // Works fine 10 rows.
//[Embed(source="sowpods.txt",mimeType="application/octet-stream")] //Won't work too large.
private static const DictionaryFile:Class;
private static var words:Array = new DictionaryFile().toString().split("\n");
public function DictionaryCheck() {
containsWord("AARDVARKS");
}
public static function containsWord(word:String):* {
trace(words[10]); //Traces "AARDVARKS" in both versions of file
trace((words[10]) == word); // Traces true in shorter text file false in longer
trace("Returning: " + (words.indexOf(word))); // traces Returning: 10 in smaller file
if((words.indexOf(word)) > -1){
trace("Yes!"); // traces "Yes" in shorter file not in longer
}
}
}
}