Creating and removing a cursor in Flash Builder4


To use the Cursor Manager, you import the mx.managers.CursorManager class into your application, and then reference its static properties and methods.
The Cursor Manager controls a prioritized list of cursors, where the cursor with the highest priority is currently visible. If the cursor list contains more than one cursor with the same priority, the Cursor Manager displays the most recently created cursor.

You create a new cursor, and set an optional priority for the cursor, by using the static setCursor() method of the CursorManager class. This method adds the new cursor to the cursor list. If the new cursor has the highest priority, it is displayed immediately. If the priority is lower than a cursor already in the list, it is not displayed until the cursor with the higher priority is removed.

To remove a cursor from the list, you use the static removeCursor() method. If the cursor is the currently displayed cursor, the Cursor Manager displays the next cursor in the list, if one exists. If the list ever becomes empty, the Cursor Manager displays the default system cursor.

<?xml version=”1.0″?>
<!– cursors\CursorManagerApp.mxml –>
<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009&#8243;
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/halo”>
<fx:Script>
<![CDATA[
import mx.managers.CursorManager;
import flash.events.*;
// Define a variable to hold the cursor ID.
private var cursorID:Number = 0;
// Embed the cursor symbol.
[Embed(source=”assets/1.png”)]
private var waitCursorSymbol:Class;
// Define event listener to display the wait cursor
// and to load the image.
private function initImage(event:MouseEvent):void {
// Set busy cursor.
cursorID = CursorManager.setCursor(waitCursorSymbol);
// Load large image.
image1.load(“assets/untitled.JPG”);
}
// Define an event listener to remove the wait cursor.
private function loadComplete(event:Event):void {
CursorManager.removeCursor(cursorID);
}
]]>
</fx:Script>
<mx:VBox>
<!– Image control to load the image. –>
<mx:Image id=”image1″
height=”50″
width=”100″
scaleContent=”true”
complete=”loadComplete(event);”/>
<!– Button triggers the load. –>
<mx:Button id=”myButton” label=”Show” click=”initImage(event);”/>
</mx:VBox>
</s:Application>

Advertisements

~ by mjcprasad2000 on July 8, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: