Flex gets the instance code for the client IP and computer name through JS
- 2020-03-29 23:55:20
First of all, getting it JS is not calling webservices and httpservices.
In each of our FLex web projects, have such a folder bin - debug, there is an index. The HTML file, my understanding is that the first web page run, MXML files will be compiled as SWF, how SWF show in the browser, is through the HTML files, equivalent to the HTML file embedded in a SWF object components. www.jb51.net
So, I personally think it's possible to write js code in this HTML to get the IP address. So the following code appears.
Add the script tag in index.html, the actual code is as follows:
So the equivalent of the background code to get IP and pcname is written.
How to call in flex, then use the flex of the class: flash. External. The ExternalInterface.
For the ExternalInterface class, adobe explains it this way:
This function replaces the fscommand() method.
You can use the ExternalInterface class in the following combination of browser and operating system:
. - + * / /
Note: Flash Player version 220.127.116.11 and later allows the. (period) character in the id and name attributes.
Programmatically using this class to open pop-up Windows in Flash Player 10 and later running in the browser may not succeed. Different browsers (and browser configurations) may block pop-ups at any time; There is no guarantee that any pop-ups will be displayed. However, to be as successful as possible, use this class to open a pop-up window only in code that is executed as a direct result of a user action (for example, in an event handler for a mouse click or key event).
Using ActionScript, you can do the following on an HTML page:
Pass any number of arguments with any name.
Pass various data types (Boolean, Number, String, and so on).
Use this class in our MXML file. Call the function to get IP and pcname in js:
PcName = ExternalInterface. Call (" getClientPcName ");
IP = Your externalinterface.call (" getClientIp ");
You can try Alert to see if it's right. There is still a problem, add your machine as the server, then the IP obtained on the server will be: 127.0.0.1, handle it I believe you will have a way.