Frame in Flash…
[AS]myLV = new LoadVars();
myLV.onLoad = function(success){
if (success){
//pull string into Flash and split it at the “;” to parse it into an array
myVarsArray = this.myVars.split(“;”);
//anything else you want to do here…
} else {
trace(“file failed to load”);
}
};
myLV.load(“textFile.txt”);[/AS]
Thats a quick example, but I am not exactly sure what you are trying to do. Do you want it to go in order? Or be random? How are you displaying the info?
i have to do a game like. i give a word “ALI” then i show you “D _ _ _ " and you have to guess it’s “DALI” then i show you " _ E _ _” and you have to guess it’s “IDEAL”. make a word with previous letters + one new, that is shown. well, the problem is… how can i make flash know which letter apears in the final word and not in the first one. hard isn’t it ?
Ok, if that was what I was thinking (the hangman type game), I was trying stuff out and I gotta say… if you don’t know AS, you are getting ahead of yourself. I am working on it and still have a buggy version, but quite a bit of “advanced” coding.
Just to make sure we are on the right page… open a new document, paste this on a frame (I hope you have Verdana installed, if not it will show your default font)…
[AS]//Load variables in
myLV = new LoadVars();
myLV.onLoad = function(success) {
if (success) {
myVarsArray = this.myVars.split(“;”);
getWord();
} else {
trace(“file failed to load”);
}
};
myLV.load(“vars.txt”);
//set text formatting options
myTF = new TextFormat();
myTF.font = “Verdana”;
myTF.size = 12;
//create array to store parsed word
var parsedWordArray = ;
//create clip to hold textboxes
this.createEmptyMovieClip(“wordContainer”, depth++);
//function to randomly choose a word
function getWord() {
newWord = myVarsArray[random(myVarsArray.length)];
trace(newWord);
parseWord();
}
//function to parse the word into seperate textboxes
function parseWord() {
ranLetterShown = random(newWord.length);
for (var i = 0; i<=newWord.length; i++) {
parsedWordArray* = newWord.charAt(i);
wordContainer.createEmptyMovieClip(“textBoxContainer”+i, i);
wordContainer[“textBoxContainer”+i].createTextField(“letter”+i, i, i20, 20, 15, 20);
wordContainer[“textBoxContainer”+i][“letter”+i].border = true;
wordContainer[“textBoxContainer”+i][“letter”+i].maxChars = 1;
wordContainer[“textBoxContainer”+i][“letter”+i].restrict = “A-Z”;
wordContainer[“textBoxContainer”+i][“letter”+i].setNewTextFormat(myTF);
if (i == ranLetterShown) {
wordContainer[“textBoxContainer”+i][“letter”+i].selectable = false;
wordContainer[“textBoxContainer”+i][“letter”+i].text = parsedWordArray;
} else {
wordContainer[“textBoxContainer”+i][“letter”+i].type = “Input”;
}
wordContainer[“textBoxContainer”+i][“letter”+i].letterVar = i;
wordContainer[“textBoxContainer”+i][“letter”+i].onKillFocus = function() {
if (this.text == parsedWordArray[this.letterVar]) {
trace(“correct”);
this.selectable = false;
this.type = “dynamic”;
} else {
trace(“incorrect”);
this.text = “”;
}
checkWord = “”;
checkValidity();
};
}
for (var r = newWord.length; r<=20; r++) {
wordContainer[“textBoxContainer”+r].removeMovieClip();
}
trace(parsedWordArray);
}
function checkValidity() {
for (var j = 0; j<parsedWordArray.length; j++) {
checkWord += wordContainer[“textBoxContainer”+j][“letter”+j].text;
trace(checkWord);
trace("new: "+newWord);
if (checkWord == newWord) {
trace(“COMPLETED WORD!”);
getWord();
}
}
}
//position word
wordContainer._x = 275-wordContainer._width;
wordContainer._y = 200;
[/AS]
[edit]
Oh and in the same directory you save this create a text file called “vars.txt” and put this in there…