1
A
回答
1
功能:
/* Function to make a generic HTTP Request
* loc = location e.g. http://www.google.com
* req = request
* type = content type
* complete = function to execute when HTTP req returns with complete
*/
public function httpReq(loc:String , req:String, type:String, complete:Function):void{
/* Start the HTTP Request */
try{
requestSender= new URLLoader();
requestSender.addEventListener(Event.COMPLETE, complete);
requestSender.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, printResponse);
var urlRequest :URLRequest = new URLRequest(loc);
/* Setup HTTP Request */
urlRequest.data = req;
urlRequest.contentType = type;
urlRequest.method = URLRequestMethod.GET;
requestSender.load(urlRequest); // Send the request off, when complete jump to completeHandler
}
catch(e:Error){
trace(e.message);
trace(e.getStackTrace());
}
}
得到响应:
/* HTTP Request complete, back with response */
private function responseHandler(event:Event):void
{
this.requestSender = URLLoader(event.target); // Set requestSender as response
this.output.text = this.requestSender.data; // Get its data
trace("THE DATA IS "+this.requestSender.data);
this.requestSender.close();
alert.cancel();
}
调用示例:
httpReq("http://www.google.com" , "requestString", "application/x-www-form-urlencoded", responseHandler);
0
相关问题
- 1. 移动到CollectionViewSource中的特定项目?
- 2. Flex移动项目选项
- 3. Flex移动项目:Alert.show
- 4. Android:活动建立网络连接
- 5. 从域名重定向到Django项目的特定网址
- 6. 建立自定义网址验证器 - 如何从“已移动”网址响应中抓取新网址?
- 7. 滚动到特定项目
- 8. Flex桌面库项目无法找到移动皮肤定义
- 9. JavaME Midlet无法建立HTTP连接
- 10. 连接到Android中的特定网络
- 11. 如何创建链接到特定帖子的网址?
- 12. 无法连接到特定位置的特定ftp地址
- 13. 建立通用服务器连接后连接到特定数据库?
- 14. Sitecore全球网址到特定网址
- 15. 春季:从网页切换到移动网页(两个独立的项目)
- 16. 将javascript连接到网址
- 17. 在Flex移动项目中运行Javascript
- 18. 获取建立连接的IP地址到Oracle 11
- 19. .htaccess - 如何将http://重定向到https://用于特定网址
- 20. 无法创建“的连接网址“空”
- 21. 如何创建HTTP连接并检索网站HTML的移动版本?
- 22. Flex 4.6移动sqlite特定数据
- 23. 我如何找到链接到特定长网址的所有短网址?
- 24. 移动设备上的指向特定网址的图标
- 25. howdoi无法建立网络连接howdoi
- 26. 在android中建立互联网连接
- 27. 的.htaccess重定向到子目录的特定网址
- 28. 将图标添加到Flex移动项目中的TabbedMobileApplication
- 29. Flex Builder AS3项目移植
- 30. 将flex项目从一列项目移动到它自己的列