-
Writing to and Reading from XML
Howdy all,
Im working on a project for my uni course designing educational games for kids. Weve made a handful of games now and are hoping to link them to a website that effectively displays the progress and achievement of the kids playing the games.
Firstly I would like to implement a login page at the beginning of all the games, which checks the login against an xml text file, and allows access if such a name exists.
Then I would like to write to the xml file various ingame variables, such as questions correct, questions incorrect etc. The end goal is then for a webpage to read this data and display it in a table.
Im literally starting from scratch here, if anyone could link me to relevant tutorials or give me any pointers I would really appreciate it, this community has been fantastic in the past, and I credit this site with my continued enjoyment of Flash
Many thanks
-
FK'n_dog
to get you started, here is a simple login from xml file -
PHP Code:
passwords = new Array();
pwds = new XML();
pwds.ignoreWhite = true;
pwds.load('password.xml');
pwds.onLoad = function() {
rootNode = pwds.firstChild;
len = rootNode.childNodes.length;
for (var x=0; x<len; x++) {
nme = rootNode.childNodes[x].attributes.nme;
pass = rootNode.childNodes[x].attributes.pass;
obj = {nme:nme,pass:pass};
passwords.push(obj);
// use List Variables to see how the array gets populated
} // end for
}; // end onLoad
submitButton.onRelease = checkPwd;
function checkPwd(){
len2 = passwords.length;
verify = false; // boolean value - must be set to true to continue
// userName and passwd are variable names of Input textfields
if(userName == "" || passwd == "") verify = false; // if empty fields
for(var yy=0; yy<len2; yy++){
if(userName == passwords[yy].nme && passwd == passwords[yy].pass){
verify = true;
break;
} // end if
} // end for
if(verify){
trace("correct name/password");
}else{
trace("incorrect name/password");
} // end if/else
}; // end checkPwd
/* --passwords.xml--
<clients>
<client nme="shane" pass="123" ></client>
<client nme="mike" pass="456" ></client>
</clients>
*/
-
You cannot write to a XML file (or any other file format) directly from Flash. You must use a third-party scripting such as PHP or ASP to do that.
-
I Keep this on mind !!!, thanks a lot
-
XML flash
What about creating an XML? can you have the flash interface where the user enters his questions and answers and points, system, then when the user clicks enter, the xml is made, and a swf is made. Then in another swf, the xml is called on to load that swf?
-
As I said before you cannot create/write a XML file directly from Flash. To do this, you must get the user answers, points, etc, pass it by GET/POST to a PHP script and then write the XML file from PHP.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|