#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    4
    Rep Power
    0

    Flash not reading dynamic content


    Hi,
    I'm new to loading dynamic content, so i made a test file.
    I've given a dynamic textfield the variable name "msg" and converted it into a movieclip symbol. This is all there is on the stage.
    Attached to this movieclip is the following action:

    onClipEvent (load) {
    LoadVariables ("message.txt",this);
    }

    In the same directory where the published .swf resides i have a textfile called message.txt, and it's contents shows up perfecty in this .swf

    BUT:
    Now i want to load data from MySQL via PHP, instead of loading it from the textfile, so in the actionscript I change the .txt extension into .php (the name of the PHP-file is also "message") This php-file resides in the same directory as the textfile, and register_globals is on in my php.ini file. Still my .swf does not show anything! Why???
    When i check the file "message.php" in my webbrowser it perfectly retrieves the data from my (local)database, showing:
    msg=Contents+from+database. So that seems to work. But flash does'nt show anything.

    This is the message.php file i'm using:
    <title>Uit No Hands/DevShed</title><?
    // message.php

    // open connection to database
    $connection = mysql_connect("localhost", "root", "rolf") or die
    ("Unable to connect!");
    mysql_select_db("rolf") or die ("Unable to select database!");

    // formulate and execute query
    $query = "SELECT testveld FROM test";
    $result = mysql_query($query) or die("Error in query: " .
    mysql_error());

    // get row
    $row = mysql_fetch_object($result);

    // print output as form-encoded data
    echo "msg=" . urlencode($row->testveld);

    // close connection
    mysql_close($connection);
    ?>



    Hope someone can help!

    Rolf
  2. #2
  3. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    7
    Rep Power
    0
    Well, when you don't know what's going on try to debug. First of all you can try this: run the swf from authorung tool (changing the loadvars url to "http://localhost/.../message.php" otherwise it won't work) and then check the variable list. If the output of the php is present somewhere then it's a targetting problem, otherwise there are chances that flash can't reach the php.

    Ciao,
    *M
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    4
    Rep Power
    0

    Your answer


    Hi M,

    In the variables list i see only the code contained in the .php file. There is no sign of what should be the database output .
    What i also do not understand is where the second instance(2) comes from, since i made only one instance: the MC with the dynamic textfield in it.
    elow is the variables list output:
    Level #0:
    Variable _level0.$version = "MAC 6,0,50,0"
    Movie Clip: Target="_level0.instance1"
    Variable _level0.instance1.<title>Uit No Hands/DevShed</title><?
    // message.php

    // open connection to database
    $connection = " mysql_connect(\"localhost\", \"root\", \"rolf\") or die\r(\"Unable to connect!\");\rmysql_select_db(\"rolf\") or die (\"Unable to select database!\");\r\r// formulate and execute query\r$query = \"SELECT testveld FROM test\";\r$result = mysql_query($query) or die(\"Error in query: \" .\rmysql_error());\r\r// get row\r$row = mysql_fetch_object($result);\r\r// print output as form-encoded data\recho \"msg=\" . urlencode($row->testveld); \r\r// close connection\rmysql_close($connection);\r?> "
    Edit Text: Target="_level0.instance1.instance2"
    variable = "msg",
    text = ,
    htmlText = ,
    html = false, textWidth = 0, textHeight = 0, maxChars = null,
    borderColor = 0x000000, backgroundColor = 0xFFFFFF, textColor = 0x000000, border = true,
    background = true, wordWrap = true, password = false, multiline = true,
    selectable = false, scroll = 1, hscroll = 0, maxscroll = 1,
    maxhscroll = 0, bottomScroll = 1,
    type = "dynamic",
    embedFonts = false, restrict = null, length = 0, tabIndex = undefined,
    autoSize = "none",
    condenseWhite = false


    How do i solve this?

    Rolf
  6. #4
  7. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    7
    Rep Power
    0
    When loading data from a text file you are actually reading it. There's no processing, you just open it and read it as is. This is what's wrong with your PHP file. You're simply reading it. There's no web Server (e.g. Apache) to process the php and send the data to you.
    Since you're working in authoring environment (Ctrl+Enter from FlashMX) what you should do next is to "call" LoadVars using an absolute path like "http://localhost/yourProject/phpfile.php". Doing this will likely fix the problem. Instead of php source code you'll be loading web server output (echo "...") processed as you programmed.

    Cheers,
    *M

IMN logo majestic logo threadwatch logo seochat tools logo