Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-14-2005, 06:29 AM
Junior Member
 
Join Date: Feb 2005
Posts: 6
Default Write data to xml...

Hi there,
I am new to SWFKit. Need to know if there is any way to write data into XML file (just like in .txt file).

Pls. reply if you know how to do it.

Thnx in advance.
Reply With Quote
  #2 (permalink)  
Old 02-15-2005, 11:53 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Write data to xml...

1. in the actionscript make a xml object and convert it to a string
2. in swfkit, get the value of the xml string
Code:
var xml = FlashPlayer.getVariable("_root.myXML");
3. write the string into a xml file
Code:
var name = Dialogs.fileSave("XML file(*.xml)|*.xml|");
if (name)
{
    var file = new FileStream(name, "w");
    file.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
    file.writeLine(xml);
    file.close();
}
You can convert a ansi string to utf8 string if your xml contains special charactors
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;
}
See also: http://www.swfkit.com/forum/thread_1_737.html
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:42 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.