tags:

views:

128

answers:

1

hi, i am trying to develop an flash application.

where they have designed the entire front end by flash. now i need to doing the functionality part like taking the data from flash and save in database(sqlserver r mysql) using ( asp.net 3.5 frame work) . now as flash is able to read xml file there is no issue in it.

but how to write an xml file from flash and send to dot net frame work. like in the page we have 3 textbox where an user enter the values. now i need take those value and put in an xml format and from xml format give the data to .net framework extract the req values from xml and save in data base which will be done in c# coding

is this logic going to work. is there any other solution to solve the promblem

thank you

+2  A: 

You can create xml in flash using the e4x syntax.

var xml:XML = <root/>;
var child:XML;
for(i = 0; i < 3; i++)
{
  child = <text/>;
  child.@id = i + 1;
  child.appendChild(textFields[i].text);
  xml.appendChild(child);
}
//always use toXMLString (and not toString) on xml objects
//this is because toString returns empty string for an xml object 
//without any children (like <root id="3"/>)
trace(xml.toXMLString());

//send it using url loader
var urlLoader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("serverurl.asp");
req.data = xml.toXMLString();
urlLoader.load(req);

BTW, you need not use xml for passing data from flash to server. You can pass it as an html query string.

var urlLoader:URLLoader = new URLLoader();
var data:URLVariables = new URLVariables();
//you can use dot syntax and/or [] syntax to add data.
data.total = 3;
for(i = 0; i < 3; i++)
  data["text" + (i + 1)] = textFields[i].text;
var req:URLRequest = new URLRequest("serverurl.asp");
req.data = data;
//it sends "total=3&text1=firsttext&text2=secondtext&text3=thirdText"
urlLoader.load(req);
Amarghosh