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 file's
the file myMovie.fla, the attributes would be set to
8.
In the HTML file, add the following JavaScript code where the document says
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
Alternatively, for Microsoft Internet Explorer applications, you can attach an event
handler directly in the
<script Language="JavaScript" event="FSCommand (command, args)"
for="theMovie">
...
</script>
9.
Save and close the HTML file.
When you're 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.
and
NAME
:
tag, as shown in this example:
<SCRIPT>
attributes are the filename. For example, for
ID
.
myMovie
Chapter 17, "Publishing"
Sending messages to and from Flash Player
// Place
in Using Flash.)
665
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?