|< Day Day Up >|
For the rest of this hour, you'll learn some useful and powerful ways to combine Flash with standard HTML. If you already know HTML, you should be able to take this information and run with it. If you're not familiar with HTML, the rest of this hour should still be useful because you'll see some examples of what's possible. In addition, you'll see some code snippets that you can probably use in the future. If you want to learn more about the concepts discussed this hour, you can look to any good HTML resource.
You probably noticed that when you clicked the button you created in the second task this hour, "Use getURL to Create a Hyperlink," not only were you hyperlinked to another page, but the page you were viewing (the one with your Flash movie) was actually replaced with the new page. This is the default behavior for any hyperlink (as is the case with the HTML equivalent, A HREF). Alternatively, you can specify the window parameter to change the behavior from "replace this page with another" to "jump to a new web page and put it in new window."
In HTML, window refers to the rectangular frame into which the user views a web page. Some pages just have one big window whereas others are made up of an arrangement of several windows. Windows can be given names so that you can specify into which window particular content should go. There are also some generic window names. Compare this to how you can refer to houses in your neighborhood specifically by using addresses or you can use generic terms such as "next door" and "across the street."
The Go to web Page behavior's Open In setting (which is getURL's second parameter) lets you specify a target window into which the specified URL will load. If you set this parameter to "_self", the hyperlink loads the new web page directly inside the same browser window. If you edit the getURL script, you can specify a window name (which generally applies only when you've previously named windows, as in HTML frames), into which to load the new web page. For example, suppose your Flash movie has several buttons, each one causing a different window to change its contents. As you click the buttons, the Flash movie stays in its own window, and other windows pop open as necessary.
One way to arrange several windows in HTML is by using framesets. One frameset can have as many frames as you want. Each frame can be designed to have specific dimensions and features such as a menu bar or title bar.
In addition to author-named windows, there are four reserved "generic" target window names. If you click the Open In drop-down list, as shown in Figure 19.6, you'll see _self, _blank, _parent, and _top. Most of these names apply to frames (which you can learn about in an HTML reference), and one name comes in handy when frames aren't being used. The name _blank causes the selected URL to load into a new browser window, and it leaves the current window open. To see this in action, select the button created in this hour's second task, open the Behaviors panel, and double-click the row you added (it should read Go to Web Page...). Then change the parameter to _blank. When you publish, you should notice that when the button is clicked, a whole new browser window is created.
Figure 19.6. The Go to Web Page behavior provides the generic target window options in a drop-down list.
Sending Email: The mailto: Command
Although you have to use more advanced techniques to actually send email from a web page, here's a quick-and-dirty way to do something close. The HTML command mailto: can be used in conjunction with getURL to automatically open a user's email program with a preaddressed email message. The user just needs to type a message and then send the email message.
It's really simple. You can just make another button (perhaps with the label Email Me) and then use the Go to Web Page behavior again. But this time, be sure to select _self and put the following text in the URL field:
Here, email@example.com is the email address. If you select the Publish Preview command, when the action is encountered, you should see that a new email message that's already addressed is created. The user only needs to type the message and click Send. The only catch is that the user must have a default email program identified on his or her computer (most people do).
If you want the email message to pop up with the subject and body content already created, you can change the simple mailto string (for the URL field) to something like this:
mailto:firstname.lastname@example.org?subject=Subject goes here&body=Body goes here
Simply replace email@example.com with the address you want the message sent to, replace Subject goes here with whatever subject line you want, and replace Body goes here with whatever message you want in the body of the email message.
|< Day Day Up >|