---
title: "Flex 中取得当前服务IP地址"
author: "shuiyan"
date: "2010-03-10T15:54:47Z"
tags: ["Flex", "JavaScript", "PHP", "Windows", "脚本"]
categories: ["Web前端"]
slug: "flex-ip"
draft: false
lastmod: "2010-03-10T15:54:47Z"
id: 612122
url: "https://shuiyan.iteye.com/blog/612122"
---

var uri:URI = new URI(Application.application.url);  
trace(uri.authority);//IP address of the server which hosts this flex application  
trace(uri.port);  
trace(uri.path);  
var uri:URI = new URI(Application.application.url);  
userService.url = “http://”+uri.authority+”:8080/FileManage/servlet”;  
&lt;mx:HTTPService method=”POST”  id=”userService”&gt;  
**as3corelib里面的类，所以必须要as3corelib这个包，然后**  
**import xx.xx.URI;**

其实要获得本机IP地址, 可以通过调用JavaScript脚本, Windows下读Network对象即可!  
因为JavaScript是本机执行环境, 所有与本机交互都可以通过JavaScript变通执行!

来自：[http://xinsync.xju.edu.cn/index.php/archives/4134](http://xinsync.xju.edu.cn/index.php/archives/4134)