FlexAir获取MAC地址代码

package util{
    import com.hurlant.crypto.rsa.RSAKey;
    import com.hurlant.util.Hex;
                            
    import flash.display.Sprite;
    import flash.net.InterfaceAddress;
    import flash.net.NetworkInfo;
    import flash.net.NetworkInterface;
    import flash.utils.ByteArray;
                            
    public class GetAddress extends Sprite
    {
        public function GetAddressList():void
        {
            var networkInfo:NetworkInfo = NetworkInfo.networkInfo;
            var interfaces:Vector.<NetworkInterface> = networkInfo.findInterfaces();
                                    
            if( interfaces != null )
            {
                trace( "Interface count: " + interfaces.length );
                for each ( var interfaceObj:NetworkInterface in interfaces )
                {
                    trace( "\nname: "             + interfaceObj.name );
                    trace( "display name: "     + interfaceObj.displayName );
                    trace( "mtu: "                 + interfaceObj.mtu );
                    trace( "active?: "             + interfaceObj.active );
                    trace( "parent interface: " + interfaceObj.parent );
                    trace( "hardware address: " + interfaceObj.hardwareAddress );
                    if( interfaceObj.subInterfaces != null )
                    {
                        trace( "# subinterfaces: " + interfaceObj.subInterfaces.length );
                    }
                    trace("# addresses: "     + interfaceObj.addresses.length );
                    for each ( var address:InterfaceAddress in interfaceObj.addresses )
                    {
                        trace( "  type: "           + address.ipVersion );
                        trace( "  address: "         + address.address );
                        trace( "  broadcast: "         + address.broadcast );
                        trace( "  prefix length: "     + address.prefixLength );
                    }
                }         
            }
        }
    }
}

===============控制台内容:===============

name: {97ED7215-4BDF-4FF1-AB5C-73AE76E87C87}
display name: 无线网络连接 2
mtu: 1500
active?: false
parent interface: null
hardware address: 78-92-9C-06-65-E3
# addresses: 2
  type: IPv4
  address: 169.254.250.76
  broadcast: 169.254.255.255
  prefix length: 16
  type: IPv4
  address: 192.168.23.1
  broadcast: 192.168.23.255
  prefix length: 24
name: {C208B292-1BE4-4ADC-9385-C0A40972E216}
display name: 本地连接
mtu: 1500
active?: false
parent interface: null
hardware address: 5C-26-0A-6F-44-26
# addresses: 1
  type: IPv4
  address: 169.254.225.215
  broadcast: 169.254.255.255
  prefix length: 16
name: {D9CEA236-6DEB-4EE6-8646-45C44AC627C9}
display name: 无线网络连接
mtu: 1500
active?: true
parent interface: null
hardware address: 78-92-9C-06-65-E2
# addresses: 1
  type: IPv4
  address: 192.168.2.102
  broadcast: 192.168.2.255
  prefix length: 24
name: {846EE342-7039-11DE-9D20-806E6F6E6963}
display name: Loopback Pseudo-Interface 1
mtu: -1
active?: true
parent interface: null
hardware address:
# addresses: 2
  type: IPv6
  address: ::1
  broadcast:
  prefix length: 128
  type: IPv4
  address: 127.0.0.1
  broadcast:
  prefix length: 8
name: {C4A6309C-ED0C-406D-B4AB-295B9223EA5D}
display name: Teredo Tunneling Pseudo-Interface
mtu: 1280
active?: true
parent interface: null
hardware address: 00-00-00-00-00-00-00-E0
# addresses: 1
  type: IPv6
  address: 2001:0:9d38:6abd:200a:3639:3f57:fd99
  broadcast:
  prefix length: 64


你可能感兴趣的:(mac,Flex,AIR)