About the External API
669
The previous code is split into three sections. The first section imports the
ExternalInterface class so you don’t have to use its fully qualified class name. The second
section of code defines a callback function,
asFunc()
, which is called from JavaScript in
an HTML document created in an upcoming example. This function sets the text within
a TextInput component on the Stage. The third section of code defines a function and
assigns it as an event listener for when the user clicks the Button component instance on
the Stage. Whenever the button is clicked, the SWF file calls the
jsFunc()
JavaScript
function in the HTML page and passes the text property of the
out_ti
text input
instance.
7.
Select File > Publish Settings and then select the Formats tab and make sure that Flash and
HTML are both selected.
8.
Click Publish to create the HTML and SWF files.
When you’re finished, go on to the next procedure to create the container for the
SWF file.
Before you can test the previous Flash document, you need to modify the generated HTML
code and add some additional HTML and JavaScript. The following procedure modifies the
HTML container for the SWF file so the two files can interact when they run in a browser.
To create the HTML container for the SWF file:
1.
Complete the previous procedure.
2.
Open the extint.html file that Flash creates when you publish the application.
It’s in the same folder as the Flash document.
3.
Add the following JavaScript code between the opening and closing
head
tags:
<script language="JavaScript">
<!--
function thisMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function makeCall(str) {
thisMovie("extint").asFunc(str);
}
function jsFunc(str) {
document.inForm.inField.value = "AS > Hello " + str;
}
// -->
</script>
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...