Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Thanked 0 Times in 0 Posts

    Data sent from PHP file won't store

    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;
    		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?

  2. #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Florida, USA
    Thanked 406 Times in 398 Posts
    Post your whole class. Or set global variables for your email and username to be stored in.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts