showBusyCursor for HTTPService object in Flex3.2


Flex 3 has this HTTPService class for firing up HTTP requests from your application, and 7 types of service requests GET , POST , HEAD , OPTIONS , PUT , TRACE and DELETE are supported. Interestingly, Flex has two versions of this HTTPService class. Thats right, there are two classes with the same name – only they exist in two different packages  – one lives in mx.rpc.http and the other in mx.rpc.http.mxml. Each one has a specific use. The HTTPService class in mx.rpc.http is to be used in the ActionScript files in your application and the HTTPService class in mx.rpc.http.mxml is to be used in mxml files as a <mx:HTTPService> tag. Both of these classes are nearly identical, but they do have differences. Most notable difference that I have found is that the class in the mxml package has a boolean variable showBusyCursor that can be set to true or false. And the other HTTPService class (the one to be used in ActionScript) doesn’t. And why this variable is not present in this class is truly a mystery to me, because even if I triggered a HTTPService from ActionScript, I would definitely like to show the busy cursor to my user just to tell him that the application is working at something.

So the work around for the scenario where you are using the mx.rpc.http.HTTPService(the ActionScript one) is that you manually turn on the busy cursor and turn it off when you response is received.  That is done this way –

Use this in the import section

import mx.managers.CursorManager;

and the following line before using the ‘send’ method of the HTTPService class –

CursorManager.setBusyCursor();

and the following line when you want the busy cursor turned off –

CursorManager.removeBusyCursor();

I found this solution in this URL – http://tech.groups.yahoo.com/group/flexcoders/message/98038

One thing that I found out for myself is that this case is specific to Flex3.2. In Flex3.4 they have added the showBusyCursor boolean variable to the ActionScript version of the class as well. See here  – http://www.adobe.com/livedocs/flex/3/langref/mx/rpc/http/HTTPService.html#showBusyCursor

If you have observed any other difference between these two classes in Flex3.2 pls do feel free to share it over here.

Advertisements

About vatsalad

Hi, I'm Vatsala
This entry was posted in Adobe Flex and tagged , , , , . Bookmark the permalink.

One Response to showBusyCursor for HTTPService object in Flex3.2

  1. Aswath says:

    Good one……:)

Comments are closed.