Interaction between flex and JavaScript (1) [original]

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.