Jump to content

AS3 variable sent to php via .call()


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.