PDA

View Full Version : problem in passing variables beween flash cs5 and php


kareem_3d
12-04-2010, 01:30 PM
i am having an issue passing variables between flash cs5 and php ,, this issue didn't exist in flash cs3 ,even i used the same code that worked before in flash cs3 and still not working with flash cs5 :confused:

here is a simple example :

in as3 :

var variables:URLVariables = new URLVariables();

// PassingVariables.php and my swf file are in the same folder
var request:URLRequest = new URLRequest("PassingVariables.php");
request.method = URLRequestMethod.POST;
request.data = variables;

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

variables.status = "GetInfo";

loader.load(request);

function Loaded(e:Event):void
{
// username_txt is a textfield in my stage
var variables1:URLVariables = new URLVariables(e.currentTarget.data);
username_txt.text = "" + variables1.username;
}

in php "PassingVariables.php" :

<?php

if($_POST['status'] == "GetInfo")
{
print "username=kareem";
}

?>

the output in the username_txt is "undefined" !!!!

Ninetynine
12-07-2010, 02:41 PM
This is a quick guess, try putting an ampersand for username so :


echo "&username=kareem";