SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 1999
    Location
    Southampton, Hants, UK
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sending Vars via POST using flash

    Code:
    input_submitbutton.onRelease=function(){
    
    	sendmessage = new LoadVars();
    	sendmessage.sbn = input_name.text;
    	sendmessage.sbm = input_message.text;
    	sendmessage.send("/post.php","","POST");
    
    }
    the post.php script appends the data onto the end of a text file which is loaded into the flash movie that you are currently in.

    1) all is well and good - the browser goes of to the post.php page, is there anyway of stopping this though - ideally the vars would be send off to the post.php page - you would still stay at page currently on with the flash movie - and the movie would just restart, is this possible.

    2) it always seems to take a while to load the data into the flash movie - or something like that, I usually have to close the browser and re-open it to have the data updated in the flash movie.

    the php code is below is you want it:

    Code:
    <?php
    
    $sbn = $_POST['sbn'];
    $sbm = $_POST['sbm'];
    
    $file_filename = "scratchbox.txt";
    $file_content = "";
    
    $fp = fopen($file_filename, "r");
    $file_content = fread($fp, filesize($file_filename));
    fclose($fp);
    
    $file_content = str_replace("scratchbox_messages=","",$file_content);
    $file_content = "scratchbox_messages=<font face='verdana' color='#FFFFFF' size='10'>" . date("d/m/y") . "<b> - " . $sbn . " - </b>" . $sbm . "</font><br>" . $file_content;
    
    $fp = fopen($file_filename, "w");
    fwrite($fp, $file_content);
    fclose($fp);
    
    header('Location: /');
    
    ?>

  2. #2
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Mexico City
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Daniel, I´ve reading your scripts and it looks you´re an expert, I need a menu like the one that appears in http://www.dimsa.co.cr/flash/index.htm
    it follows the cursor slowly, when you click, it stopped and you can choose one option, please if you know how to do this, send me a message or write me to novelnumen@yahoo.com

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use sendAndLoad()
    Code:
    input_submitbutton.onRelease=function(){ 
    sendmessage = new LoadVars(); 
    retVars = new LoadVars();
    sendmessage.sbn = input_name.text; 
    sendmessage.sbm = input_message.text; 
    sendmessage.sendAndLoad("/post.php",retVars,"POST" );
    retVars.onLoad = function() {
    //This is where you could receive data echo ed back to the flash movie from the PHP script.
    }
    }
    PHP Code:
    <?php
    $sbn 
    $_POST['sbn'];
    $sbm $_POST['sbm'];

    $file_filename "scratchbox.txt";
    $file_content "";
    $fp fopen($file_filename"r" );
    $file_content fread($fpfilesize($file_filename));
    fclose($fp);

    $file_content str_replace("scratchbox_messages=","",$file_content);
    $file_content "scratchbox_messages=<font face='verdana' color='#FFFFFF' size='10'>" date("d/m/y" ) . "<b> - " $sbn " - </b>" $sbm "</font><br>" $file_content;

    $fp fopen($file_filename"w" );
    fwrite($fp$file_content);
    fclose($fp);

    //Something to send back the latest data from the text file
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •