Results 1 to 7 of 7

Thread: flash php basics with loadvars

  1. #1
    Join Date
    Jan 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default flash php basics with loadvars

    I'm using loadvars to get and retrieve data from flash to php.

    I need some help in how can i call php functions from flash normally and with parameters.

  2. #2
    Join Date
    Jan 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    To be more specific, i would like to know how the comunication works.

    I know how flash retrive vars from php, but how php retrive data from flash?

    I have this example:

    var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
    if (success) {
    aleatorio.text = result_lv.rand;
    } else {
    aleatorio.text = "Error connecting to server.";
    }
    };
    var send_lv:LoadVars = new LoadVars();
    send_lv.name = input_al.text;
    send_lv.sendAndLoad("http://localhost/vinhos/test.php", result_lv, "GET");

    I have a button, that when i click, it gets from php a random number. This works fine.

    In fllsh i have an input box instance "input_al". If i put a number it sends it to php but it is not working.

    In php i'm getting the flash var this way: $_GET['input_al']

    This is just an example for me to know how this work.

    Can anyone help me?

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Check Out what it won't work with

    And then follow this tutorial for how it is done with php files

    Hope it helps!
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Jan 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Has i see there is no problem in my case. The output is a standalone player, and it wont play in a browser. The operating system is a MAC OSX 10.4, which is not refered in the "won't work" list.

    I've tryed just doing it only with php and it worked. The problem is how php receive the vars from flash.

    I've tryed this ways:
    the object of Loadvars calls send_lv and the var i want to send calls input_aleatorio.
    I have:
    send_lv.input_aleatorio = 5;
    send_lv.sendAndLoad("http://localhost/vinhos/test.php", result_lv, "POST");


    In php i tryed:
    $tab = $HTTP_POST_VARS['input_aleatorio'];
    $tab = $_POST['input_aleatorio'];

    None of this worked

  5. #5
    Join Date
    Jan 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It's working with this:

    $tab = $_POST['input_aleatorio'];

    Thanks

  6. #6
    Join Date
    Jan 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i have another question. How can i call a php function from flash?

    For example:


    i have in php

    function some_name(){
    echo "success";
    }

    What should i have i flash? And if i want to send arguments from flash to php function?

    I haven't found yet an example for this and it is very important.

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You can try with the $_GET var inside flash with all references pointing to the file in question.

    You can also try variations of the load() vars or encapsulate the sting in it's own page using <?php include(); ?> and call that page...

    Not sure exactly wqhat you are after though.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •