Let's take a look at how Flex calls functions in JavaScript.
Flexconnectjavascript. mxml <? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
<Mx: SCRIPT>
<! [CDATA [
Import flash. External .*;
Public Function invokejavascript (): void
{
Lblresult. Text = externalinterface. Call ("returnthename", "huangxi ";
}
]>
</MX: SCRIPT>
<Mx: button id = "btnconnect" label = "Call JavaScript" Click = "invokejavascript ()" x = "229" Y = "204"/>
<Mx: Label id = "lblresult" text = "test" x = "205" Y = "99" width = "150" Height = "80"/>
</MX: Application>
<SCRIPT> added to flexconnectjavascript.html
Function returnthename ()
{
Return "huangxi ";
}
////////////////////////
Summary
1. externalinterface. Call ("returnthename", "huangxi"); the first parameter is the same as the function in Javascript, and the second parameter is the passing parameter.