search
HomeWeb Front-endJS TutorialFlex 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:

Copy the code The 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.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
常用的Flex布局属性有哪些常用的Flex布局属性有哪些Feb 25, 2024 am 10:42 AM

flex布局的常用属性有哪些,需要具体代码示例Flex布局是一种用于设计响应式网页布局的强大工具。它通过使用一组灵活的属性,可以轻松控制网页中元素的排列方式和尺寸。在本文中,我将介绍Flex布局的常用属性,并提供具体的代码示例。display:设置元素的显示方式为Flex。.container{display:flex;}flex-directi

手把手带你使用CSS Flex和Grid布局实现3D骰子(附代码)手把手带你使用CSS Flex和Grid布局实现3D骰子(附代码)Sep 23, 2022 am 09:58 AM

在前端面试中,经常会问到如何使用 CSS 实现骰子/麻将布局。下面本篇文章给大家介绍一下用CSS 创建一个 3D 骰子(Flex和Grid布局实现3D骰子)的方法,希望对大家有所帮助!

一文详解三个 flex 属性对元素的影响一文详解三个 flex 属性对元素的影响Aug 30, 2022 pm 07:50 PM

在开发的时候经常用 flex 这个属性作用于弹性盒子的子元素,例如:flex:1或者flex: 1 1 auto,那么这个属性到底控制了元素怎么的行为呢?flex:1又究竟是什么含义呢?让这篇文章带你彻底了解 flex 属性吧!

带你吃透Flex布局的三个属性:flex-grow、flex-shrink、flex-basis带你吃透Flex布局的三个属性:flex-grow、flex-shrink、flex-basisDec 06, 2022 pm 08:37 PM

本篇文章带大家深入了解CSS Flex布局的三个属性:flex-grow、flex-shrink、flex-basis,希望对大家有所帮助!

无法识别计算机名称进行网络共享无法识别计算机名称进行网络共享Dec 26, 2023 am 09:59 AM

win10系统是一款被大多数用户们所选择的优秀系统!强大的工作能力是win10系统最引人注目的标签!基本上大多数涉及电脑来进行的工作普遍都是使用win10系统,最近有很多的小伙伴们都在反应在使用电脑的时候网络共享找不到计算机名字,今天小编就为大家带来了网络共享找不到对方电脑的解决办法让我们一起来看一下吧。网络共享找不到计算机名字的解决办法:操作步骤:1、右键点击电脑桌面最右下角的网络连接图标。2、点击左上角‘更改高级共享设置’。进入到共享设置页面。3、有很多人往往没有开启网络发现而搜不到共享电脑

详解Css Flex 弹性布局中的网格间距与边框处理方法详解Css Flex 弹性布局中的网格间距与边框处理方法Sep 26, 2023 am 10:31 AM

标题:详解CSSFlex弹性布局中的网格间距与边框处理方法引言:CSSFlex弹性布局是一种现代的页面布局方式,可以使网页在不同的屏幕尺寸下自动适应,并且具有灵活性和响应性。在使用CSSFlex弹性布局时,我们经常会遇到需要设置网格间距和边框的情况。本文将详细介绍CSSFlex弹性布局中的网格间距与边框处理方法,并提供具体的代码示例。一、网格间距的处

一文详解CSS3中的Flex布局一文详解CSS3中的Flex布局Nov 01, 2022 pm 07:29 PM

本篇文章带大家了解一下CSS3中的Flex布局,希望对大家有所帮助!

如何通过Css Flex 弹性布局实现滑动菜单效果如何通过Css Flex 弹性布局实现滑动菜单效果Sep 26, 2023 pm 02:13 PM

如何通过CSSFlex弹性布局实现滑动菜单效果在网页设计中,滑动菜单是一种常见的交互效果,它可以让网页更加流畅和美观。本文将教你使用CSSFlex弹性布局来实现这一效果,并提供具体的代码示例。CSSFlex是一种新的布局方式,可以方便地实现各种复杂的布局效果。它通过设置容器和子元素的属性来控制布局,其中flex属性是最重要的属性之一。首先,我们需要一个

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools