Viewers: in countries Watching now:
Through several hands-on tutorials, instructor Todd Perkins shows how to best build dynamic, streamlined sites using Flash CS3 Professional. Learn how to create custom keyboard shortcuts, apply advanced text techniques such as animating scrolling text with custom easing controls, and using advanced animation techniques. Flash CS3 Professional Beyond the Basics covers many challenging features, including adding complex interactivity to a Flash CS3 project and getting Flash content on a phone. Exercise files accompany the tutorials.
Now we're going to talk about sending URL variables in our form. If you're following along I'm working in 04_URL_Variables.fla in the Chapter 07 folder in the Exercise Files folder. Now, if you're familiar with html forms, you may know exactly what URL variables are, but if you're unfamiliar with html forms, that may sound like a very foreign, a very confusing term. Basically URL variables refer to the information that a form sends. For example picture somebody on a website filling out a form, they fill our their name and their e-mail and comments and they click the Submit button to send the form in an e-mail.
The URL variables are the information held in the Name text field, the e-mail text field, and the Comments text field. What we do need to its connect that information and send that to our file that's going to process our form and send an e-mail, and that's how we get information from a form into an e-mail. So let's select frame one of the actions layer and open up the Actions panel by pressing option F9 on the Mac or F9 on the PC. One very effective way to attach URL variables to a URL address is to use the URL variables class.
What I'm going to do in our variable section below line 2, I'm going to create a new variable. I'm going to call this variable variables and this represents our URL variables. The datatype is going to be URLVariables. Flash actually has a class just for managing URL variables. We'll set this variable equal to a new instance of the URL variables class. The URL variables class is a dynamic class just like the object class. That means you can create your own properties and values with an instance of the URL variables class.
This is very useful for sending form information, because often a script that processes your form and sends an e-mail wants certain named values in order to send the e-mail properly. For example, your script may require you to send a variable called subject and that would include the information that's in the subject of the e-mail being sent. Let's take a look at how to create that variable next. Go to the next line. Type variables.subject, notice I'm not getting any code hinting because this property does not exist, I'm creating it right now.
I'll set it equal to "Information sent from a Flash Form"; So now this value's connected to our URL variables object. Let's go to the next line. Another thing the form simply asked for is the recipient of an e-mail. So I'll type variables.recipient equals and I'm just going to give the generic name of "email@example.com"; Remember it's a string value cause this is an e-mail address.
So now we've connected the recipient variable to our form variables. The next step is to take the values that are inside of the text fields in the form, when the user clicks the Submit button and attach those values to our variables object. At the top of the sendForm function, type variables.name. This can be something that's also required or may be optional for your form mail script. Set that equal to name_txt.text; And this will be equal to whatever is inside of the name text field.
On the next line, type variables.email. We'll set that equal to email_txt.text; The last property we'll set is comments. So let's go down to the next line and type variabless.comments = comments_txt.text; Now we have two more steps left. First we have to specify a way that our URL request is going to send form variables.
So let's go down right below where we set the value of the URL equal to a new URLRequest, type url.method = URLRequestMethod.POST; Now there's two different methods for sending variables and one is called Post and one is called Get. Post is a little bit more common, but again as specified by your Web server host or your form mail script, you may need to use different URL request method.
But if you don't know you're typically safe with going post here. So let's go to the next line. And now we need to connect our URL request to our form variables. Type url.data = variables; and that connects all of our form variables to our url request. Now if I sound unusually excited about this, it's because this way is fairly simple compared to creating a form in html. Unless you're using a tool that writes all the code for you, when you create a form in html, you have to take all of the form variables and do special encoding on those variables to make sure that they're acceptable to send in html form.
All you have to do in Flash is create properties of whatever values we want on a URL variables object and associate that object with our URL request, and then when we run our navigateToURL function and pass in URL, all the values are encoded properly. Flash is doing all of the encoding of our URL behind the scenes. And if URL encoding is unfamiliar to you as well as html forms, don't worry about it. Just know that Flash is actually doing a lot of work behind the scenes that you would have to do if you were to create the same form using html.
And there you have a form that you can use to send an e-mail. You'll simply have to adjust the address to link to the script that processes the form and sends the e-mail, and you may create different properties on your URL variables object. And that would all be specified inside of your form mail script. And there's a look at how to create and send your form using components.
There are currently no FAQs about Flash CS3 Professional Beyond the Basics.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.