Archive for September, 2009
How can I quickly determine
Posted by Admin in Uncategorized on September 29th, 2009
How can I quickly determine whether my Web server supports Perl?
A4: The only way is to test it. Servers vary greatly in the software that runs them and the way they are configured. There is no surefire way to determine whether the server will run CGI programs unless you are an expert.
Q5: Do CGI programs see a difference between HTML post forms and Flash movies that use the LoadVars object?
A5: No. They look the same to CGI programs. This means that creating quick and simple HTML forms is a great way to test your CGI programs before trying to use them from a Flash movie
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
I’ve made a CGI program
Posted by Admin in Uncategorized on September 26th, 2009
I’ve made a CGI program to send data to a movie, but that movie doesn’t always get the data. Why?
A2: Make sure that you are using the right MIME type when returning the data. This corresponds to the Content-type: at the top of the Perl scripts in this hour. If you are generating a text or HTML page, then text/html is the right MIME type. However, if you are sending data directly to a Flash movie, use application/x-www-urlform-encoded.
Q3: In a program like the survey, how do I prevent the user from clicking the Submit button more than once?
A3: There are many ways. You could let the user click the button more than once, but just not send the data if it has already been done—set a variable to true the first time. Or, you could send the user immediately to another frame that says “please wait” when the user clicks the button.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Summary
Posted by Admin in Uncategorized on September 23rd, 2009
The LoadVars object allows you to send and receive information from a server. The send command works just like a
The next step is to change
Posted by Admin in Uncategorized on September 20th, 2009
The next step is to change the trace command to a send command. We’ll use one that replaces the entire page.
The CGI program looks similar to the echo.cgi example from earlier this hour, but it writes the data to a text file instead. It then returns the text “Thank You!” as the Web page.
Even if you have been able to get the echo.cgi program working on your server, you may not be able to get this one to work. This is because the program needs to have permission to create and append to a new file. You may need to adjust the permissions of the program or even the folder it sits in. You may have to create the survey.txt file yourself, as an empty text file, and then set its permissions. Some hosting providers may not allow CGI programs to create or write to files.
Test this movie and then examine the new contents of survey.txt on your server. You will see the data for your test there. A new line is added every time someone takes the survey. You can compute the results of the survey using a spreadsheet program, or even another CGI script specially written to compute the results with the existing data.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Repeat step 5 to make another group
Posted by Admin in Uncategorized on September 17th, 2009
Repeat step 5 to make another group of four radio buttons. Name them OSmac, OSwindows, OSlinux, and OSother. Place appropriate text next to them and group them together in a movie clip named OS. At this point, you may want to check the movie 18survey.fla in the folder 18survey to see how your movie matches my sample.
The getValue function is the one we made in Hour 15 that gets the name of the selected radio button. We can use any one of the button movie clips in the group to get the answer, but I used the first in each group.
Run the movie. Instead of submitting the data to the server, the movie uses the trace command, along with a toString() function to output the potential submission to the Output window. This allows you to test your movie before going forward and doing the CGI script. You should see a result like this:
OS=OSmac&age=ageGroup2&email=gary@xxx.com&name=Gary
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Task: Recording Survey Results
Posted by Admin in Uncategorized on September 14th, 2009
Now let’s make a Flash movie that is somewhat useful. We’ll build a slightly more complex form that asks several questions. Then, we’ll send all the data to the server, where a CGI program records it. It does this by appending the data to the end of a text file.
Start a new Flash movie.
In this movie, place two input text fields, linked to the variables userName and userEmail.
Open the movie 15radiobuttons.fla that we used in Hour 15, “User Input Elements.” Copy a single radio button from that movie’s stage onto the new movie’s stage. This should bring with it the movie clip and two buttons as Library elements.
Copy and paste to make a group of four radio buttons. Name each movie clip ageGroup1, ageGroup2, ageGroup3, and ageGroup4. Place text next to each one signifying a different age group. Select them all and choose Insert, Convert to Symbol. Make them all one movie clip named ageGroup.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Upload these both to your server
Posted by Admin in Uncategorized on September 11th, 2009
Upload these both to your server, set the permissions on echo.cgi to what your server requires for CGI programs, and open the HTML page in your browser. You should be able to type a name and ID in the HTML form, click Submit, and get back a list of the values you entered.
Now let’s do the same thing in Flash. The movie 18echotest.fla contains two simple input text fields linked to the variables userName and userID. There is also a Submit button. The only script is on the Submit button. It creates a LoadVars object, sets two properties, and sends it.
The second parameter, _self, means that the entire HTML page with the Flash movie will be replaced by the result of the CGI program. This means that it will work just like a normal HTML form.
You can test this movie by uploading both the .swf and the .html files to your server, in the same location as the working CGI program. The result should be the same as if you used the HTML form.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Here is an example of a simple CGI
Posted by Admin in Uncategorized on September 8th, 2009
Here is an example of a simple CGI program that takes the input from an HTML form or a Flash movie and echoes them back to the user:
Because this is a book about ActionScript, not Perl, I will quickly summarize what this code does. It takes the contents of an HTML form or a Flash LoadVars object and looks at each property/value pair, sending it back as a simple text page. It converts the text to normal text rather than the escape-character equivalent, which uses + rather than spaces and things such as %20. Both HTML forms and Flash convert the data to this format before submitting.
You can find the CGI script on the CD-ROM in the folder 18send. It is called echo.cgi. The sample HTML is called echotest.html.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Seek out a friend who has created
Posted by Admin in Uncategorized on September 5th, 2009
Seek out a friend who has created CGI programs before. Tell her that you need to get your first Perl program up and running. Someone who knows Web servers can figure out your hosting situation and show you how to set up a Perl program in no time.
Partner with someone at your company who can write CGI programs. At most companies, Flash and CGI programming are considered different skills and are done by different people. So if you are asked by your company to set up a program that requires CGI programming, but you have never done it before, you may want to inquire about having someone else help you with the task.
For the rest of this hour, I’ll assume that you were able to get CGI programs running on your server. Remember that you will have to upload the Flash movie to the same server where the CGI program is located. In most cases, you will want the movie and the CGI program to be in the same folder.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
So how do you set the permissions
Posted by Admin in Uncategorized on September 2nd, 2009
So how do you set the permissions of a file on your server? Well, this is where I stop. I can’t tell you how to set the permissions on your server because there are many different types of servers, many different setups used by ISPs, and many different programs with different interfaces that allow you to set permissions. However, I will give you a list of things you can do to get your first CGI program up and running:
Figure out what type of Web site you have. Is it a company Web site? Then you probably have a company system administrator who can help you.
If you use a quality hosting provider, there are probably how-tos and help files that you can refer to on its Web site.
Quality Web hosting companies will also have customer support that may be able to help you.
If you are using a free or inexpensive Web hosting solution, you probably cannot run CGI programs at all.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours


Recent Comments