Set busy Cursor using the CursorManager
Line Break
Author: Roelof (11 Articles) - Author Website
Roelof is a SAP Consultant specialized in Front-End development. In his spare free time he is either developing on the web, playing basketball, watching soccer, travelling or just being lazy. He is also the co-owner of Flex-Blog.com.
There are multiple ways to show that your Flex Application is busy, one of the nicest is showing the busy cursor. This is very easy within Flex since you can use the CursorManager component.
The only source code you need is:
1 | CursorManager.setBusyCursor(); |
This is a static method of the CursorManager component. It is also possible to create a custom Cursor, this will be the subject of our next example.
In the following example we used a toggle button to switch between a busy cursor and a normal cursor:
You can look at the source code using the right mouse click -> view source or scroll down this page:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="160" viewSourceURL="srcview/index.html"> <fx:Script> <![CDATA[ import mx.controls.Button; import mx.managers.CursorManager; import flash.events.*; private function toggleButtonHandler(event:MouseEvent):void { var toggleButton:Button = event.target as Button; if ( toggleButton.selected ) { CursorManager.setBusyCursor(); } else { CursorManager.removeBusyCursor(); } } ]]> </fx:Script> <mx:Panel paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" horizontalAlign="center" verticalAlign="middle" title="Busy Cursor Example" > <mx:Button label="Toggle" toggle="true" click="toggleButtonHandler(event);" /> <mx:Text text="Click the button to display or hide the busy cursor."/> </mx:Panel> </s:Application> |
Related posts:
Comments
One Response to “Set busy Cursor using the CursorManager”



[...] my previous post about setting the busy cursor, I decided to write a next post about custom Cursors. In our example we use an Image as a Cursor [...]