all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

is there a way to output an xml doc from Flash?


is there a way to output an xml doc from Flash? wendallsan
4/14/2005 9:34:18 PM
flash actionscript:
Hi all, I am designing an application that will drill users on various
techniques, sort of an online flash card system. I ultimately want to be able
to distribute this without data and allow users to input their own data which
would be stored outside the flash program on their local system. I am
currently using XML to organize the data and have built a prototype that does a
good job of loading the XML data, parsing it, and displaying it for the user.
I am now trying to figure out how to approach the 'input your own data' side of
this application and I don't see any methods of the XML objects that would
allow me to save XML data to an external file of any kind, there is only the
send() and sendAndLoad() methods. Ideally I am hoping to be able to have users
run this on their local computers without any special server software running.
Can anyone suggest a workaround to be able to output XML data as a '.xml' text
file? Any help is appreciated.
Re: is there a way to output an xml doc from Flash? NSurveyor
4/14/2005 10:56:25 PM
Well, you could use the SharedObject to save the xml as a string, and then you
can retrieve that string. I'm not sure if that's what you're looking for.
Basically, you can save data to the computer without letting the user choose
where it's saved and it's in the form of a .sol file. Here's just a "simple"
example of the uses of the SO:

First, drag the following components to the stage:

TextArea, List, and Button.

Then delete them (this adds them to the Library).

Finally, add the following actionscript to frame 1:

//Set up TextFields
my_fmt = new TextFormat();
my_fmt.align = 'center';
my_fmt.bold = true;
my_fmt.color = 0x000000;
my_fmt.font = 'Comic Sans MS';
my_fmt.size = 22;
//
createTextField('title',1,0,0,Stage.width,100);
title.selectable = false;
title.text = 'Leave a message for yourself!';
title.setTextFormat(my_fmt);
//
my_fmt.align = 'left';
my_fmt.size = 18;
//
createTextField('t1',2,55.5,33.8,Stage.width,100);
t1.selectable = false;
t1.text = 'Message:';
t1.setTextFormat(my_fmt);
//
createTextField('t2',3,58,225.3,Stage.width,100);
t2.selectable = false;
t2.text = 'Selected Message:';
t2.setTextFormat(my_fmt);
//
//Set up Components

createObject('Button','nm',4,{_width:116,_height:22,_x:397.9,_y:71.3,label:'New
Message'});

createObject('Button','dm',5,{_width:116,_height:22,_x:397.9,_y:98.3,label:'Dele
te Message'});
createObject('List','ms',6,{_width:322.9,_height:137,_x:55.5,_y:71.3});
createObject('TextArea','sm',7,{_width:438.9,_height:115.8,_x:58,_y:254.3});
//Get SharedObject
message_so = SharedObject.getLocal('messager');
//Create messages array, if non-existent
if(!message_so.data.messages){
message_so.data.messages = [{label:String(new Date()),data:'Welcome! This
program let\'s you save your very own messages!'}];
}
//Set the list box to show the current messages
ms.dataProvider = message_so.data.messages;
//Save the messages
message_so.data.flush();
//Set up all the component methods and such
update_info = function(){
message_so.data.messages = new Array();
for(var i = 0;i<ms.length;i++){
message_so.data.messages[ i ] =
{label:ms.getItemAt(i).label,data:ms.getItemAt(i).data};
}
message_so.data.flush();
}
ms.change = function(){
sm.text = this.selectedItem.data;
}
ms.addEventListener('change',ms);
sm.change = function(){
ms.getItemAt(ms.selectedIndex).data = this.text;
update_info();
}
sm.addEventListener('change',sm);
nm.click = function(){
ms.addItem({label:String(new Date()),data:'<Message goes here>'});
ms.selectedIndex = ms.length-1;
ms.change();
}
nm.addEventListener('click',nm);
dm.click = function(){
ms.removeItemAt(ms.selectedIndex);
ms.selectedIndex = ms.length-1;
ms.change();
update_info();
}
dm.addEventListener('click',dm);
//Initialize
ms.selectedIndex = ms.length-1;
ms.change();

Re: is there a way to output an xml doc from Flash? Ajay Vyas
4/15/2005 12:00:00 AM
Hi,
The shared object is the only way to store some data in user machine.
There are limitations to this also, the data is avliable to the movie
downloaded from the same URL and there are linitation to the amount of data one
can save.
But this is good frature macromedia offered.
Ajay
Re: is there a way to output an xml doc from Flash? mandingo
4/15/2005 12:00:00 AM
but the Shared Object doesn't answer the question...

XML - Flash can't do it (well it can't write it) on it's own...

There are 3rd party apps that do... and I think it may be possible with Flash
Remoting ... or Communication... I don't recall offhand if they do...
AddThis Social Bookmark Button