...

Data sent from PHP file won't store

subclass
11-27-2009, 08:08 PM
Alright, sorry, as this is my first post and I'm relatively new to actionscript, this may seem like a dumb post.

I'll try to describe a bit of what I'm trying to do and afterwards post the code.

I'm making a simple register/login mxml. I'm able to do both of those with php. I have my own local db. The problem is, after I log in I want to grab all the information from the db.

For this I created a class, MemberProfile. As of now, it only grabs two things: username and email. I use the URLrequest, variables, and loader to send the request along with the logged in members userId. The odd thing is that once it goes to my onComplete function, I can see the two variables (I use alert boxes, I know they're sent back); however, when I store them into the class vars and then attempt to view them back in the main mxml file, it only shows as null.

my call to the class

private function buildProfile( loggedUserId:int ):void
{
userProfile = new MemberProfile( loggedUserId );
Alert.show( "Email " + userProfile.email );
Alert.show( "Username " + userProfile.username );
Alert.show( "UserId " + userProfile.userId );
}

The email and username alert box show null while the userid shows the correct id.


public function MemberProfile( userId:int )
{
this._userId = userId;
var request:URLRequest = new URLRequest ("http://localhost/php_code/profile.php");
request.method = URLRequestMethod.POST;

var variables:URLVariables = new URLVariables();
variables.userId = userId;

request.data = variables;

var loader:URLLoader = new URLLoader ();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);
}

private function onComplete ( event:Event ):void
{
var variables:URLVariables = new URLVariables( event.target.data );

var temp:String = variables.username;
this._username = temp;

temp = variables.email;
this._email = temp;

Alert.show( "Setting username and email: " + username + " " + email );
}

In this alert, username and email is my getter functions and they display the correct information.

Any idea how to keep the data?

Inigoesdr
11-28-2009, 04:45 PM
Post your whole class. Or set global variables for your email and username to be stored in.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum