


Flex example code to obtain client IP and computer name through JS_javascript skills
First of all, let me explain that using JS to obtain data does not mean calling webservices and httpservices.
In each of our FLex web projects, there is a folder bin-debug, which contains an index.html file. My personal understanding is this. First, when the web page is run, the mxml file will be compiled. For swf, how to display swf in the browser is through this html file, which is equivalent to embedding a swf object component in the html file. www.jb51.net
Therefore, I personally think it is feasible to write js code in this html to obtain the IP address. Hence the following code.
Add script tag in index.html, the actual code is as follows:
The code equivalent to the background for obtaining IP and pcname is now written.
How to call it in flex, then use this class of Flex: flash.external.ExternalInterface.
For the ExternalInterface class, Adobe explains it this way:
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 containing JavaScript. Adobe recommends using ExternalInterface for all communication between JavaScript and ActionScript.
In Flash Player, you can use JavaScript in an HTML page to call ActionScript functions. ActionScript functions can return a value that JavaScript immediately receives as the return value of the call.
This function replaces the fscommand() method.
The ExternalInterface class is available in the following browser and operating system combinations:
Browser Operating System Operating System
Internet Explorer 5.0 and above Windows
Netscape 8.0 and above Windows MacOS
Mozilla 1.7.5 and above Windows MacOS
Firefox 1.0 and Later Windows MacOS
Safari 1.3 and later MacOS
Flash Player 9.0.31.0 and later for Linux The ExternalInterface class is supported in the following browsers:
Browser
Mozilla 1.7.x and higher
Firefox 1.5.0.7 and higher
SeaMonkey 1.0.5 and higher
ExternalInterface class requires the user's web browser to support ActiveX® or the NPRuntime API exposed by some browsers for plug-in scripting. Even browser and operating system combinations not listed above should support the ExternalInterface class if they support the NPRuntime API.
Note: When embedding a SWF file into an HTML page, make sure to set the id attribute and that the id and name attributes of the object and embed tags do not contain the following characters:
. - * / /
Note: Flash Player version 9.0.115.0 and later allows the . (period) character in the id and name attributes.
Programmatically opening a pop-up window using this class may not succeed in Flash Player 10 and later running in a browser. 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 type of open popup window only in code that executes as a direct result of user action (for example, in an event handler for a mouse click or keypress event).
Using ActionScript, you can perform the following actions on HTML pages:
Call any JavaScript function.
Pass any number of arguments with any names.
Pass various data types (Boolean, Number, String, etc.).
Receives the return value from a JavaScript function.
By using JavaScript on HTML pages, you can:
Call an ActionScript function.
Pass parameters using standard function call notation.
Return a value to a JavaScript function.
Flash Player currently does not support SWF files embedded in HTML forms.
Note: In Adobe AIR, the ExternalInterface class can be used to communicate between the JavaScript of an HTML page loaded in an HTMLLoader control and the ActionScript embedded in the SWF content of that HTML page.
Use this class in our mxml file. Call the function to obtain ip and pcname in js:
pcName = ExternalInterface.call("getClientPcName");
ip = ExternalInterface.call("getClientIp");
You can try Alert and see if it works. There is another problem. If you add your machine as a server, the IP obtained on the server will be: 127.0.0.1. I believe you will have a way to deal with it.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



What are the common properties of flex layout? Specific code examples are required. Flex layout is a powerful tool for designing responsive web page layouts. It makes it easy to control the arrangement and size of elements in a web page by using a flexible set of properties. In this article, I will introduce the common properties of Flex layout and provide specific code examples. display: Set the display mode of the element to Flex. .container{display:flex;}flex-directi

In front-end interviews, we are often asked how to implement dice/mahjong layout using CSS. The following article will introduce to you how to use CSS to create a 3D dice (Flex and Grid layout implement 3D dice). I hope it will be helpful to you!

During development, the flex attribute is often used to act on the child elements of the flexible box, such as: flex:1 or flex: 1 1 auto. So how does this attribute control the behavior of the element? What exactly does flex:1 mean? Let this article take you through a thorough understanding of the flex property!

This article will give you an in-depth understanding of the three properties of CSS Flex layout: flex-grow, flex-shrink, and flex-basis. I hope it will be helpful to you!

The win10 system is an excellent system chosen by most users! Powerful work ability is the most eye-catching label of win10 system! Basically, most work involving computers generally uses the win10 system. Recently, many friends have reported that the computer name cannot be found in network sharing when using computers. Today, the editor will bring you the network Let’s take a look at the solution for sharing that the other party’s computer cannot be found. Solution to the problem that the computer name cannot be found in network sharing: Operation steps: 1. Right-click the network connection icon in the lower right corner of the computer desktop. 2. Click ‘Change advanced sharing settings’ in the upper left corner. Enter the sharing settings page. 3. Many people often do not turn on network discovery and cannot find shared computers.

This article will take you through the Flex layout in CSS3, I hope it will be helpful to you!

Title: Detailed explanation of grid spacing and border processing methods in CSSFlex elastic layout Introduction: CSSFlex elastic layout is a modern page layout method that allows web pages to automatically adapt to different screen sizes and is flexible and responsive. When using CSSFlex flexible layout, we often encounter situations where we need to set grid spacing and borders. This article will introduce in detail the grid spacing and border processing methods in CSSFlex flexible layout, and provide specific code examples. 1. Grid spacing

How to achieve the sliding menu effect through CSSFlex elastic layout. In web design, sliding menu is a common interactive effect, which can make the web page more smooth and beautiful. This article will teach you how to use CSSFlex elastic layout to achieve this effect, and provide specific code examples. CSSFlex is a new layout method that can easily achieve various complex layout effects. It controls the layout by setting the properties of the container and child elements, of which the flex property is one of the most important properties. First, we need a
