Skip navigation
Currently Being Moderated

XML Loading by Password

Apr 30, 2012 2:13 PM

Tags: #dynamic #xml #as2 #actionscript #password #navigation #actionscript_2 #2.0

Okay, so I've made a login sytem for my students to use to check their scores in class.  I currently have it set to load their scores from an xml file when they login using they're username and password, that's all good.  My problem is that I want to minimize my file size.  Currently, when they login, they are directed to the frame in my .fla for their info.  I would like to have only the one frame for loading the data, so that their data is connected to their username and pasword and when they login in their data is loaded into the one frame I have created instead of having a frame for each individual student.  Here is a sample of what my xml is like:

 

//-------------------- XML --------------------

<firstperiod>

     <person>

          <name>Last, First</name>

          <grade1> 98 </grade1>

          <grade2> 87</grade2>

          <grade3> 62 </grade3>

          <grade4> 93 </grade4>

          <grade5> 96 </grade5>

     </person>

     <person2>

          <name>Last, First</name>

          <grade1> 98 </grade1>

          <grade2> 87</grade2>

          <grade3> 62 </grade3>

          <grade4> 93 </grade4>

          <grade5> 96 </grade5>

     </person2>

 

</firstperiod>

 

//-------------------- XML End --------------------

 

I have their login hardcoded in to AS2:

 

//-------------------- AS2 Login Script --------------------

login.failed_txt.background = false;

login.failed_txt.border = false;

 

var myName:String;

var myPass:String;

 

loginBtn.onRelease = function (){

myName = username.text;

myPass = password.text;

 

if(myName == "Last1First1" && myPass == "12345678"){

gotoAndStop("FrameLabel1");}

 

if(myName == "Last2First2" && myPass == "123456789"){

gotoAndStop("FrameLabel2");}

 

else {

loginfailed_txt.text = "LOGIN IS INVALID";

}

}

//-------------------- AS2 Login Script End --------------------

 

//-------------------- AS2 XML Load Script --------------------

function loadXML(loaded) {

if (loaded) {

_root.firstperiod = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;

_root.grade1 = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;

_root.grade2 = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;

_root.grade3 = this.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;

_root.grade4 = this.firstChild.childNodes[0].childNodes[4].firstChild.nodeValue;

_root.grade5 = this.firstChild.childNodes[0].childNodes[5].firstChild.nodeValue;

name_txt.text = _root.firstperiod;

grade1_txt.text = _root.grade1;

grade2_txt.text = _root.grade2;

grade3_txt.text = _root.grade3;

grade4_txt.text = _root.grade4;

grade5_txt.text = _root.grade5;

} else {

  trace("file not loaded!");

}

}

xmlData = new XML();

xmlData.ignoreWhite = true;

xmlData.onLoad = loadXML;

xmlData.load("studentscores.xml");

//-------------------- AS2 XML Load Script End --------------------

 

So instead of navigating to the student's frame in the .fla upon correctly entering thier login info, I want the the data to load in, oh let's say frame 2, where the dynamic text boxes are and get rid of all the superfluous frames.  Does that make sense at all?

 

Any help would be greatly appreciated! Thanks!

 
Replies
  • kglad
    72,182 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 30, 2012 2:51 PM   in reply to Claunchster

    where are those names and passwords stored?

     
    |
    Mark as:
  • kglad
    72,182 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 30, 2012 11:13 PM   in reply to Claunchster

    that is not secure.  any novice can extract your user names and passwords and view the grades.

     
    |
    Mark as:
  • kglad
    72,182 posts
    Jul 21, 2002
    Currently Being Moderated
    May 1, 2012 6:43 AM   in reply to Claunchster

    you should use a database on your server to store the data you don't want to be publicly available.  that probably includes the data in your xml file.

     

    you'll also need server-side code to retrieve data from your database.  you can use the loadvars class in flash to call your server-side code.

     
    |
    Mark as:
  • kglad
    72,182 posts
    Jul 21, 2002
    Currently Being Moderated
    May 1, 2012 9:19 AM   in reply to Claunchster

    your database will consist of:

     

    user table:

     

    id  first_name  last_name password

     

    grade table:

     

    id  user_id  grade

     

    where user_id will be the id from the user table that matches the user's login name and password.

     

    your php will return all grades in the grade table that have the matching user_id.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points