Haxe Forum > Send,receive AS2 and php

  • I am a student.I am making a game for charity.I was looking for a swf compiler tool.I found swfdotnet, Activeswf, ....ActiveSwf is great.It allows me to use script file(.as).It has source C#.After compiling, I get a logo appear in the flash file.Thank you so much because you give me a free tool.I have read the instructions of the flash cs3 for sending and receiving between php and swf.Its using LoadVar
    Example:

    var php_process:LoadVars = new LoadVars();
    var myVars: LoadVars = new LoadVars();    
    myVars.uname = tuser.text;
    myVars.passw = tpass.text;
    //Send to php
    myVars.sendAndLoad("http://.../Read.php",php_process,"POST");

    To receive:
    myVars.load("http://.../Read.php");
    // once vars have been loaded, we will have these variables:
    txt.text=parseInt(php_process.alpha);
    

    How do I send and receive between php and swf?

  • I suggest you work through these tutorials, and after come back with any remaining questions.
    http://haxe.org/doc/remoting
    Don't get too bogged down in which targets your remoting between, just try to get the concepts down and the rest will hopefully fall into place ( neko and php are very similar for instance in terms of api ). You can use sendAndLoad but try remoting first it's more powerful and intuitive the way haxe sets it up.

  • Main.hx:

    class Main
    {
        public function new()
        {
            var lv = new flash.LoadVars();
            lv.nr1 = "10";
            lv.nr2 = "20";
            lv.sendAndLoad("test.php", lv);
            
            lv.onLoad=function(success:Bool)
            {
                if(success)
                    trace(lv.sum);//30
                else
                    trace("error occurred");
            }
        }
        
        public static function main()
        {
            flash.Lib.current.addChild(new Main());
        }
    }

    build.hxml:
    -main Main
    -swf index.swf
    -swf-version 8
    -swf-header 1024:768:30:FFFFFF

    test.php:
    <?php
    $nr1 = $_POST["nr1"];
    $nr2 = $_POST["nr2"];
    $sum = $nr1 + $nr2;
    echo "sum=$sum";
    ?>

    Jan

  • I get:error occured.I think the problem is to configure the swf file.I just click run button to run in adobe.How do I do this with haXe?

  • Add -D network-sandbox to your build.hxml file or test the swf online/from a server.
    Please try to specify the error next time, because now we can only guess what a solution might be. ;)
    (The network sandbox restriction is disabled when you test from the Flash IDE by the way, just as a convenience for developers)

    Jan

  • Oh, I see the error message 'error occurred' is the one from the script/example, but still, tell a bit more about your setup or how you are testing this.

    Cheers,

    Jan

  • I'm trying local.I use xampp.When I use adobe, I just press Ctrl + Enter and run "localhost \ test.php" on firefox.I'll get value from php.

  • Oh,when I add -D network sandbox and copy swf file to folder htdocs of xampp,I get Main.hx12:undefined

  • And this is the way when I run it on the server.Amazing.Thank you so much

< Prev | Page 1 / 1 | Next >