标签:dev rtt var length ipc add lis oid pool
package { import flash.display.Sprite; import flash.events.Event; import flash.net.NetworkInfo; import flash.net.NetworkInterface; import flash.net.URLLoader; import flash.net.URLRequest; import flash.system.System; import flash.text.TextField; public class GetMacTest extends Sprite { private var _ipLdr:URLLoader = new URLLoader(); private var _macText:TextField = new TextField();//此网络接口的硬件地址。mac地址 private var _adressText:TextField = new TextField();//Internet 协议 (IP) 地址。 private var _broadcastText:TextField = new TextField();//本地网络段的广播地址。 private var _ipVersionText:TextField = new TextField();//IP 地址类型(IPv4 或 IPv6)。 private var _prefixLengthText:TextField = new TextField();//此地址的前缀长度。 private var _displayNameText:TextField = new TextField();//此网络接口的显示名称。 private var _nameText:TextField = new TextField();//此网络接口的名称 private var _startText:TextField = new TextField();// private var _endText:TextField = new TextField(); private var _countryText:TextField = new TextField();//所在国家 private var _provinceText:TextField = new TextField();//所在省 private var _cityText:TextField = new TextField();//所在市 public function GetMacTest() { if(stage) init(); else addEventListener(Event.ADDED_TO_STAGE,init); } private function init(e:Event=null):void { flash.system.System.useCodePage=true; _macText.autoSize = "left"; _adressText.autoSize = "left"; _broadcastText.autoSize = "left"; _ipVersionText.autoSize = "left"; _prefixLengthText.autoSize = "left"; _displayNameText.autoSize = "left"; _nameText.autoSize = "left"; _startText.autoSize = "left"; _endText.autoSize = "left"; _countryText.autoSize = "left"; _provinceText.autoSize = "left"; _cityText.autoSize = "left"; this.addChild(_macText); this.addChild(_adressText); this.addChild(_broadcastText); this.addChild(_ipVersionText); this.addChild(_prefixLengthText); this.addChild(_displayNameText); this.addChild(_nameText); this.addChild(_startText); this.addChild(_endText); this.addChild(_countryText); this.addChild(_provinceText); this.addChild(_cityText); for(var i:int = 0;i<this.numChildren;i++){ this.getChildAt(i).x = 30; this.getChildAt(i).y = 70+i*20; } _ipLdr.addEventListener(Event.COMPLETE,onIpComplete); getIP(); getInfo(); } private function getIP():void { _ipLdr.load(new URLRequest("http://int.dpool.sina.com.cn/iplookup/iplookup.php")); } private function getInfo():void { var ni:NetworkInfo = NetworkInfo.networkInfo; var nInterfaces:Vector.<NetworkInterface> = ni.findInterfaces();trace(nInterfaces.length); var i:int=0; while (!nInterfaces[i].active || nInterfaces[i].hardwareAddress == "" || nInterfaces[i].hardwareAddress == "00-00-00-00-00-00-00-E0") { i++;trace("i:",i); } for (var j:int = 0; j < nInterfaces.length; j++ ) { trace("j:", j, nInterfaces[j].hardwareAddress); if (nInterfaces[j].active && nInterfaces[j].hardwareAddress != "" && nInterfaces[j].hardwareAddress != "00-00-00-00-00-00-00-E0") { trace("j:", j, nInterfaces[j].hardwareAddress); } } _macText.text = "此网络接口的硬件地址(mac):"+nInterfaces[i].hardwareAddress; _adressText.text = "Internet 协议 (IP) 地址:"+nInterfaces[i].addresses[0].address; _broadcastText.text = "本地网络段的广播地址:"+nInterfaces[i].addresses[0].broadcast; _ipVersionText.text = "IP 地址类型(IPv4 或 IPv6):"+nInterfaces[i].addresses[0].ipVersion; _prefixLengthText.text = "此地址的前缀长度:"+nInterfaces[i].addresses[0].prefixLength; _displayNameText.text = "此网络接口的显示名称:"+nInterfaces[i].displayName; _nameText.text = "此网络接口的名称:"+nInterfaces[i].name; } private function onIpComplete(e:Event):void { trace(e.currentTarget.data as String); if (e.type=="complete") { trace("getIp success"); //var myip:String = (e.currentTarget.data as String).split("\"")[9];trace("myip:",myip);//"http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json" var arr:Array = (e.currentTarget.data as String).split(" "); for(var i:int = 0;i<arr.length;i++){ trace(arr[i]); } _startText.text = "start:"+arr[1]; _endText.text = "end:"+arr[2]; _countryText.text = "county:"+arr[3]; _provinceText.text = "province:"+arr[4]; _cityText.text = "city:"+arr[5]; } else { trace("getIp failed"); } } } }
标签:dev rtt var length ipc add lis oid pool
原文地址:http://www.cnblogs.com/frost-yen/p/7388841.html