EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 665

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Sending messages to and from Flash Player 665
4. Select Frame 1 of the Actions layer, and add the following ActionScript in the
Actions panel:
window_btn.onRelease = function() {
fscommand("popup", "http://www.macromedia.com/");
};
alert_btn.onRelease = function() {
fscommand("alert", "You clicked the button.");
};
5.
Select File > Publish Settings, and make sure that Flash with FSCommand is selected in the
Template menu on the HTML tab.
6. Select File > Publish to generate the SWF and HTML files.
7. In an HTML or text editor, open the HTML file that was generated in step 6 and examine
the code. When you published your SWF file using the Flash with FSCommand template
on the HTML tab of the Publish Settings dialog box, some additional code was inserted in
the HTML file. The SWF files
NAME and ID attributes are the filename. For example, for
the file myMovie.fla, the attributes would be set to
myMovie.
8. In the HTML file, add the following JavaScript code where the document says // Place
your code here.
:
if (command == "alert") {
alert(args);
} else if (command == "popup") {
window.open(args, "mmwin", "width=500,height=300");
}
(For more information about publishing, see Chapter 17, “Publishing in Using Flash.)
Alternatively, for Microsoft Internet Explorer applications, you can attach an event
handler directly in the
<SCRIPT> tag, as shown in this example:
<script Language="JavaScript" event="FSCommand (command, args)"
for="theMovie">
...
</script>
9.
Save and close the HTML file.
When youre editing HTML files outside of Flash in this way, remember that you must
deselect the HTML check box in File > Publish Settings, or your HTML code is
overwritten by Flash when you republish.
10. In a web browser, open the HTML file to view it. Click the Open Window button; a
window is opened to the Macromedia website. Click the Alert button; an alert
window appears.

Table of Contents

Related product manuals