开发者

flash, actionscript - the post request from a flash file stops working after published

Good day to all. I have a problem with the following code:

textBox.addEventListener(KeyboardEvent.KEY_DOWN,handler);
   function handler(event:KeyboardEvent){

   // if the key is ENTER
   if(event.charCode == 13){

    var url:String = "http://localhost/flashsave.php";
    var request:URLRequest = new URLRequest(url);

    var variables:URLVariables = new URLVariables();

    variables.cuvant = textBox.text;

    request.data = variables;开发者_开发问答
    request.method = URLRequestMethod.POST;

    navigateToURL(request);
    var loader:URLLoader = new URLLoader();

    try {
        loader.load(request);
    } catch (error:Error) {
        //trace("Unable to load requested document.");
    }

The problem is that the code is working when I test the scene (ctr+alt+enter in flash), but after I publish it it doesn't work... not sending any request nor redirect.

What I want to do is to log in a file on the server what the users typed (related with Related with: Flash actionscript - save a text file on server).

Thank you for help.


I believe that have a static link to the localhost like that is your problem. Try having your swf in one directory and the php in the same directory or in a subdirectory.

if the php is in the same directory its url would be:

"flashsave.php"

Else if it is in a subdirectory it would be:

"php/flashsave.php"

do not include a forward slash at the start of the link as it will reference the C:// drive :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜