Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 02:12
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  PHP, Perl, ASP, JSP, CFM (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis, nothingGrinder)
| | |-+  Newbie totaly at loss
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Newbie totaly at loss  (Read 2337 times)
mmp770
Server what's that
*
Posts: 24



View Profile WWW Email
« on: 01/29/02, 02:23 »

Hi,

I'm writing my first script that interacts with Flash. I'm testing this whole concept with a simple Flash movie that receives from a Perl script an array of first names and last names. The data is contained in a text file called things.txt.

The Flash movie has three parts. In the first one I execute the following ACtionScripit from a frame in the main timeline

---------------------<code>
done = 0;
loadVariables ("things.cgi", "_root");
gotoAndPlay ("loop");
---------------------</code>

Four frames after the "loop" label, in the main timeline, I have the following

---------------------<code>
if (done == 0) {
   gotoAndPlay ("loop");
}
---------------------</code>

And at this point the third part, the one that shows the results, is irrelevant as the movie never gets there.

I have established the following facts:

1.- The movie gets to "loop" and stays looping.

2.- Things.cgi is executed each time the movie is run

Things.cgi has the following code

---------------------<code>

# this script will read a text file, put it in an array and send the array over to a Flash movie

use strict;
use warnings;

# variables
my $fileBuffer; # buffer of the text file
my $firstName; # file data element
my $lastName; # file data element
my @allFirst; # first name array
my @allLast; # last name array
my $sendBack; # data to be sent back
my $i; # general counter

# debugging variables
my ($x, $sec, $min, $hour);
####################

# use for debugging
open(DEBUG, ">debug.txt");
($sec,$min,$hour,$x,$x,$x,$x,$x,$x) =localtime(time);
print DEBUG "$hour:$min:$sec\n";
####################

# read the text file and parse the data
open(INFILE, "things.txt");
while ($fileBuffer=<INFILE>){
   chomp($fileBuffer);
   ($firstName, $lastName)=split(/,/,$fileBuffer);
   push (@allFirst, $firstName);
   push (@allLast, $lastName);
}

# build the text to be sent back
$sendBack="names=(";
for ($i=0; $i<$#allFirst; $i++){
   $sendBack.="\"$allFirst[$i]\",";
}
$sendBack.="\"$allFirst[$#allFirst]\")&last=(";
for ($i=0; $i<$#allFirst; $i++){
   $sendBack.="\"$allLast[$i]\",";
}
$sendBack.="\"$allLast[$#allFirst]\")&done=1";

print $sendBack;

# send to the debug file
print DEBUG "$sendBack\n";
####################

# close the debug file
close(DEBUG);
####################

---------------------</code>


What am I doing wrong?


Thanks for the help.
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #1 on: 01/29/02, 03:01 »

Assuming that the script is working correctly.  (You can test this by typing in the URL to the Script in the browser window and see what is printed to the screen. - If it prints out a bunch of errors it's got something wrong - If it prints out all your information it is working correctly.).  

This script looks like it's returning  "done=1" if everything went successfully.  So your going to have to test for "done=1" in the loop.  An example would be:

if (done == 0) {
  gotoAndPlay ("loop");
} else {
gotoAndPlay("Complete");
}

It might be better to test it like this though:
if (done == 1) {
 gotoAndPlay("Complete");
} else {
   gotoAndPlay ("loop");
}


So what this does:  If done=1 - then the script has returned all of the results, theirfore you goto a Frame that is not in the Loop, and stop the Movie from Looping.  If done is not equal to 1 (ie still 0) then continue to loop.

Their's probably more to your question then that, but I guess it's a start.


Logged

-Jeff.
mmp770
Server what's that
*
Posts: 24



View Profile WWW Email
« Reply #2 on: 01/29/02, 05:09 »

Thanks, it worked Smiley.

Now I'm trying to figure out how to get the array part working. If I'll need help I'll scream.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!