Jumat, 23 Mei 2008

Linking to Other Web Pages


A short tutorial showing how to create hyperlinks to other web pages (URLs). The same method can be used to create links to external files - such as ZIP, DOC, PDF, MP3, etc.


There can be problems testing external links locally (from your computer). One of the features of the latest Flash Player is heightened security. Basically, when you install it, you need to visit Adobe/Macromedia's online settings manager to choose and apply your settings. This should only need to be done once - on any computer you use for development and testing.

This thread in our forums covers the topic in some detail and provides links to the settings manager:

When creating links to external files such as PDF documents, keep in mind that the file will most likely open in the default application set on the viewer's computer. In the case of PDF files, creating a link to it will usually open the file in the browser with Acrobat Reader. If you link to an MP3 file, it will probably open in the viewer's media player (WinAmp, Windows Media Player, Quicktime, etc.) If you want to allow the user to save the file to their computer, it is recommended to ZIP (or RAR) the file and link to that instead.

Setting Up

The actionscript for hyperlinks is very simple. I'll show how to do it using point-and-click methods with the Assist Pane on the Script panel.
You can turn any shape, image, text, object, or MovieClip into a hyperlink. So, open a new file in SWiSH Max2 and draw a rectangle shape on the Layout. Select that shape and open the Script panel.

1) Add Script -> Events -> Button -> on (release)
2) Add Script -> Browser/Network -> getURL(...)
3) On the Assist Pane, type in the web page you want to open in the URL field.
4) In the Window field, you can select (or type in) a target frame. The default options _self and _blank refer to the browser window itself. If you select _self, it will open the URL in the same browser window. If you select _blank, it will open a new browser window and go to the URL provided. The options _top and _parent refer to Framesets (HTML Frames). If you are using a frameset and want to open a URL in a specific frame, you will need to know the exact name of that frame (written in the HTML frameset code). Whatever name is in the HTML is what you would type into the Window field.

You should end up with a script similar to this:
on (release)
getURL("http://www.example.com", "_blank");

Tidak ada komentar: