Passing Variables From PHP to Flash MX

Hi,

Being a novice user of PHP and Flash I have no idea about where I am going wrong! :-/

I want to pass a PHP variable to load in a dynamic movie clip.

E.g I want to pass a user name from a postgress database to appear in the .swf file when loaded.

My PHP code is:
// ($myrowUN[0]) being the result of my query

$sendUserName = $myrowUN[0];
echo “&sendUserName=$sendUserName”;

My ActionScript code is:
// Placed in the movieclip

onClipEvent (load) {
GetUserName = new LoadVars();
GetUserName = function(success){
if(success){
this.sendUserName
}
else {
trace(“Sorry, Error logging your New Password”);
}
}
GetUserName.load(“Newpassword2.php”);
}

Any help would be much appreciated!

Try this :slight_smile:


onClipEvent (load) {
	GetUserName = new LoadVars();
	GetUserName.onLoad = function (success) {
		if (success) {
			trace(this.sendUserName);
		} else {
			trace("Sorry, Error logging your New Password");
		}
	};
	GetUserName.load("Newpassword2.php");
}


Voetsjoeba,

Thanks for the quick reply!

I tried that code but it didn’t work :-(!!!

Boooooo!

I’m positive that I am nearly there now though!!!..

Worked for me … can you show me your files ?

Messed around with the code a little more yesterday and seem to have got it working with the following code:

PHP:
$sendUserName = $myrowUN[0];
echo “&sendUserName=”.$sendUserName;

Actionscript:
GetUserName = new LoadVars();
GetUserName.onLoad = function (success){
if (success){
UN = this.sendUserName;
}
else{
trace(“wrong”);
}
}
GetUserName.load(“NewPassword2.php”);

Thank’s a lot for your help - much appreciated!

Anytime :slight_smile: