Hey, I need to know how I can have a text field load some data from an xml and then the user can change the text in the text field and send it back to the xml file. Like load, edit, send.
Could anyone help me here?
Thanks,
fatnslow
Hey, I need to know how I can have a text field load some data from an xml and then the user can change the text in the text field and send it back to the xml file. Like load, edit, send.
Could anyone help me here?
Thanks,
fatnslow
You would need some backend scripting to allow file access like that. There are many ways to do what you are asking, it would really depend on server setup (OS, etc.).
Jeremy
well backend scripting can be minimized to a simple “save posted data” command. Thats not too hard. In Flash you have the rest of the process and it can get a little involved. Are you at all close to having something functional yet? Or have you just not even tried?
I have no idea to start actually. But isnt it possible to do this with php? Flash loads text, someone edit it, and then flash sends to php, and php to xml? I have no clue how to work with php and xml together.
So any help is appreciated
php is your backend scripting. You really dont use PHP to go to XML, you just use PHP to save it to your server. You’ll start out with an xml file, load it into flash, edit it in flash and then save it to a php script which will save the newly edited version back on the server for the next time its loaded. In that process the XML will basically always be XML.
The php will be simple. Basically a save file script - you can have one of those in like 5 lines, no worries.
Loading the xml isnt hard either nor is sending it from Flash to the php which will save it. The worst part is probably the editing. I cover that pretty well in a tutorial Im writing. If you want a rough draft of it, let me know. Otherwise, you should start with writing a simple XML file and learn loading it into Flash - either that or look up how to save a text file in PHP (all of which are covered in tutorials you can find on the main site kirupa.com).
I guess the .php file can be like this:
<?php
$file = fopen("sponsor.xml", "w+") or die("Can't open XML file");
$xmlString = $HTTP_RAW_POST_DATA;
if(!fwrite($file, $xmlString)){
print "Error writing to XML-file";
}
print $xmlString."
";
fclose($file);
?>
or something close to it atleast (taken from a guestbook). But how do I get it to send and load? my xml look like this:
<text>
<dinkost_text>DinKost er en av hovedsponsorene for V.S.F-F.C og har bidratt godt til draktene. DinKost eies av moren til Simen, og er et nettbasert slanke- og erneringsfirma. De kan gi deg godt med raad, alt fra kosthold og slanketips og til riktig spising iforhold til sportsut0vere.</dinkost_text>
<ots_text>OTS Trading er en av hovedsponsorene til V.S.F-F.C og har bidratt godt til draktene og diverse småting. OTS Trading er faren til Axel sitt selskap. OTS Trading selger, leverer og fikser gravemaskiner o.l.</ots_text>
<plinto_text>Plinto er ogsaa en av hovedsponsorene for V.S.F-F.C. Firmaet eies av faren til Henrik og er ett designer firma. De designer alt fra bord til flyplasser. De har vært med paa aa designe Gardemoen flyplass og har designet noe for en opera.</plinto_text>
</text>
But I dont know how to load and send, and make it editable. so if you could help me here? It three different text fields wich will load one of the three nodes.
Thanks for any help
keep at that guestbook tutorial, it does them both, sending and loading.
Ok, I will see if I can break apart the as.
Thanks for help
Edit: BTW, looking forward to your xml intro, just took a look at your site. nice site
Hmm, the guestbook I have loads an xml, but you cant edit it there. It uses name,date,message fields to send. And it is alittle bit to complicated for me to put together the as, since im not good with as at all. So, any help or tuts are very much appreciated.
thanks
well, like I said before, it can get a little involved. If I was you, Id work on that guestbook tutorial. Editing can get even a little harder.
At simplest terms, though, with your example, you could just load the text into input fields and then, when ready to save just create a new XML based on their current content and send it off to be saved. You really wouldnt be editing so much, but rather loading and then saving a new.
I need to use the edit option, because its not sure the user will be editig all three of the xml nodes, maybe just one of them, and then i cant load and create. But Im not to good with actionscript so having hard time changing the as to fit my fla. I have allready looked at the guestbook script, but I will try again, just alittle bit irritating.
not if you load all the content into the text fields, then, edited or not, its just going right back into a new XML object to be sent off and saved. Youwont have to be messing with the original and even if nothing changes, the end result will remain the same.
But will i not end up with alot of xml files? if that what you mean by creating a new one. But, can’t you just instead of creating new, send to the one that allready is there, by just chaning the text in the nodes? Not good with xml as you see
OK, now I have loaded the text from the xml into three input fields:
//**** Load XML ****************************
myXML = new XML();
myXML.ignoreWhite = true;
receiverXML = new XML();
myXML.onLoad = function(success) {
myXML.contentType = "text/xml";
if (success) {
this.showXML();
} else {
trace("Error loading XML file");
}
};
myIdentifier = Math.round(Math.random()*10000);
myXML.load("sponsor.xml?uniq="+myIdentifier);
receiverXML.onLoad = function() {
this.contentType = "text/xml";
_root.currPage = 0;
this.showXML();
};
//Load nodes:
XML.prototype.showXML = function() {
dinkost.scroll = 1;
ots.scroll = 1;
plinto.scroll = 1;
var numItems = this.firstChild.childNodes.length;
var firstItem = numItems-(currPage*showAmount);
if (currPage == 0) {
previous._visible = false;
}
var lastItem = firstItem-showAmount;
if (lastItem<=0) {
lastItem = 0;
next._visible = false;
}
dinkost.htmlText += this.firstChild.childNodes[0].firstChild.nodeValue;
ots.htmlText += this.firstChild.childNodes[1].firstChild.nodeValue;
plinto.htmlText += this.firstChild.childNodes[2].firstChild.nodeValue;
};
(taken from a guestbook, so some weird things there)
how do I do so when a user clicks a send/edit button, it sends the text back to the xml?
Thanks for help so far senocular
saveButton.onRelease = function() {
myXML.firstChild.childNodes[0].firstChild.nodeValue = dinkost.htmlText;
myXML.firstChild.childNodes[1].firstChild.nodeValue = ots.htmlText;
myXML.firstChild.childNodes[2].firstChild.nodeValue = plinto.htmlText;
myXML.sendAndLoad(“processDatSheet.php”, receiverXML);
}
Your text fields get ‘written’ to with your xml node data, just like you’ve got.
So, basically, you just flip it around and have your xml node data ‘overwritten’ with whatever is currently in those three text fields before you send the entire contents of myXML to the php file.
Excuse me if I make no sense, or if this doesn’t work, I haven’t slept.
Thanks, I’ll try it out now, but whats processDatSheet.php? Is that the php file I got, like this:
<?php
$file = fopen("sponsor.xml", "w+") or die("Can't open XML file");
$xmlString = $HTTP_RAW_POST_DATA;
if(!fwrite($file, $xmlString)){
print "Error writing to XML-file";
}
print $xmlString."
";
fclose($file);
?>
Thanks for the help!
Yes.
:: Copyright KIRUPA 2024 //--