How to find the ip address in as3?

时光毁灭记忆、已成空白 提交于 2019-12-05 14:36:15

No, it is not possible from AS3 without using any server side technology. You can use a loader and load something like http://whatismyip.org/ to get the IP. But without any server (i.e. from pure flash) it is not possible.

Setting Air 2.5 Target output in CS5 is the way of getting ip address.

import flash.net.InterfaceAddress;
import flash.net.NetworkInfo;
import flash.net.NetworkInterface;

function findIPAddress():void
{
    var networkInfo = NetworkInfo.networkInfo;
    var interfaces = networkInfo.findInterfaces();
    var interfaceObj;
    var address;

    //Get available interfaces
    for (var i = 0; i < interfaces.length; i++)
    {
        interfaceObj = interfaces[i];

        for (var j = 0; j < interfaceObj.addresses.length; j++)
        {
            address = interfaceObj.addresses[j];

            trace(address.address + "\n");
        }
    }
}

findIPAddress();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!