Macromedia Flash 8 for Windows & Macintosh

Flash gives you two ways to open new files by linking to URLs. You can select text on the Stage and turn it into a live link by entering a URL in the link field of the Text (Tool) Property inspector. You can also use ActionScript to instruct Flash Player to open a URL. Both techniques let you open the new file in a different browser window or different frame of the current window.

To script a button that opens a Web page

1.

In a Flash document, select or create a button instance.

2.

Access the Actions panel, and choose Script Assist mode.

3.

From the Add menu, choose Global Functions > Browser/Network > getURL (Figure 13.69).

Figure 13.69. With a button selected on Stage, choose Global Functions > Browser/Network > getURL from the Actions panel's Add menu to script the button to open a new URL in the browser window.

The parameters for getURL appear in the Script Assist window.

4.

Enter the desired URL in the URL field.

5.

From the Window pop-up menu (Figure 13.70), choose one of the following:

_self opens the specified URL in same frame of the browser window as the content being currently viewed.

_blank opens the specified URL in a new browser window.

_parent opens the specified URL in the parent of the current frame.

_top opens the specified URL in the top-level frame of the current browser window.

Figure 13.70. With Script Assist active, you can enter the URL and choose what window or frame the new URL opens in.

6.

Leave the Variables setting as Don't Send.

Flash adds the button's default handler on (release) and the getURL function to the script in the Script pane of the Actions panel (Figure 13.71). The send variables setting is of concern to more advanced ActionScripters who are setting up their own variables.

Figure 13.71. Script Assist creates a script that opens the new URL when the end user interacts with the button.

7.

Choose Control > Test Movie or Control > Test Scene to try out your button.

When you're testing Flash content on your local system and asking to load a URL that is on the network, you can run into security issues. For testing purposes, you may need to change the security settings in the Flash section of the Publish Settings dialog or give special permissions to the file you're testing via Macromedia's Security Settings Manager (see Chapter 16).

To create a text link to a URL

1.

On the Stage, select the text that you want to be a link.

You can select individual letters or words using the text tool or select an entire text box using the selection tool.

2.

Access the Property inspector, and enter the desired URL in the URL Link field (to the right of the chain-link icon).

3.

From the Target pop-up menu, choose the method you want Flash Player to use when opening the URL.

The choices are the same as in step 5 of the preceding task. Flash creates the script for opening the new Web page in the manner you chose.

4.

Choose Control > Test Movie or Control > Test Scene to try out your live link text.

The Mystery of URLs

The acronym URL stands for Uniform Resource Locator, which is a standardized way of handling the addresses of files so that they can be found on the Internet. The conventions of the URL make it possible to decipher the hierarchical structure of the server (or local computer) on which a file is stored, allowing you to maneuver through all the directories, folders, and subfolders to the specific file that you want.

URLs have two forms: absolute and relative.

An absolute URL is a complete address that specifies the protocol your browser should use to open the file (HTTP, or Hypertext Transfer Protocol, is one used to transfer the text and graphics of Web sites), the name of the server on which the file resides, the path name (the nested hierarchy of directories, volumes, folders, and so on), and the name of the file itself.

A relative URL is a shorthand version of the full address that lets you describe one file's location in relation to another. In essence, you tell Flash to move up and down the hierarchy of nested files, folders, and directories, starting from the file where you give Flash the getURL instruction. It's like saying, "Look in the folder you're in right now for a file called Fabulous.fla" or "Look in the folder you're in right now for a folder called OtherJunk, and then look inside that folder for the file Fabulous.fla," or "Go up one level to the folder that contains the folder containing the file you're in right now. In that higher-level folder, look for a folder called ThisJunk. Look in ThisJunk for a file called Abysmal.fla."

Using relative URLs in a script or link has the advantage of allowing you to test your movies on your computer without opening an Internet connection. Additionally, provided that you keep your files in the same relative positions in the hierarchy, you don't need to rename the files when you transfer them from your local computer to the server where you'll make them available to your viewers.

Категории