Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-22-2012, 08:51 PM   PM User | #1
SuperDoD
New to the CF scene

 
Join Date: Apr 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
SuperDoD is an unknown quantity at this point
Sending a matrix from PHP to AS3

Hello!
I have a bit of a problem. I need to send a two dimensional array from PHP to AS3 and save the data in AS3 in a two dimensional array, but I can't find a way. Here is my code:

adatatvitel.php
PHP Code:
<?php

require("db.php");

$sql "SELECT * FROM kerdesvalasz";
$result mysql_query($sql) or die(mysql_error());

$adatok = array
 (
  
"kerdes" => array
  (
  ),
  
"valasz1" => array
  (
  ),
  
"valasz2" => array
  (
  ),
  
"valasz3" => array
  (
  ),
  
"valasz4" => array
  (
  ),
  
"helyes" => array
  (
  )
 );
 
$i=0;
while(
$row mysql_fetch_array($result))
{
  
$adatok['kerdes'][$i] = $row ['kerdes'];
  
$adatok['valasz1'][$i] = $row ['valasz1'];
  
$adatok['valasz2'][$i] = $row ['valasz2'];
  
$adatok['valasz3'][$i] = $row ['valasz3'];
  
$adatok['valasz4'][$i] = $row ['valasz4'];
  
$adatok['helyes'][$i] = $row ['helyes'];
  
$i++;  
}

for(
$i=0;$i<17;$i++)
{
  echo 
"adatok=".$adatok['kerdes'][$i];
  
$temp $_POST['adatok'];
  if(
$temp == $adatok['kerdes'][$i])
  {
  
ob_clean();  //clrscr();
  
}
}

?>
I just want to send the adatok[kerdes][$i] elements of the array first.

AS3:

Code:
stop();

var loader:URLLoader=new URLLoader();
loader.dataFormat=URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE,onComplete)

function sendIt(e:MouseEvent):void
{
var request:URLRequest=new URLRequest("login.php");
request.method=URLRequestMethod.POST;
var vars:URLVariables=new URLVariables();
vars.user=user_txt.text;
request.data=vars;
loader.load(request);
}

function onComplete(e:Event):void
{
var request:URLRequest=new URLRequest("login.php");
request.method=URLRequestMethod.POST;
var loader:URLLoader=URLLoader(e.target);
var vars:URLVariables=new URLVariables(loader.data);
gotoAndStop(2);
uzenet.text=vars.user;
}

login_btn.addEventListener(MouseEvent.CLICK,sendIt);
start_btn.addEventListener(MouseEvent.CLICK,startquiz);

var adatok:Array = [];
var valtozo:String = new String();
var i:int = 0;
var j:int = 0;
var szamlalo:int = 0;

for(i=0;i<17;i++)
{
	adatok[i] = [];
}
i=j=0;

function startquiz(e:MouseEvent):void
{
var request:URLRequest=new URLRequest("adatatvitel.php");
request.method=URLRequestMethod.POST;
var loader:URLLoader=URLLoader(e.target);
while(szamlalo<17)
{
var vars:URLVariables=new URLVariables(loader.data);
adatok[i][j] = vars.adatok;
request.data = vars.adatok;
j++;
szamlalo++;
}
gotoAndStop(3);
}

Last edited by SuperDoD; 04-22-2012 at 08:53 PM..
SuperDoD is offline   Reply With Quote
Old 05-05-2012, 08:34 PM   PM User | #2
Awoken
New to the CF scene

 
Join Date: May 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Awoken is an unknown quantity at this point
well, if there is a way to directly send info from your server side PHP to you client side as3 , which is I assume what you're looking to do, I don't have the info on that. But, if you are using Javascript by any chance on your client side then I know a way to send variables via java to AS3 and AS3 to java. So maybe even if you knew a way to transfer info to java via PHP you could then use Java to send to AS3.

now I don't know what is causing your problem, BUT if your PHP is infact server side coding, then it would make sense that it can't access the AS3, cus it's Client side (I'm assuming this is web developement). So I believe, could be wrong, but I believe only client side script can access AS3

Some further reading.
http://www.hardcode.nl/archives_155/...-viceversa.htm
Awoken is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:16 AM.


Advertisement
Log in to turn off these ads.