As I mentioned before, a Flash movie essentially acts as a web page when reading in values from a CGI script, in our case, a text file. The way you get the values into Flash is using the Load Variables command. Let's look at how we'd read in the values from our text file.
The Action Script above would read in the values from your text file and assign those values to your text fields, or, if there aren't any text fields with the name being passed in (i.e. Name or Email), Flash would create a variable to hold the value. This can be very helpful if you want to have values that you're not ready to use until a later point in your movie. Just be sure that you can get to your variable when you need it.
The other thing to note here is that if you're using a CGI script instead of a text file, you'd just type the path to it where you see poll.txt above. Also, at the bottom, under the Variables section, if you're just using a text file, there's no sense in sending anything to it, but if you have a CGI script, you may want to send variables to it. Your CGI script could then process these variables or kick off another action. Flash will basically send any variables that are currently in scope to the URL you've provided.
What does that mean? Well, it means that if you're on the Main Timeline and you have a handful of variables (like Name and Email in our example above), they will be sent to your CGI script. If this Load Variables is performed somewhere else, like inside a Movie Clip, then your variables on the Main Timeline will NOT be sent. Notice that the Load Variables is inside a Tell Target block.
This means that the values that are received from your CGI script will be declared on the Main Timeline. You'd then be able to refer to them anywhere else in your movie by referring to them as /name, and /email (to follow our example). In Part II of this tutorial, we'll go into much more detail on sending variables to CGI in order to save them.
|» Level Advanced|
Rating: 8 Votes: 73
|Jei Gaither is a web developer in Austin, TX. His projects out-weigh his spare time, but he still manages to find new uses for Flash and creative interfaces.|
|Download the files used in this tutorial.|
|Download (33 kb)|
|More help? Search our boards for quick answers!|