Passing variable FROM flash to HTML/php

后端 未结 2 1445
情深已故
情深已故 2021-01-17 01:54

I was hoping maybe someone could provide some insight on a problem I\'m having a tough time deciding how to solve.

I have a rather simple flash application users can

2条回答
  •  情话喂你
    2021-01-17 02:36

    You want to use a combination of URLRequest, URLVariables and URLLoader to do this. See the below.

    var myData:URLRequest = new URLRequest("some.php");
    myData.method = URLRequestMethod.POST;
    
    var variables:URLVariables = new URLVariables();
    variables.username = 'CREATED USERNAME';
    
    myData.data = variables;
    
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, dataOnLoad);
    loader.load(myData);
    
    function dataOnLoad(evt:Event){
        trace('Completed');
    }
    

    This would then call the 'some.php' file with your username stored in '$_POST['username']'. Your php script can then make an impression on the db linking that username to that session (however you want to do that).

提交回复
热议问题