Hello, I read over the old post by Jabber, about sending variables from Flash -> PHP -> Flash but I can’t seem to get it right. I have a series of input boxes which take values and then send it to a PHP script. The PHP script compiles the values and writes a .CKT file. Then I am trying to read this file into a string and send it back to Flash into a dynamic text field named “retVar”. When I test the .swf, the dynamic text field is just always left blank. Any help would be greatly appreciated. Here is my code…
flash code…
submit_btn.onRelease = function( )
{
var loginVars:LoadVars = new LoadVars();
loginVars.c1 = parseInt( c1.text );
loginVars.c2 = parseInt( c2.text );
loginVars.c3 = parseInt( c3.text );
loginVars.l1 = parseInt( l1.text );
loginVars.l2 = parseInt( l2.text );
loginVars.l3 = parseInt( l3.text );
loginVars.r1 = parseInt( r1.text );
loginVars.r2 = parseInt( r2.text );
loginVars.r3 = parseInt( r3.text );
loginVars.sendAndLoad( "triple_rlc.php", loginVars, "POST" );
};
php code…
<?php
//File being written to
$filename = "triple_rlc_result.CKT";
//Footer file to place at end of file
$footer = "footer.txt";
//Simultation file
$simul = "simul.txt";
//Path to Micro cap
$mcpath = "../";
//Get capacitors
$c1 = $_POST['c1'];
$c2 = $_POST['c2'];
$c3 = $_POST['c3'];
//Get Inductors
$l1 = $_POST['l1'];
$l2 = $_POST['l2'];
$l3 = $_POST['l3'];
//Get Resistors
$r1 = $_POST['r1'];
$r2 = $_POST['r2'];
$r3 = $_POST['r3'];
//Open file
$fi = fopen( $filename, 'w' ) or die( "Unable to open file." );
//Write title
$string = "*Writing to the filename, " . $filename . "
";
fwrite( $fi, $string );
//Write capacitors
$string = "C1 5 0 " . $c1 . "P
";
fwrite( $fi, $string );
$string = "C2 6 0 " . $c2 . "P
";
fwrite( $fi, $string );
$string = "C3 7 0 " . $c3 . "P
";
fwrite( $fi, $string );
//Write Inductors
$string = "L1 2 5 " . $l1 . "N
";
fwrite( $fi, $string );
$string = "L2 3 6 " . $l2 . "N
";
fwrite( $fi, $string );
$string = "L3 4 7 " . $l3 . "N
";
fwrite( $fi, $string );
//Write Resistors
$string = "R1 1 0 1M
";
fwrite( $fi, $string );
$string = "R2 1 2 " . $r1 . "
";
fwrite( $fi, $string );
$string = "R3 1 3 " . $r2 . "
";
fwrite( $fi, $string );
$string = "R4 1 4 " . $r3 . "
";
fwrite( $fi, $string );
//Write finished
$string = "*Variables finished writing
";
fwrite( $fi, $string );
//Open footer
$fa = fopen( $footer, 'r' ) or die( "Unable to open footer file." );
$contents = fread( $fa, filesize( $footer ) );
//Write footer
fwrite( $fi, $contents );
//Close footer
fclose( $fa );
//Close file
fclose( $fi );
//Read entire output file
$return = fopen( $filename, 'r' ) or die( "Unable to open return file." );
//Return outputfile to dynamic text box.
print "retVar=" . $return;
?>
I’m sorta new to send vars back and forth, but I have been working with PHP and Flash off and on for 4-5 years now. Thanks ahead of time.