Jump to content


Problem Creating Simple Login System


  • You cannot reply to this topic
5 replies to this topic

#1 Amrik

    Young Padawan

  • Members
  • Pip
  • 43 posts

Posted 28 February 2007 - 04:03 AM

Guys, I was trying to create a simple login system with Macromedia Flash 8
The Problem I am facing is that eventhough i type in the correct username and password it takes me to the page of Invalid Username and Password. I would tell you guys what all i did
I created a new document 350 x 270 pixels Background color - Red
Then went on to creating a Total of 4 layers
Layer 1 - Static Text
In this i created 3 keyframes on 1,2 and 3
On the First Keyframe I Created Two Static Text
One was Username: (9,46.9) and the other Password:(9,125.9)

On The Second Keyframe I Created another Static Text
"Login Successful!!!!" (91,56.9)

On The Third Keyframe I Created another Static Text
"Invalid Username Or Password. Please Try Again :(" (39,56.9)

Layer 2 - Input Text
On this layer i created only one keyframe on keyframe 1
I made two input boxes with borders
One i kept it to the left of the Static box saying Username: I chosed Single Line and gave the input box the variable name user

The Second one i kept it to the left of the Static box saying Password: I chosed Password (The one where you can choose Single Line , Multiline and so on....) and gave the box the variable name pass

Layer - 3 Buttons
Made 3 Keyframes on 1,2 and 3
On Keyframe 1 i created a button saying "Login"(9,181.8), i kept it under the Password: and gave the button some actionscript code that goes like this
on(release, keyPress "<Enter>"){
	if("sorn" eq user and "cool" eq pass){
		gotoAndPlay(2);
	}else{
		gotoAndStop(3);
	}
}

On Keyframe 2 i created another button saying "Continue"(115,167.8), i kept this button under the "Login Successful!!!!" text
I have yet to give it some codes but let me solve this problem first :)

One The Third Keyframe saying "Back"(115,167.8), i kept it under the "Incalid Password..." text and gave the button some actionscript code that goes like this
on(release, keyPress "<Enter>"){
	gotoAndPlay(1);
}

Layer - 4 Action
I created 3 Blank Keyframes on 1,2 and 3
On the first Keyframe i gave the code:
stop();

This is all i did and when i tried entering the Username and password (correct one) it takes me to Frame 3 :( Where could i have possible gone wrong?
Thanks,
Anusorn a.k.a Amrik :)

#2 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 28 February 2007 - 09:54 AM

Just fyi, you probably shouldnt make a login like that. If you decompile the swf, you will be able to get the required login and password from you code. Not the most secure way to keep people out....

and you might need to change your gotoAndPlay to _parent.gotoAndPlay or somthing like that. You should check to make sure that your vars are set. Try tracing the pass and username vars on release of the button. And I dont think pressing the enter key will work to activate the button.

#3 Amrik

    Young Padawan

  • Members
  • Pip
  • 43 posts

Posted 28 February 2007 - 10:57 AM

Thank You For the information about this not the most secure way to keep people out... I am just trying to make a simple login system. Let me make this one work and then i will try to make one that is more secure :)

Pax, can u explain a bit more about the _parent.gotoAndPlay where should i change this? I have 2 gotoAndPlay change both? And I am not really good about the tracing thingy...Can you give me some site that teaches about the Trace command?
Ok i will remove the enter ^^
my vars are set...i have only 2 vars..user and pass... ^^

Thanks Again!

#4 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 28 February 2007 - 11:18 AM

ok, when you trace somthing, it will appear in the output window (same place where errors pop up. use F2 to open the window if you dont have it up).

So if you were to use the following code, whatever appears inside the trace() would show up in your output window. It is a very useful way to debug.

trace("Button scope: " + this); Might trace somthing along the lines of:

_level0.instance5

the _parent of instance5 would be _level0, so trace(this._parent) would trace out _level0

on(release, keyPress "<Enter>"){
trace("Username:  " + user "  Password:  " + pass);
trace("Button scope:  " + this);
trace("Button Parent:  " + this._parent);
if("sorn" eq user and "cool" eq pass){
_parent.gotoAndPlay(2);
}else{
_parent.gotoAndStop(3);
}
}

Try that and see what happens. Good luck

#5 Amrik

    Young Padawan

  • Members
  • Pip
  • 43 posts

Posted 28 February 2007 - 08:02 PM

I used your code but it gave me some errors so i changed it to this one and it said The Script contains no error.
But it is not working, this is what i get after i press Login

on(release, keyPress "<Enter>"){
trace("Username:  " + user);
trace( "  Password:  " + pass);
trace("Button scope:  " + this);
trace("Button Parent:  " + this._parent);
if("sorn" eq user and "cool" eq pass){
_parent.gotoAndPlay(2);
}else{
_parent.gotoAndStop(3);
}
}

Username:  <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">sorn</FONT></P></TEXTFORMAT>
  Password:  <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">cool</FONT></P></TEXTFORMAT>
Button scope:  _level0
Button Parent:  undefined


#6 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 28 February 2007 - 09:26 PM

Ok, now that is very helpful! And sorry bout the error in the code, forgot a + sign in the trace.

Anyways, This should solve some problems. your user variable is:

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">sorn</FONT></P></TEXTFORMAT>

which does not equal sorn. Same problem with your password var. You should be able to take the _parent's out. Seems your entire stage is the button.

So you'll be needing to figure a way to get your login and password variables into flash without all that other gibberish. Where/how are you defining your user/pass variables?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users