Am I doing this wrong??
- PsychoZombii
-
PsychoZombii
- Member since: May. 6, 2009
- Offline.
-
- Forum Stats
- Member
- Level 07
- Programmer
((I feel like I come here too often, sorry guys))
I'm trying to create a functional login for an AS3/XML project I'm working on.
I'm using compressed XML's to store data, and then importing and decompressing them when I need the data.
For some reason, when I test the login, It always traces "login failed...".
but at the same time, it always traces my username, "Psycho".
I'm not sure if it's my code or if i'm just doing something out of order.
I figured you AS3 geniuses could help me out. Pweety Please??
here's my current code:
private function parseXML(e:MouseEvent):void
{
//user clicks login button
_firstRun.loginconfirm.removeEventListener(MouseEvent.CLICK, parseXML);
//my custom XML Loader class loads and decompresses the XML...
_xmlLoader = new XMLLoader("Psycho.xml");
//...and continues when the loader class dispatches the "COMPLETE" event.
_xmlLoader.addEventListener("COMPLETE", login);
}
private function login(e:Event):void
{
_xmlLoader.removeEventListener("COMPLETE", login);
//If the user DOES NOT input the right username/password combo...
if (_firstRun.username.text != _xmlLoader.loadedXML.children().child("myname")
|| _firstRun.password.text != _xmlLoader.loadedXML.children().child("mypass"))
{
//user is not logged in, and movieclip (held inside of a swc) goes to the signup screen instead
trace("login failed...");
//this is supposed to trace the users' username, which it does, so idk the problem
trace (_xmlLoader.loadedXML.children().child("myname"));
//I'll change this later so it displays a message instead
_firstRun.gotoAndStop("signup");
//listens for a click for signing up, outputs user data into a new XML
_firstRun.signupconfirm.addEventListener(MouseEvent.CLICK, writeXML);
}
else
{
//Otherwise, the user is logged in. IT NEVER GETS HERE :(((
trace("login success.");
}
}
- MSGhero
-
MSGhero
- Member since: Dec. 15, 2010
- Offline.
-
- Forum Stats
- Supporter
- Level 16
- Game Developer
At 2/28/14 08:55 PM, PsychoZombii wrote: ((I feel like I come here too often, sorry guys))
I'm trying to create a functional login for an AS3/XML project I'm working on.
I'm using compressed XML's to store data, and then importing and decompressing them when I need the data.
For some reason, when I test the login, It always traces "login failed...".
but at the same time, it always traces my username, "Psycho".
I'm not sure if it's my code or if i'm just doing something out of order.
I figured you AS3 geniuses could help me out. Pweety Please??
here's my current code:
private function parseXML(e:MouseEvent):void
{
//user clicks login button
_firstRun.loginconfirm.removeEventListener(MouseEvent.CLICK, parseXML);
//my custom XML Loader class loads and decompresses the XML...
_xmlLoader = new XMLLoader("Psycho.xml");
//...and continues when the loader class dispatches the "COMPLETE" event.
_xmlLoader.addEventListener("COMPLETE", login);
}
private function login(e:Event):void
{
_xmlLoader.removeEventListener("COMPLETE", login);
//If the user DOES NOT input the right username/password combo...
if (_firstRun.username.text != _xmlLoader.loadedXML.children().child("myname")
|| _firstRun.password.text != _xmlLoader.loadedXML.children().child("mypass"))
{
//user is not logged in, and movieclip (held inside of a swc) goes to the signup screen instead
trace("login failed...");
//this is supposed to trace the users' username, which it does, so idk the problem
trace (_xmlLoader.loadedXML.children().child("myname"));
//I'll change this later so it displays a message instead
_firstRun.gotoAndStop("signup");
//listens for a click for signing up, outputs user data into a new XML
_firstRun.signupconfirm.addEventListener(MouseEvent.CLICK, writeXML);
}
else
{
//Otherwise, the user is logged in. IT NEVER GETS HERE :(((
trace("login success.");
}
}
1) You don't have to use children and child in xml, you can do it more intuitively by treating it like an object and the child nodes are properties. Attributes are .@attribute.
2) .children() and .child() return XMLLists, not strings. XMLLists are not equal to strings. You can index into XMLLists just like arrays.
- PsychoZombii
-
PsychoZombii
- Member since: May. 6, 2009
- Offline.
-
- Forum Stats
- Member
- Level 07
- Programmer
Thanks man! I'm a bit new to XML so i'm still trying to get a grip on it.
This looks a bit easier than I was doing it, I was using a for() loop to append all the children to the root node, lol.
I guess I'll try this way and reply if I have any problems.
- milchreis
-
milchreis
- Member since: Jan. 11, 2008
- Offline.
-
- Forum Stats
- Member
- Level 26
- Programmer
When your .swf file downloads an .xml file that contains the passwords, it means that the user downloads this .xml file.
You pretty much make all passwords public.
Password verification should happen on the server.
- PsychoZombii
-
PsychoZombii
- Member since: May. 6, 2009
- Offline.
-
- Forum Stats
- Member
- Level 07
- Programmer
At 3/1/14 05:35 AM, milchreis wrote: When your .swf file downloads an .xml file that contains the passwords, it means that the user downloads this .xml file.
You pretty much make all passwords public.
Password verification should happen on the server.
Yeah, I was somewhat aware of this.
I'm not so sure how to go about that, so I changed a bit of my code so that the xml will be downloaded as raw, binary data.
Then, I convert to XML in flash. Works fine, so far.
Would that be okay? Or is there still a possible security issue?
- MSGhero
-
MSGhero
- Member since: Dec. 15, 2010
- Offline.
-
- Forum Stats
- Supporter
- Level 16
- Game Developer
At 3/1/14 07:54 PM, PsychoZombii wrote: Would that be okay? Or is there still a possible security issue?
There will always be the possibility of a security issue if others' private info gets sent to the client. That kind of stuff needs to be handled by a server.
- PsychoZombii
-
PsychoZombii
- Member since: May. 6, 2009
- Offline.
-
- Forum Stats
- Member
- Level 07
- Programmer
At 3/1/14 09:01 PM, MSGhero wrote:At 3/1/14 07:54 PM, PsychoZombii wrote: Would that be okay? Or is there still a possible security issue?There will always be the possibility of a security issue if others' private info gets sent to the client. That kind of stuff needs to be handled by a server.
Oh, okay.
Well then, I figured I'd make some sort of php script and upload to my remote server,
then post variables from the client to the php file, and let the php check if the two are equal, and return the result.
Based on my limited knowledge of php, I feel like this is possible.
I also wanted to make a php file that generates an xml (for signup) using variables sent from the client and/or the site.
That being said, this is surely a problem best suited for the programming forum now, heheh.
Thanks for your help everyone!


