Guest User

Untitled

a guest
Jan 20th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <s:HTTPService id="weatherService"
  2. url="{BASE_URL}"
  3. resultFormat="object"
  4. result="weatherService_resultHandler(event)"
  5. fault="weatherService_faultHandler(event)"
  6. showBusyCursor="true">
  7. <s:request xmlns="">
  8. <q>{cityName.text.toString()}</q>
  9. <format>{FORMAT}</format>
  10. <num_of_days>{NUMBER_OF_DAYS}</num_of_days>
  11. <key>{API_KEY}</key>
  12. </s:request>
  13. </s:HTTPService>
  14.  
  15. import mx.rpc.http.HTTPService;
  16.  
  17. private function callService():void
  18. {
  19. var requestObj:Object = {};
  20. requestObj.q = cityName.text.toString();
  21. requestObj.format = FORMAT;
  22. requestObj.num_of_days = cNUMBER_OF_DAYS;
  23. requestObj.key = API_KEY;
  24.  
  25. var weatherService:HTTPService = new HTTPService();
  26. weatherService.url = BASE_URL;
  27. weatherService.resultFormat = "object";
  28. weatherService.showBusyCursor = true;
  29. weatherService.request = requestObj;
  30. weatherService.addEventListener(ResultEvent.RESULT , weatherService_resultHandler);
  31. weatherService.addEventListener(FaultEvent.FAULT, weatherService_faultHandler);
  32. weatherService.send();
  33. }
  34.  
  35. protected function weatherService_resultHandler(event:ResultEvent):void
  36. {
  37. trace("got result");
  38. }
  39.  
  40. protected function weatherService_faultHandler(event:FaultEvent):void
  41. {
  42. trace("got fault");
  43. }
Add Comment
Please, Sign In to add comment