Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the interaction between Flex and browser

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to implement Flex and browser interaction, the content is concise and easy to understand, definitely will make your eyes shine, through the detailed introduction of this article I hope you can learn something.

Summary Flex interacts with browsers

In order to extend the functionality of your Web application with Flex, you will have to interact more with the browser, which will use the knowledge described below.

1. Implement URL jump in Flex (use flash. net.navigateToURL() method such as: )

/* *param1: URL to be redirected *param2: redirect_blank/_self */ navigateToURL(newURLRequest("http://blog.csdn.net/xingjunli"),"_blank");

Flex interacts with browsers using FlashVars to pass replacement parameters (using the Application.application.parameters attribute)

Embed SWF file code in page (we can set FlashVars information dynamically through JS to achieve the purpose of data interaction)

Get parameter code in Flex:

privatefunctiononFlashVars(e:MouseEvent):void//Get page parameters { varparameters:Object=Application.parameters; labURL.text=Application.url.toString();//http://localhost:8889/main.swf varparame1:String=parameters.UserName;//Andy_liu varparame2:int= parameseInt (parameters.Age);//18 varparame3:String=parameters.Address;//HongKong /* txtParam1.text= parame1; txtParam2.text=String(parame2); txtParam3.text= parame3; */ }

3. Call JavaScript functions in Flex when Flex interacts with the browser

First complete jsfunction in the page (note that only JS functions introduced by the current page can be called in Flex)

functionShowUserInfo(name,age,address) { alert("Name:"+name+"\n"+"Age:"+age+"\n"+"Address"+address); return"CallSuccessful! " }

Call methods in Flex and get the JSfunction return value (using the ExternalInterface.call() method):

privatefunctiononCallJS(e:MouseEvent):void { /* *param1: Current page JSfunction method name *param... 0-N parameters passed */ varresultValue:String=ExternalInterface.call("ShowUserInfo",txtParam1.text,txtParam2.text,txtParam3.text); //resultValue=CallSuccessful! That's how Flex interacts with the browser. Have you learned anything? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report