I need a little help here getting data from mysql via PHP with AS3.
I’ve change the code a few times
AS3 Code here
function requestData():void {
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("http://www.bestlincs.co.uk/forum/iphone.php");
varSend.method = URLRequestMethod.POST;
varSend.data as String;
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(evt:Event):void{
var urlLoader:URLLoader = evt.target as URLLoader;
var resultData:String = urlLoader.data as String;
if (resultData == "") {
output_txt.text = "No data coming through";
} else {
output_txt.condenseWhite = true;
output_txt.htmlText = "" + resultData;
}
}
urlLoader.load(varSend);
}
requestData();
stop();
PHP code is HERE
<?
include "../lib/forumconnect.php";
$query = mysql_query("SELECT * FROM posts WHERE post_owner='0'");
$body="";
while($row = mysql_fetch_array($query))
{
$body.=$row['post_body']."<br>";
}
echo "returnBody=".strip_tags($body);
echo "returnBody=".strip_tags($body);
mysql_close();
exit();
?>
Now i get the error
Scene 1, Layer ‘Layer 1’, Frame 1, Line 9 1120: Access of undefined property event.
Scene 1, Layer ‘Layer 1’, Frame 1, Line 26 1120: Access of undefined property varLoader.
Please can anyone shed some light on this ???
The error message says it all.
There is no property called
returnBodyinevent.target.data.You should be looking at this instead
So your function becomes something like this: