Click to See Complete Forum and Search --> : pass variable from php into flash, help please


conga
08-29-2009, 10:38 PM
Here are what I'm having:

<?PHP

$testVal = "This is a test";

$test = urlencode($testVal);

$out = "test=". $testVal;
echo $out;

?>

// and this is my flash file
function getData() {

// Prepare request

var urlReq:URLRequest=new URLRequest("http://localhost/test.php");
urlReq.method=URLRequestMethod.GET;

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

}

function completeHandler(evt:Event) {

var vars:URLVariables = URLVariables(evt.target.data);
trace(" TEST = ", vars.test);
trace(" TEST = ", unescape(vars.toString()));
}

// and below is the ouput
TEST = undefined
TEST = test=This is a test

/////////////////////////////////////

I've tried with several different ways to get ONLY the value of the variable - that means I only want to have "This is a test" returned, but I either got "undefined" or the whole thing "test=This is a test".

Please help. I'm totally new to PHP and FLASH (CS4).

Thanks