tags:

views:

117

answers:

3

I am having trouble displaying a custom cursor in the full screen mode of my flex application. How can I do this?

A: 

Hi Amarghosh,

I am having the same problem. I used the following code

[Embed(source="Asset/CustomCursor.png")]

private var CustomCursorSymbol:Class;  

var removalID:int = cursorManager.setCursor(CustomCursorSymbol);

to store what was set as the custom cursor. Then to remove it, I used the following code,

cursorManager.removeCursor(removalID);

It works fine in normal screen mode. But in full screen. The cursor disappears after some time. Then there remains neither the custom cursor nor the original white pointer cursor of windows on the screen.

Kindly help me doing this right. I want to use a cursor in the full screen mode of my flex application.

Thanks

Alex Fisherr
A: 

CursorManager.removeCursor() method removes a cursor from the cursor list.

If the cursor being removed is the currently displayed cursor, the CursorManager displays the next cursor in the list, if one exists. If the list becomes empty, the CursorManager displays the default system cursor.

I can't find a way to add a removed cursor back to the cursor list other than calling the setCursor again. The following code works in normal as well as full screen mode. There's got to be a better way, because the customID is incremented in each call - but at least it works fine.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" 
    xmlns:local="*" >
    <mx:Button label="Custom" click="onCustomClick();"/>
    <mx:Button label="Default" click="onDefaultClick();"/>
    <mx:Button label="Go Fullscreen" 
        click="stage.displayState = StageDisplayState.FULL_SCREEN;"/>
    <mx:Script>
     <![CDATA[
      import mx.managers.CursorManager;

      [Embed(source="cursor.png")]
      public var CursorPNG:Class;

      private var customID:int;

      private function onCustomClick():void
      {
       customID = CursorManager.setCursor(CursorPNG);
      }
      private function onDefaultClick():void
      {
       CursorManager.removeCursor(customID);
      }

     ]]>
    </mx:Script>
</mx:Application>
Amarghosh
A: 

Dear Amargosh,

I am using the same method you are talking about. I am calling the method which changes the cursor on the RollOver event of mouse on a Canvas. Then I call the restore cursor method on RollOut event which removes the previously assigned cursor and shows the system's default one. It all works fine in normal mode. Custom cursor appears and disappears on roll over and out of the Canvas. But when I switch the canvas to full screen mode, the custom cursor only appears only for a moment or so. And then it disappears. No cursor on the screen. If you move out of the Canvas, the system's default cursor is only visible then.

Alex Fisherr
Instead of posting new answers, use the `add comment` button for comments.
Amarghosh
Ask a new question and add the relevant code in it.
Amarghosh