URL encoding MX problem
- Started
- Last post
- 21 Responses
- stewart
strange, but maybe someone can explain this:
i'm importing text from an external .txt file into flash, so i can easily update the content without opening the .fla files.
nothing special.BUT:
1. if i use the "System.useCodePage=true;" method to encode special characters like é and ü in Flash MX it only works in the exported swf document, but not when the swf is embedded in a html file.
2. if i use the "UTF-8" method combined with the "#include document" (like explained here http://www.kirupa.com/developer/… ) all special characters are displayed okay, also when the swf is embedded in a html file.
the strange thing here is that when i change the text in the .txt file using method 2, the old text is displayed in the swf. even when i delete the browser cache etc.
anyone with a good solution?
because i don't want to use %EB %20 etc for special characters in the .txt document...
- welded0
Can you find and replace the special characters with the hex (or whatever %20 and the like is) via Actionscript?
- stewart0
good question.
but isn't that a little too complicated welded?
- ozhanlion0
imho you need a function to change that variable name to +1 everytime you call loadVariables()
that way you can bypass that chache thingy. and also make sure to save txt as utf-8
- welded0
Ya, likely it is, especially if you're working with lots of text, but I've used a similar technique with javascript and it worked really well.
- stewart0
oz, it has nothing to do with cached or not.
if i use #include, the text is fixed in the swf. if i change the text of the txt file or completely delete the txt file, the text is still in it, even if i play the swf 'stand alone'.
what do you mean with save the text as UTF-8?
my txt file starts with //!-- UTF-8 ... isn't that enough?
- ozhanlion0
open your notepad, paste your text and then save as txt you will see the popup and there your second option is save as unicode, maybe that helps, although I am not so sure.
sorry dood I am just drowning with stupid work here, wanna look at in the evening hopefully.
but I am sure thereis a workaround.
- Anarchitect0
ozhanlion's right saving your txt with utf-8 is enough [never had a problem with ã,é,ò,ç....]
there's some info, but if you do what was described earlier, you'll not need it.
http://www.kirupa.com/developer/…
- stewart0
dangit.
i think the problem is i can't save the .txt files as utf-8???
i'm on mac - BY THE WAY.
but if i start the .txt documents with //!--UTF-8 and load it into my swf using #include "file" it all works like it should, except that when i update the text in the .txt file it shows the OLD text in the swf online!
- Anarchitect0
//I use the LoadVars object to load an external txt, php, ....
myVars = new LoadVars();
myVars.onLoad = function(success){
if (success){
myTextBox.text = this.var;
};
};//to prevent caching of the file you should append a random Number [I can't test using the test scen in Flash, only within a browser]
myVars.load("file.txt?".Math.rou...
- stewart0
bump
- bk_shankz0
If you're in bbedit click the options button and you can save as utf-8 format.
That commented line everyone says to put in there has never worked for me.
- stewart0
sh*t
- bk_shankz0
Send me the text file and I'll save it as utf-8 if you can't find an editor that will do it.
- stewart0
thanks shankz.
but the point is i want the possibility to edit the .txt document on whatever computer in the world...
so saving it to utf-8 is no option.
am i really stuck to adding those dumb %EB codes into my .txt document to show up online as é ü å etc?
i can't believe it.
- ozhanlion0
no you don't. fucking call them from xml, why not ?
share your bitch maybe some hand will heal it.
- stewart0
here it is:
http://www.kulsdom.com/newstoday…in the swf standalone everything is okay,
but in the html it is fucked up...
- unfittoprint0
put the whole thing in an XML file.
you can change the encode from ISO to UTF-8 manually.
- stewart0
"you can change the encode from ISO to UTF-8 manually".
right. thanks.
but i don't have any ideas how this XML document should look like.can i still use the #include file function in flash, or is the "_root.loadVariables("file");" method a better way in this case?
- unfittoprint0
(change the [] with the arrows]
XML file
[?xml version="1.0" encoding="utf-8"?]
[content]
MY TEXT GOES HERE
[/content]FLASH
contentXML = new XML();
contentXML.ignoreWhite = true;
contentXML.onLoad = function(success) {
if (success) {
textvar = contentXML.firstChild.firstChild...
textBox.htmlText=textvar;
} else {
trace("oops! Problem!?");};
//load
contentXML.load("myxml.xml");
- unfittoprint0
anyaway if intent do still use txt files as external surce there'ss some info at macromedia regarding utf-8 encoding for MAC:
check below:
http://www.macromedia.com/suppor…