
For the accomplishment of the associated .SWF” movie, graphics and scripting
were merged together. First the schematic was designed and then edit boxes were
added (Fig.5a).
Our movie-interface is structured in a single scene, 2 layers and 4 frames.
The first layer serves for actions (programming), and the second one for graphics. In
the first frame the initialization is made; the second frame contains the input part of
the application; in the 3rd frame are checked and enabled the data that were input in
frame 2; the 4th frame contains the outputs (in this part are displayed the results of the
simulation – see fig.5b and 5c).
The Functions Used for the Implementation are:
LoadVariablesNum ("http://vlab.unitbv.ro/VELab/op3/op3.php", 0, "POST"); that
sends variables form level 0 of the movie, using POST method, to op3.php file
LoadVariablesNum ("http://vlab.unitbv.ro/VELab/op3/op3_val.txt", 0); that reads
data from an external file (op3_val.txt), assembled by the VI (fig.6) and sets the
values for variables in movie. In the file 'op3_val.txt' the variables must be defined
like variable name=value and separated with '&'. The variable name from the external
file must be the same with the variable name inside the movie.
GetURL("http://vlab.unitbv.ro/VELab/op3/op3.out", "_blank"); that loads a document
from a specific URL into a window. This function is used in order to view 'op3.out',
'op31.jpg', 'op32.jpg' and 'op33.jpg' files.
gotoAndPlay(4); that sends the play head to the frame 4 and plays from that frame
gotoAndStop(4) ; that sends the play head to the frame 4 and stops it
stop(); that stops the movie currently playing
In order to create the 'values.txt' file we have used the server side scripting
language PHP (provided for free). The FLASH function loadVariablesNum
("http://vlab.unitbv.ro/VELab/op3/op3.php", 0, "POST") calls the op3.php file and
passes to it, through POST method, all the variables from the movie level 0.
"op3.php" has the role to over-take these variables and to write them, according to a
preset format, in the values.txt file.
Here it is the commented op3.php listing:
<?php
//gets all variables from swf file
$vin = $HTTP_POST_VARS['vin'];
$r1 = $HTTP_POST_VARS['r1'];
$r2 = $HTTP_POST_VARS['r2'];
$r3 = $HTTP_POST_VARS['r3'];
$r4 = $HTTP_POST_VARS['r4'];
$v1 = $HTTP_POST_VARS['v1'];
$v2 = $HTTP_POST_VARS['v2'];
//create and open the output file
$filename="./values.txt";
if (!file_exists($filename)) {
touch($filename);
// Create blank file
chmod($filename,0666);
}
$f=fopen($filename,"w");
//writes input values in the file
//"values.txt"
fputs($f,"R1:".$r1."\n");
fputs($f,"R2:".$r2."\n");
fputs($f,"R3:".$r3."\n");
fputs($f,"R4:".$r4."\n");
fputs($f,"V1:".$v1."\n");
fputs($f,"V2:".$v2."\n");
fputs($f,"VIN:".$vin."\n");
fclose($f);
?>
47