User Guide
Example: Using the External API with a web page container 513
■ The getStatus() ActionScript method returns a value, and that value is assigned to the
currentStatus variable, which is then assigned as the content (the value property) of
the
status text field.
The
sendMessage() JavaScript function demonstrates passing a parameter to an ActionScript
function. (
sendMessage() is the function that is called when the user presses the Send
button on the HTML page.)
<script language="JavaScript">
...
function sendMessage(message)
{
if (swfReady)
{
...
getSWF("IntrovertIMApp").newMessage(message);
}
}
...
</script>
The newMessage() ActionScript method expects one parameter, so the JavaScript message
variable gets passed to ActionScript by using it as a parameter in the
newMessage() method
call in the JavaScript code.
NOTE
If you’re following along in the code, you’ve probably noticed that in the source code for
the
updateStatus() function, the line of code that calls the getSWF() function, is actually
written as follows:
var currentStatus = getSWF("${application}").getStatus();
The ${application} text is a placeholder in the HTML page template; when Adobe Flex
Builder 2 generates the actual HTML page for the application, this placeholder text is
replaced by the same text that is used as the
<object> tag’s id attribute and the <embed>
tag’s
name attribute (IntrovertIMApp in the example). That is the value that is expected by
the
getSWF() function.