Answered
Bug or ??
I am building a hangman game (Flash 8), where users can
supply their own list of words in an external text file. I am using
the LoadVariables function and the method for loading variables
from an external text file described in the help system, and this
works fine - as expected - as long as the external text file does
not contain any of the special Danish characters ("æ",
"ø" and "å" - I don't know how these come through on a
non-Danish system. Url-encoding the characters as suggested in the
help for loadVariables, %e6, %f8 and %e5, gives the same error as
typing them to the text file from the keyboard).
The error is connected with the reading of the text file - I think.
Here is the text file, named "words.txt" created in Notepad (on a Windows system):
var1=ost,sko,l%E5sabcd&done="done"
I have reproduced some of my program to demonstrate the error:
var wordlist:Array = new Array();
var letter, textOut:String;
this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());
loadVariables("words.txt", target_mc);
var param_interval:Number = setInterval(checkParamsLoaded, 100);
// A movie clip showing a capital A
a_key.onRelease = function() {
letter = "A";
updateOut();
}
// A movie clip showing a capital Æ (%c6)
ae_key.onRelease = function() {
letter = "Æ";
updateOut();
}
function initGame() {
s = "";
wordlist = target_mc.var1.split(","); // split the list of words to single items
for (i=0; i<target_mc.var1.length; i++) {
s = s + target_mc.var1.charCodeAt(i) + "-";
}
fromFile_txt.text = s;
trace(wordlist);
textOut = "";
}
function updateOut() {
textOut = textOut + letter;
out_text.text = textOut;
}
function checkParamsLoaded() {
if (target_mc.done == undefined) {
trace("Not yet !");
} else {
trace("Done loading words");
clearInterval(param_interval);
initGame();
}
}
Running this with Test Movie gives:
in the Output panel:
Done loading words
ost,sko,l�bcd
in the Flash movie:
111-115-116-44-115-107-111-44-108-65533-98-99-100-
corresponding to:
o s t , s k o , l ??? b c d
This means, that the special Danish character has been replaced along with the "s" and the "a" from the original input with a charactervalue of 65533
I get the same result when running the exported swf file outside the Flash environment.
I have tried - upon a previous response from kglad - thanks - to embed the font Latin 1 in the movie, but with no change in performance. I have also tried adding the font I am using (Tahoma) to the library. The only effect of these two efforts beeing to increase the size of the swf file
Is this a bug - or am I missing something?
The error is connected with the reading of the text file - I think.
Here is the text file, named "words.txt" created in Notepad (on a Windows system):
var1=ost,sko,l%E5sabcd&done="done"
I have reproduced some of my program to demonstrate the error:
var wordlist:Array = new Array();
var letter, textOut:String;
this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());
loadVariables("words.txt", target_mc);
var param_interval:Number = setInterval(checkParamsLoaded, 100);
// A movie clip showing a capital A
a_key.onRelease = function() {
letter = "A";
updateOut();
}
// A movie clip showing a capital Æ (%c6)
ae_key.onRelease = function() {
letter = "Æ";
updateOut();
}
function initGame() {
s = "";
wordlist = target_mc.var1.split(","); // split the list of words to single items
for (i=0; i<target_mc.var1.length; i++) {
s = s + target_mc.var1.charCodeAt(i) + "-";
}
fromFile_txt.text = s;
trace(wordlist);
textOut = "";
}
function updateOut() {
textOut = textOut + letter;
out_text.text = textOut;
}
function checkParamsLoaded() {
if (target_mc.done == undefined) {
trace("Not yet !");
} else {
trace("Done loading words");
clearInterval(param_interval);
initGame();
}
}
Running this with Test Movie gives:
in the Output panel:
Done loading words
ost,sko,l�bcd
in the Flash movie:
111-115-116-44-115-107-111-44-108-65533-98-99-100-
corresponding to:
o s t , s k o , l ??? b c d
This means, that the special Danish character has been replaced along with the "s" and the "a" from the original input with a charactervalue of 65533
I get the same result when running the exported swf file outside the Flash environment.
I have tried - upon a previous response from kglad - thanks - to embed the font Latin 1 in the movie, but with no change in performance. I have also tried adding the font I am using (Tahoma) to the library. The only effect of these two efforts beeing to increase the size of the swf file
Is this a bug - or am I missing something?