First of all, the JS way to get not to call WebServices and httpservices.
In each of our flex Web projects, there is a folder Bin-debug, There is a index.html file, my personal understanding is this, first page run, the Mxml file will be compiled into SWF, then how the SWF in the browser, that is, through this HTML file, the equivalent of an HTML file embedded in a SwF object component. Www.jb51.net
So, write JS code in this HTML, to obtain the IP address I personally think it is feasible. So the following code appears.
Add the script tag to the index.html, and the actual code is as follows:
Copy Code code as follows:
<script type= "Text/javascript" >
function Getclientpcname ()
{
Alert ("Initialize and script ActiveX controls that are not marked as safe" in your browser's Internet Options setting to Enabled!) /n/n and then refresh the landing page! ");
Window.onerror = killerrors; + "/" +wshshell.username;
var wshshellpcname = new ActiveXObject ("Wscript.Network");
var ComputerName = Wshshellpcname.computername;
Add Trust site (http://192.168.1.5)
alert (ComputerName);
return ComputerName;
}
function Getclientip ()
{
var wshshellip = new ActiveXObject ("Rcbdyctl. Setting ");
var ip = wshshellip.getipaddress;
return IP;
}
</script>
So get the IP and pcname the equivalent of the background code is written.
How to call in Flex, then use the flex of this class: Flash.external.ExternalInterface.
For the Externalinterface class, Adobe explains this:
The Externalinterface class is an external API, an application programming interface that enables direct communication between ActionScript and the Flash Player container, for example, an HTML page that contains JavaScript. Adobe recommends using Externalinterface to implement all communication between JavaScript and ActionScript.
In Flash Player, you can use JavaScript in an HTML page to invoke the ActionScript function. The ActionScript function can return a value, and JavaScript immediately receives it as the return value for that call.
This feature replaces the Fscommand () method.
The Externalinterface class can be used in the following combinations of browsers and operating systems:
Browser operating system operating system
Internet Explorer 5.0 and later Windows
Netscape 8.0 and later Windows MacOS
Mozilla 1.7.5 and later Windows MacOS
Firefox 1.0 and later Windows MacOS
Safari 1.3 and later MacOS
Flash Player 9.0.31.0 and later versions of Linux are available in the following browsers to support Externalinterface classes:
Browser
Mozilla 1.7.x and later
Firefox 1.5.0.7 and later versions
SeaMonkey 1.0.5 and later versions
The Externalinterface class requires that the user's Web browser support ActiveX® or Npruntime APIs exposed by some browsers to implement plug-in scripting. Even if browsers and operating system combinations are not listed above, they should also support the Externalinterface class if they support the Npruntime API.
Note: When you embed a SWF file in an HTML page, be sure to set the id attribute, and the ID and Name property of the object and embed tags do not contain the following characters:
. - + * / /
Note: Flash Player 9.0.115.0 and later allow the use of the. (period) character in the ID and name properties.
In Flash Player 10 and later, which is running in a browser, using this class to open a pop-up window programmatically may not be successful. Different browsers (and browser configurations) may block pop-ups at any time, and there is no guarantee that any pop-up windows can 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 a mouse click or in the event handler function of a key event).
With ActionScript, you can perform the following actions on an HTML page:
Call any JavaScript function.
Pass any number of arguments with any name.
Passes various data types (Boolean, number, String, and so on).
Receives the return value from a JavaScript function.
By using JavaScript on an HTML page, you can:
Call the ActionScript function.
Use standard function call notation to pass parameters.
Returns a value to a JavaScript function.
Flash Player does not currently support SWF files that are embedded in an HTML form.
Note: In Adobe AIR, the Externalinterface class can be used to communicate between the JavaScript of the HTML page loaded in the Htmlloader control and the ActionScript that is embedded in the SWF content of the HTML page.
Use this class in our Mxml file. To get the IP and Pcname functions in the call JS:
Pcname = Externalinterface.call ("Getclientpcname");
ip = Externalinterface.call ("Getclientip");
You can try alert and see if it's right. There is also a problem, to join your machine as a server, then on the server to get the IP will be: 127.0.0.1, handle it I'm sure you'll find a way.