Jump to content

AS3 variable sent to php via .call()


NLCGraphics

Recommended Posts

Can anyone tell me how I would get my variable from actionscript 3 to a php class?

 

I have my made my connection in AS3 using

var nc:netConnection = new netConnection;
nc.call(""People.thePeople", res);

 

then in my People Class i have a method .thePeople which I want to access it in but don't know how.. can someone tell if I use it like normal post data like

 

$myActionVar=$_POST['myvar'];

 

 

Here is my AS3 code:

 

import flash.net.NetConnection;
import flash.net.Responder;

var nc:NetConnection = new NetConnection();
// connect to bootstrap index.php file
nc.connect("http://localhost:8888/index.php");


var myvar:String = "this is myvar";
var res:Responder = new Responder(myResult, onError);


nc.call("People.thePeople", [res, myvar]);

function myResult(e:Object):void{
for(var i=0;i<e.length;i++){
	trace(e[i].id+' '+e[i].first+' '+e[i].last);
}
}

function onError(e:Object):void{
trace(e);
}

 

 

and here is my PHP class

 

<?php


class People
{
public function __construct(){
	mysql_connect("localhost:8889", "root", "root");
	mysql_select_db("firstdb");
}

public function thePeople()
{
[b]$myvar = $_POST['myvar'];[/b]
	$myresult = mysql_query("SELECT * FROM firstDb");
	$t = array();

while($row = mysql_fetch_assoc($myresult))
	{
	array_push($t, $row);	

	}

return $t;
}
}

 

Link to comment
https://forums.phpfreaks.com/topic/174847-as3-variable-sent-to-php-via-call/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.