Flex integrates IFrame and integrates UnityWebPlayer for direct communication call solution, flexunitywebplayer

Source: Internet
Author: User
Tags openldap

Flex integrates IFrame and integrates UnityWebPlayer for direct communication call solution, flexunitywebplayer

For Web development, flex interacts with JS, and UnityWebPlayer interacts with JS. Mutual calls between them are common.

/*** Flex calls the Javascript function * @ params functionName: String Javascript function name * @ params... the params Javascript function parameter * @ return returns the return content of the Javascript function **/ExternalInterface. call (functionName: String ,... params );

/*** Use Javascript to call the Flex Function * @ params functionName: String Javascript to call the Flex Function name * @ params closure: Function Flex will call the Function * @ return void **/ExternalInterface. addCallback (functionName: String, closure: Function );

JS calls the Unity web Content Function

<script type="text/javascript" language="javascript"><!--//initializing the WebPlayervar u = new UnityObject2();u.initPlugin(jQuery("#unityPlayer")[0], "Example.unity3d");function SaySomethingToUnity(){u.getUnity().SendMessage("MyObject", "MyFunction", "Hello from a web page!");}--></script>

In Unity web player, you need to have a "MyObject" GameObject object and add a script with the "MyFunction" function:

function MyFunction(param : String){    Debug.Log(param);}

Unity web player calls JS functions on the webpage:

Add this script to unity to call Application. ExternalCall ("SayHello", "The game says hello! ");

On the web page, you need to define a function called SayHello (): <script type = "text/javascript" language = "javascript"> <! -- Function SayHello (arg) {// show the message alert (arg) ;}--> </script>
The preceding two interaction methods are commonly used. Recently, a project has encountered a special application requirement. You need to check the page of unity web player into the flex application framework and complete direct interaction between flex and unity web player.

To meet this requirement, you need to solve the following problems:

1. How to check the html page into the flex container;

2. How to implement direct communication between flex and unity web player;

Problem 1: the query result shows that there is an iframe plug-in flex, which can be solved.

Step: 1. Download the available materials from this link https://github.com/flex-users/flex-iframe/downloadsmy next is the latest flex-iframe-1.5.1.zip after decompression, two AcriptScript class files can be found in the path of flex-iframe-1.5.1 \ sources \ library \ flex-iframe \ src \ com \ google \ code \ flexiframe 2. as, iframeexternalcils. as is stored in the Flex project, I copy it to the Class file or reference the bin \ flex-iframe-1.5.swc3, create a new MXML application, add a red part of the code, fill in the page to be displayed in source <? Xml version = "1.0" encoding = "UTF-8"?> <S: Application xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns: flexiframe = "http://code.google.com/p/flex-iframe/" xmlns: s = "library: // ns.adobe.com/flex/spark" xmlns: mx = "library: // ns.adobe.com/flex/mx "minWidth =" 955 "minHeight =" 600 "xmlns: iframe =" Class. * "> <fx: Declarations> <! -- Place non-visual elements (such as services and value objects) Here --> </fx: Declarations> <iframe: IFrame id = "iFrame" source = "http://www.baidu.com/" width = "100%" height = "100%"/> </s: Application>
Issue 2: Solve direct communication between flex and unity web player.

Unity web player calls the flex function. The key is to mark the function in red. In fact, iframe is checked into the Flex HTML, if the SwfContent object is found through the iframe script, the function in flex can be called to implement communication with flex.





Iframe is nested in the div in html. iframe references html files compiled by flex. Why is the onclick event of div useless?

What do you want to do with this event?
 
How can we integrate existing WEB applications into the liferay portal?

Liferay + cas + openldap are both open-source frameworks.
Function requirements: a. Single Sign-On. B. System Integration. C. Custom styles. D. Publish information. E. Search (for OA, implementation is still a little realistic ).
B. System Integration:
System integration includes the following methods:
1. iframe: using the iframe portlet provided by liferay, other web systems can be directly integrated as URLs. However, session loss may occur. The system in iframe habitually chooses the redirect operation after performing the Login operation, which forces the display address in the browser to change to the transferred address. In fact, this is a very correct practice. Under normal circumstances, there will be no problems, and it can also prevent problems caused by PAGE refresh.
However, in the IFrame Portlet of Liferay, a Redirect operation such as a web application causes the session to become a new one after being transferred to a new page, this results in the loss of login user information stored in the original session.
There are two ways to solve this problem, both of which depend on the web application incorporated by liferay portlet.
Method 1: After a Login operation, the Redirect method is not used, but the Dispatcher method.
Method 2: After the Login operation, the redirect method is still used, but the current jsessionid is assigned to the new page.
In one case, it doesn't matter whether the Redirect method is used. This means that Liferay and webapp are in the same JVM environment. The main method is suitable for information publishing, but it is not suitable for individuals integrating other systems. First, the session problem mentioned above can be solved, but the solution is not ideal, second, displaying another system in the portal also results in a big difference in style.
2. Call JSP in the Portlet:
Use the include and method to embed JSP at the specified position into the portal page (the JSP page does not contain 3. servlet calling in the Portlet: This method is also not feasible. After all, exposing the servlet will pose a great challenge to permission management.
Based on the above problems, the system integration of other servers determines to bring up a new window, just like a login proxy, after logon, the portal no longer manages the tasks, which saves the processing of permissions, timeouts, and other issues. The integration of a specific service uses the webServices method called in the portlet, saves the trouble of intruding into the original system.
A. Single Sign-on:
We use cas as the authentication center for single-point logon and openldap as the user information storage server.
Integrate cas in liferay to directly configure the url of cas in "My Account", "portal", "setting", and "authentication" on the portal page; in addition, you also need to configure a Filter in the web system ,... remaining full text>

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.