|
|||
|
Hi
I am loading variables in my application using LoadVars in Actionscript from simple html file. And I need to save these variables back to this html file after changing. Is there any posibility to do this via SWFkit and how can I do this? Thanks in advance! |
|
|||
|
Do you mean saving the variables to a local disk file or sending them back to the remote html file? If former, you can use the FileStream or DataFile object in swfkit; if latter, you can use the "LoadVars" object in actionscript.
|
|
|||
|
I mean saving data to a local disk file. So I tried to use FileStream object:
Code:
stream = new FileStream("data.html", "w+" );
stream.writeLine("&header1="+_root.data_lv.header);
....
stream.close();
Is there any posibility to change encoding of FileStream??? |
|
|||
|
The following code shows how to use the "toUTF8" method (ffish script method) to write a XML file
Code:
//convert a string to an utf8 encoded string stream
function toUTF8(string)
{
var i;
var stream = new StringStream;
for (i = 0; i < string.length; i++)
{
var code = string.charCodeAt(i);
if (code < (1 << 7))
{
stream.put(code);
}
else if (code < (1 << 11))
{
stream.put((code >> 6) | 0xC0);
stream.put((code & 0x3F) | 0x80);
}
else if (code < (1 << 16))
{
stream.put(0xE0 | ((code >> 12) & 0x0F));
stream.put(0x80 | ((code >> 6) & 0x3F));
stream.put(0x80 | (code & 0x3F));
}
else if (code < (1 << 21))
{
stream.put((code >> 18) | 0xe0);
stream.put(((code >> 12) & 0x3f) | 0x80);
stream.put(((code >> 6) & 0x3f) | 0x80);
stream.put((code & 0x3f) | 0x80);
}
}
return stream;
}
var str = '<project name="test" default="init" basedir=".">' +
' <target name="init">' +
' <!-- displays Hello in Chinese -->' +
' <echo message="The Chinese word is: ÊÀ¼Í"/>' +
' </target>' +
'</project>';
var f = new FileStream("c:\\1.xml", "w");
f.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
f.write(toUTF8(str));
f.close();
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|