A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Flash and MySQL

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    11

    Flash and MySQL

    Hello guys.
    Question:
    I have transfer data form flash to MySQL and again to flash as soon as it possible:
    Flash(text1 field)->MySQL (save "text1" in the database field "text" and return to flash as text2. We read this again from "text" field of database)->Flash
    P.S. text1 and text2 field in the _root.charactermovie of cause.

    Here is a flash-script for _root.charactermovie:
    onClipEvent (enterFrame) {
    loadVariables("text.php", "_root.charactermovie", "POST");
    }

    enterFrame event to cycle event of cause.

    Php-script:
    <?php
    require( "function.php" );
    $dbLink = mysql_connect( $dbHost, $dbUser, $dbPass );
    dbConnect();
    mysql_query( "UPDATE text SET text='$text1' where id = 1;" );
    $result = mysql_query( "SELECT text FROM text where id='1'" );
    $row = mysql_fetch_array( $result );
    $text2=$row['text'];
    echo "text2=".$text2;
    ?>

    All is working, but... with such slow speed...it’s refresh in 1 sec or even worth.
    Is there flash problem or is there mistake in my head? :-)

    Regards,
    Alex

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

    while you are reading flashkit, just measure the time it takes a loaded server to, e.g., follow a "next thread" link - this will be seconds.
    Now, with the enterframe approach, you are creating one request to the server per frame, even if you do not need that many chnges. If this happens on a public server, nd a few people do the same, it will soon be as loaded as the fk forum

    Unless your setup can work with a reasonable refresh rate (e.g. 2 seconds after result from previous call), you should start investigating about socket servers. In order to achieve the timing mentioned, you would probably use an onclipevent(data) storing the gettimer() into a variable, nd the onclipevent(enterframe) comparing that variable to gettimer()

    Musicman

  3. #3
    proud new daddy! LuxFX's Avatar
    Join Date
    May 2000
    Location
    Dunsinane
    Posts
    1,148
    Although it should also be noted that even socket servers aren't all that fast. Flash doesn't necessarily send data right after you tell it to. The manual says:
    The send operation is asynchronous; it returns immediately, but the data may be transmitted at a later time.


    Not exactly encouraging.
    For War's a banker, flesh his gold. There by the furnace of Troy's field, Where thrust meets thrust, he sits to hold His scale, and watch the spear-point sway; And back to waiting homes he sends Slag from the ore, a little dust To drain hot tears from hearts of friends

    - Aeschylus, Agamemnon

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