Creating Interaction with ActionScript > Controlling movie playback > Jumping to a different URL

 

Jumping to a different URL

To open a Web page in a browser window, or to pass data to another application at a defined URL, you can use the getURL action. For example, you can have a button that links to a new Web site, or you can send data to a CGI script for processing in the same way as you would an HTML form.

In the following procedure, the requested file must be at the specified location and absolute URLs must have a network connection (for example, http://www.myserver.com/).

For information on passing variables, see Connecting with External Sources.

 
To jump to a URL:

1

Select the frame, button instance, or movie clip instance to which you will assign the action.

2

Choose Window > Actions to display the Actions panel if it's not already visible. If the Actions panel is not in normal mode, choose Normal Mode from the View Options pop-up menu.

3

In the Actions toolbox, click the Actions category, then click the Browser/Network category, and double-click the getURL action.

4

In the parameters pane, enter the URL from which to get the document or to which you are sending data, following these guidelines:

Use either a relative path, such as mypage.html, or an absolute path, such ashttp://www.mydomain.com/mypage.html.

A relative path lets you describe one file's location in relation to another; it tells Flash to move up and down the hierarchy of nested files and folders, starting from the file where you issued the getURL instruction. An absolute path is the complete address that specifies the name of the server on which the file resides, the path (the nested hierarchy of directories, volumes, folders, and so on), and the name of the file itself.For more information about writing paths, see About absolute and relative target paths.

To get a URL based on the value of an expression, select Expression and enter an expression that evaluates to the URL's location.

For example, the following statement indicates that the URL is the value of the variable dynamicURL:

getURL(dynamicURL);

For information on writing expressions, see Understanding the ActionScript Language.

5

For Window, specify the window or HTML frame into which the document will be loaded, as follows.

Choose from the following reserved target names:

_self specifies the current frame in the current window.

_blank specifies a new window.

_parent specifies the parent of the current frame.

_top specifies the top-level frame in the current window.

Enter the name of a specific window or frame as it is named in the HTML file.

Select Expression and enter the expression that evaluates to the window's location.

6

For Variable, choose a method for sending variables for the loaded movie to the location listed in the URL text box:

Choose Send Using Get to append a small number of variables to the end of the URL. For example, use this option to send the values of the variables in a Flash movie to a server-side script.

Choose Send Using Post to send variables separate from the URL, as longer strings in a separate header; this allows you to send more variables and lets you post information collected from a form to a CGI script on the server.

Choose Don't Send to prevent variables from being passed.

Your code would look similar to the following line:

getUrl ("page2.html", "blank");

The getURL action loads the HTML file page2.html into a new browser window.

For more information on the getURL action, see its entry in the online ActionScript Dictionary in the Help menu.