Get the App
SLTechnology News&Howtos  ›  Development  › 

How Flex and JavaScript interact

Shulou Source: shulou.com Published: 2022-06-03 01:02:41 11月15日 Update

It is believed that many inexperienced people have no idea about how to interact with Flex and JavaScript. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

In the process of learning Flex, you may encounter the problem of interaction between Flex and JavaScript, here to share with you, mainly including Flex calling functions in JavaScript and JavaScript calling functions in Flex.

Flex interacts with JavaScript

Flex interacts with JavaScript, mainly relying on Flex's ExternalInterface, which provides addCallBack and call methods.

◆, let's take a look at the functions in JavaScript called by Flex.

FlexConnectJavaScript.mxml

Add functionreturnTheName (a) {return "HUANGXI";} / to FlexConnectJavaScript.html

Summary

1.ExternalInterface.call ("returnTheName", "huangxi"), where * parameters are the same as the function in JavaScript, and the second argument is the passing parameter.

◆, let's take a look at JavaScript calling functions in Flex.

JavaScriptConnectFlex.mxml

Add calculation to JavaScriptConnectFlex.html. Add functionaddMethod () {vars=JavaScriptConnectFlex.addTo100 (); alert (s);} /

1.ExternalInterface.addCallback ("addTo100", add); defines methods that can be called by JavaScript

two。 It can be seen that JavaScript wants to call the Flex function, Flex needs to declare it, while Flex does not need to call the JavaScript function.

After reading the above, have you mastered how Flex and JavaScript interact? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Functions methods content parameters problems China plus more the same helpless for this reason most of them summary skills articles experience industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL Shulou Technology Shulou Information Xiaomi