Importing Variables from PHP 4 into Flash

Posted by Glenn on Stack Overflow See other posts from Stack Overflow or by Glenn
Published on 2010-06-09T09:02:54Z Indexed on 2010/06/09 9:42 UTC
Read the original article Hit count: 431

Filed under:

I'm trying to get variable importing from a PHP script before I implement it into a larger project. So far all I've gotten is headaches.

//this is all thats in test.php other than the open and close brackets. Normally I'd have it doing a mysql_query and putting useful information into the print statement.
print( "");

All has to do is access the three variables. The problem comes in that 'val' is undefined. The id and name variables however are just fine and return 0000 and Glenn respectively.

package {

import flash.display.MovieClip;
import flash.text.TextField;

public class test extends MovieClip
    public function test() 
        //prep request
        var request:URLRequest = new URLRequest("test.php");
        request.method = URLRequestMethod.GET;

        var loader:URLLoader = new URLLoader();

        //load request
        loader.dataFormat = URLLoaderDataFormat.VARIABLES;
        loader.addEventListener(Event.COMPLETE, dataLoaded);

    public function dataLoaded(e:Event):void
        var name =;
        var id =;
        var val =;
        trace("Val: " + val + "ID: " + id + " Name: " + name);


© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about php4