A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: more problems loading variables from php > flash

  1. #1
    Member
    Join Date
    Jun 2002
    Posts
    45
    right, i can't see why this isn't working. I have looked throught many of the old "php to flash variable" posts but still mine does not work.

    i have a swf with a dynamic txt field who's variable is named "output"

    i have action in the first frame of this .swf which is this:
    loadVariablesNum("test.php", 0, "POST");

    The test.php script has the following code

    <?php

    $number = "2398986869";
    echo "output=".$number;

    ?>


    I have tried it many different eways still i get an empty output box?

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    I once managed to select the background color as text color ...
    What happens if you call the php script from the browser?

    Musicman

  3. #3
    Member
    Join Date
    Jun 2002
    Posts
    45
    how do i do that?

    rufis,

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    if the files are on a server, you would normally type something like http://www.yoursite.com/test.html to view the movie (inside its html environment). Now just type http://www.yoursite.com/test.php instead
    If you are testing on your own computer, it would be something like http://localhost/flashtests/test.html and the php would be at http://localhost/flashtests/test.php
    If this is all greek to you, you are probably testing the movie from within flash and have copied the php file to the same directory - this will not work even if php is installed correctly on your machine.

    Musicman

  5. #5
    Member
    Join Date
    Jun 2002
    Posts
    45

    http://www.orchid.f2o.org/php_test/flash/test.php
    http://www.orchid.f2o.org/php_test/flash/test.swf

    Now when going to the php page in the browser it returns "2" which is correct.

    the php code is:

    ---------------------------------------------------------------------------------
    <?php

    include "dbConnect.php";

    $collection = "1";

    $sql = "SELECT *
    FROM pots p, collection c
    WHERE p.collection = c.collectionID
    AND $collection = c.collectionID ";

    $result = mysql_query($sql);

    $num_rows = mysql_num_rows($result);

    echo "number=" . $num_rows;

    ?>
    --------------------------------------------------------------------------------



    Actionscript on the first frame of the swf:

    ---------------------------------------------------------------------------------

    loadVariablesNum("test.php", 0, "POST");
    _root.output = number;

    ---------------------------------------------------------------------------------


    for some reason in the swf's dynamic text box (_root.output) it has "type funciton"

    It may be better to just put echo "_root.output=$number" but i actually want to use the varibles without outputting it later, it's just to test now.



    [Edited by rufisdickler on 09-07-2002 at 08:17 PM]

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    in flash you are trying to use the "number" variable the very moment it is requested. Depending on the speed of the server, the variable will be defined only a few seconds later.
    One way to handle the situation:
    frame 1:
    loadvariablesnum(....)
    num = ""
    frame 2 - no code
    frame 3:
    if(number == "") prevFrame();
    frame 4:
    _root.output = num;
    stop();
    You can use frames 2 and 3 for a nice animation "server busy" if you want
    I am using "num" here rather than "number" because it seems to confuse it with the Number() function

    Musicman

  7. #7
    Member
    Join Date
    Jun 2002
    Posts
    45

    that makes sense. I'll give it a go.


    Thanks :-]

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