Flex learning-communication between flex programs and HTML

Source: Internet
Author: User
Tags to domain

Summary good: http://blog.csdn.net/arshoon/archive/2008/06/11/2533982.aspx

 

 

Flex is usually embedded into a web page as part of a web project, so communication between the flex program and the web page becomes very important.

1) Flex provides multiple methods to implement interaction between flex programs and encapsulated pages, including flashvars attributes, query string parameters, navigatetoURL () methods, and Flash. External. externalinterface classes. 2) The flex program obtains the environment information: application. application. obtain the URL of the encapsulated page, and use @ contextroot. system. capacities obtains information about the system, such as the version, language, and operating system. 3) flashvars is used to transmit data from an external encapsulation page to the flex program. parameter values are input on the encapsulation page: ac_fl_runcontent (flashvars, "para1 = value1 &... & Paran = valuen ") or <Object> <Param name =" movie "value?#wrapper.swf? Para1 = value1/> <embed src?#wrapper.swf? Para1 = value1/> </Object>. application. parameters. para1: Get the parameter value; 4) externalinterface provides a method for flex programs and external encapsulated pages to call each other's methods. The external interface class is subject to domain Security Settings (allowScriptAccess, allownetworking). Determine whether externalinterface is available: externalinterface. available; flex calls JS: externalinterface. Call (funname, funpara1 ,..., Funparan); JS calls flex: first, use externalinterface in flex. addcallback ("jsfunname", asfun), assign the function defined in as to the name jsfunname called in JS, and then use myswf in Js. jsfunname () calls the function asfun provided in flex; externalinterface security: In general, access to JS and flex is limited to the same domain. You can set <Object> and <embed>'s allowScriptAccess = "value" (default value: never, always, and samedomain) to set the flex permission to access Js. As for JS access to the flex method, only the Js in FLEX can be accessed through addcallback. For cross-domain access, you can use the allowdomain () function settings. 5) navigatetoURL () can be used to open a new browser window or for communication between flex and Js. For example: open a new window: var URL: URLRequest = new URLRequest (http://blog.csdn.net); navigatetoURL (URL, _ blank); this function can also be used to execute JS, such as: var URL: URLRequest = new URLRequest ("javascript: window. close (); or: var urllurlrequest = new URLRequest ("javascript: myfun (para1... Paran) ") myfun () function is defined in the script section of the HTML page. function parameters must be enclosed in quotation marks! NavigatetoURL (URL, _ Self); can also be used to send email: var urlurlrequest = new URLRequest (mailto: zoushun@hotmail.com); navigatetoURL (URL, _ blank );

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.