Unfortunately it's usually not that easy as I just found out.
It depends on what you are trying to do. If you are just trying to get some information back and forth between Flash and PHP then you can user loadVariablesNum if you are more comfortable with it, but what I have found out is that the information received can only be reliably received without a loading sequence if it is placed in a text field. The code for this would be:
Code:
loadVariablesNum("mypage.php", 0);
and then in php you could have something like:
Code:
<?
$message = "&message=blah blah blah";
echo $message;
?>
you must use the &message= part because this is how Flash reads variables. By setting the textfield varaible to message, once "message" is received in full from PHP, it will be automatically placed in the text field.
Otherwise, if you need to know when it is loaded before doing something, use the following code:
Code:
<?
$message = "&message=blah blah blah";
echo $message;
?>
Code:
stop();
myVars = new LoadVars();
myVars.load("test.php");
myVars.onLoad = function(success)
{
if(success)
{
trace(this.message);
trace(this.getBytesTotal());
trace(this.getBytesLoaded());
message.text = this.message;
}
else
{
trace("error.");
}
}
the benefit of making a LoadVars Object is that you have access to a lot of methods such as getBytesTotal/Loaded in order to see if it's done as well as onData and onLoad. Only problem is that it takes a while to get a grasp on it and become comfortable with LoadVars instead of loadVariablesNum.