dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Vars dont come back

  1. #1
    Registered User
    Join Date
    Jul 2003
    Location
    USA
    Posts
    16

    Vars dont come back

    My server wont return anything back to my flash movie. I am using:

    on (release)
    {
    loadVariablesNum("foo.php", 0, "POST");
    }


    my php script gets the vars and will output them to a new browser but wont send anything back to me....

    Any suggestions?

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    What did you write in the php to send anything back to Flash then?

    Where is your Flash code? Main timeline? Thats what your code suggests. Do you have a textfield to display what you get back?
    You have to be more detailed.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Registered User
    Join Date
    Jul 2003
    Location
    USA
    Posts
    16
    Thanks for the reply,

    On the main timeline i have set up a var as follows:
    var connection_flag;
    connection_flag = 'loop';

    My php code is as follows:
    <?php

    if( validate_user( $user = $_POST['user'], $pass = $_POST['pass'] ) )
    {
    echo "&connection_flag=pass";
    }
    else
    {
    echo "&connection_flag=fail";
    }

    function validate_user( $user, $pass )
    {
    $users = array('levi' => 'neptune');
    if (isset($users[$user]) && ($users[$user] == $pass))
    {
    return true;
    }
    else
    {
    return false;
    }
    }


    ?>

    The code is attached to a button inside a movie which, is on the main timeline. I have it set up so the main time line loops after the user enters a user and pass and sends the vars by hitting the button inside the movie:
    on (release) {
    loadVariablesNum("http://161.28.112.222/Labtech/wake_up.php", 0, "POST");
    }

    at the end of the loop on the main time line i have the following test:
    if( connection_flag == 'fail' )
    {
    gotoAndPlay(1);
    }
    if( connection_flag == 'loop' )
    {
    gotoAndPlay(1);
    }
    if( connection_flag == 'pass' )
    {
    gotoAndStop(10);
    }

    I hope this explains what I have so far. If there is a better way to do this let me know.

    Thank a ton, I am really stuck.

  4. #4
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Im no good with php unfortunately so I cant see anything obviously wrong with the php code.

    I guess you have input fields in the Flash file with variable names pass and user? ( I have made mistakes like giving the instance names ).

    You could try haveing the submit button in the main timeline ( but I would think it would send the variables in the main timeline anyway).

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  5. #5
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Note the swf has to be on the same server as the php to my knowledge. ( although it would probably work locally ).

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  6. #6
    Registered User
    Join Date
    Jul 2003
    Location
    USA
    Posts
    16
    Thanks pellepiano,

    I wanted to run it from an exe, is there a way to pass vars back and forth in an exe or is this just a limitation of flash?

    I have tested my php with just html and a browser so I think that is working, also I tried moving the submit to the main time line as well.

    Is there a better way to pass vars back and forth from a server without looping the main timeline, I know with other socket programming there is usually a func that will just sit and wait for data back from the server, does flash have somthing like that?

    (I am trying to connect to an SQL database)

    thanks again for your suggestions

  7. #7
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    I always use a short frameloop to to get the confirmation.
    In MX there are new eays to check if vars are loaded but Im not updated on that. Also onClipEvent(data) on a movieclip will function as a sort of preloader for loaded variables, but its a hassle to load them into a movieclip ( imo ).

    I dont know what you mean by "pass vars back and forth in an exe".
    A exe could talk to the php on the server and read what it gets back if thats what you mean. Your code should work as good (bad =) ) as a swf on the server.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center