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項目從一列項目移動到它自己的列