Hola, Im an experienced coder, however new to java/actionscript 3
I am trying to make a very simple login and I am running into problems. They seem to be with my for loop with the .Length() function in particular...
stop();
loginError.visible = false;
var loginXml:XML;
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("logindata.xml"));
loader.addEventListener(Event.COMPLETE, loadXML);
var loginData = new Array();
var temp:Array = new Array();
function loadXML(e:Event):void
{
loginXml = new XML(e.target.data);
var total = loginXml.item.length();
var x:int = 0;
for(x=0; x < total; x++)
{
loginData[x] = new Array();
loginData[x][0] = loginXml.item[x].user.toString();
loginData[x][1] = loginXml.item[x].pass.toString();
}
}
loginBtn.addEventListener(MouseEvent.CLICK, loginFunction2);
function loginFunction2(e:MouseEvent):void
{
var success:Boolean = false;
//SEEMS TO BE WHERE MY ERROR STARTS
var lengthLD:int = loginData.length();
for(var i=0; i < lengthLD; i++) //Most Likley the Error
{
if(user.text == loginData[i][0] && pass.text == loginData[i][1])
{
success = true;
gotoAndStop(user.text);
}
}
if(!success)
{
loginError.visible = true;
}
}
Any help would be great,
Thanks : )