Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2012, 09:21 AM   PM User | #1
deafdigit
New Coder

 
Join Date: Jul 2009
Location: Odense, Denmark
Posts: 70
Thanks: 4
Thanked 0 Times in 0 Posts
deafdigit is an unknown quantity at this point
Flash builder and MySQL - string comparison

Okay so I watched this tutorial on how to make a simple Android App using Adobe Flash Builder (4.5).

It basically fires a php-script, sending post-vars, which then does some database checks, and if everything is alright, it echoes "1", else "0". The app is then supposed to do something depending on whether it echoes 1 or 0.

Here's the output-bit of the php-file:
PHP Code:
if($output == $password) {
    echo 
"1";
} else {
    echo 
"0";

(Yes - it's a login-script )

Here's the important actionscript:

Code:
import com.adobe.crypto.MD5;
import com.adobe.crypto.SHA1;
import com.adobe.crypto.SHA256;
protected function button1_clickHandler(event:MouseEvent):void {
var l:URLLoader = new URLLoader();
var r:URLRequest = new URLRequest("path/to/file.php");
var vars:URLVariables = new URLVariables();
				
vars.username = username.text;
vars.password = ********password********;
				
r.method = URLRequestMethod.POST;
r.data = vars;
				
l.addEventListener(Event.COMPLETE, lComplete);
l.addEventListener(IOErrorEvent.IO_ERROR, lError);
				
l.load(r);
				
}
			
protected function lComplete(event:Event):void
{
	if(event.target.data == '1'){
		navigator.pushView(views.Main);
	} else {
		trace(event.target.data);
	}
				
				
}
			
protected function lError(event:IOErrorEvent):void
{
	trace('url error');
		
}
The *********password******** part is because I left out the hashing-algorith I use. That part works though.

Now, when I run the program and give it the appropriate values, it won't do the navigator.pushView(views.Main); thing. It just traces " 1 " (with spaces). And I can't figure out why.

Can somebody help me with this?


//Deafdigit
__________________
HornskovVindberg inkasso
deafdigit is offline   Reply With Quote
Old 01-11-2012, 02:54 AM   PM User | #2
adaminaudio
New Coder

 
Join Date: Jan 2012
Location: Columbus, Ohio, U.S.A
Posts: 41
Thanks: 0
Thanked 8 Times in 8 Posts
adaminaudio is an unknown quantity at this point
Hi there,

I'm new on this forum but I'll see if I can't help you out with this.

since it is tracing " 1 " just like that, it may be a parse error. The quotes from php could be throwing it off(try single quotes maybe?) Otherwise, you may be able to take the substring of it like this:

var one:String = event.target.data.subString(2,3); //for a quick fix...

I'd start with the quote thing though and work from there. I do apologize though if none of this helps. Regular expressions might work too, but I'm no good at that yet
adaminaudio is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:01 PM.


Advertisement
Log in to turn off these ads.