A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Writing to and Reading from XML

  1. #1
    Member
    Join Date
    Nov 2006
    Posts
    69

    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

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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=0x<lenx++) {
    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=0yy<len2yy++){
    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>
    */ 

  3. #3
    flashguy
    Join Date
    May 2005
    Location
    In the mountains
    Posts
    341
    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.
    Visit my business at http://www.ballooncreator.com - Software Tool For Party Balloons Online Design!

  4. #4
    Multimedia Maker
    Join Date
    May 2002
    Location
    Argentina, Buenos Aires
    Posts
    9
    I Keep this on mind !!!, thanks a lot
    presodeminacion@gmail.com
    Multimedia Flash developer

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Posts
    106

    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?

  6. #6
    flashguy
    Join Date
    May 2005
    Location
    In the mountains
    Posts
    341
    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.
    Visit my business at http://www.ballooncreator.com - Software Tool For Party Balloons Online Design!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center