Relax Breath of Solution.Community tech blog of Sameera Thilakasiri - Consultant UI, UX, RWD Specialist/ Interactive Designer

Just I wanted.. Do you?…

Provide a Better Visual Feedback – Using Flex CursorManager.setBusyCursor()

Posted on February 25, 2010 | No Comments

Why do you need Flex CursorManager

Flex is all about User Experience. A Rich Internet Application (RIA) is not just attractive skins or fancy animations. It also means interacting with users and helping them use your application better.

One important part of User Experience is to provide a better visual feedback. For example, when someone types a model name and clicks Search button, it might take 2-3 seconds to get results from a web service. What would a user do during that time? He or she probably keeps clicking the Search button, or thinks your application is dead.

So how to let users know what is going on with your application? You need how do i buy viagra online | buy cialis canadian | cheap levitra generic to give them some visual feedback: like show the busy cursor when waiting for the back end response, and then remove the busy cursor when the data is ready.

To control the cursor image in Flex, you need CursorManager.

How to use CursorManager

Here is how you typically use CursorManager in Flex:

– Display the default busy cursor
CursorManager.setBusyCursor();

– Remove the busy cursor
CursorManager.removeBusyCursor();

– Create a new Cursor from your own cursor class
[Bindable]
[Embed(source=”assets/heart.gif”)]
private var HeartCursor:Class;
var cursorID:int = CursorManager.setCursor(HeartCursor);

– Removes a cursor from the cursor list
CursorManager.removeCursor(cursorID);

– Remove all cursors
CursorManager.removeAllCursors();

Sample Code

    <?xml version="1.0"   encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
          layout="absolute">

        <mx:Script>
          <![CDATA[
             import mx.managers.CursorManager;

             private var   cursorId:int;

             [Bindable]
             [Embed(source="assets/heart.gif")]
          <a href="http://marvabrooks.com/images/">buy levitra online</a>         private var HeartCursor:Class;

             private function showBusyCursor():void {
               CursorManager.setBusyCursor();
             }

             private function removeBusyCursor():void {
               CursorManager.removeBusyCursor();
             }              

             private function showHeartCursor():void {
               cursorId =   CursorManager.setCursor(HeartCursor);
             }

             private function removeHeartCursor():void {
               CursorManager.removeCursor(cursorId);
             }
         ]]&gt;
          &lt;/mx:Script&gt;

          &lt;mx:Panel     title=&quot;Flex Tutorial - Cursor Manager&quot;
            width=&quot;500&quot;   height=&quot;200&quot;
            horizontalCenter=&quot;0&quot; verticalCenter=&quot;0&quot; verticalGap=&quot;20&quot;
                horizontalAlign=&quot;center&quot;     verticalAlign=&quot;middle&quot;&gt;

            &lt;mx:HBox&gt;
              &lt;mx:Button label=&quot;Show Busy Cursor&quot;
                           click=&quot;showBusyCursor()&quot;/&gt;
              &lt;mx:Button     label=&quot;Remove Busy Cursor&quot;
                             click=&quot;removeBusyCursor()&quot;/&gt;
            &lt;/mx:HBox&gt;

            &lt;mx:HRule width=&quot;95%&quot;/&gt;

              &lt;mx:HBox&gt;
              &lt;mx:Button   label=&quot;Show Heart Cursor&quot;
                         click=&quot;showHeartCursor()&quot;/&gt;
                &lt;mx:Button   label=&quot;Remove     Heart Cursor&quot;
                           click=&quot;removeHeartCursor()&quot;/&gt;
            &lt;/mx:HBox&gt;
       &lt;/mx:Panel&gt;

      &lt;/mx:Application&gt;

Conclusion

CursorManager offers a convienent way for you to control cursor display in Flex. By using it properly, you will provide a better visual feedback to users, thus enhance the user experience of your applicaton.


Author
Sameera Thilakasiri By Sameera Thilakasiri
,is a front-end developer based in Colombo, is a blogger and a lifestyle photographer.
Follow him Twitter and Google+. Check out him.

Comments

Leave a Reply

You must be logged in to post a comment.