2 Replies Latest reply on Mar 27, 2007 3:50 PM by lli123

    How to change a mouse iamge

    lli123 Level 1
      From the current MouseEvent, I cannot find any property can be used to set a icon or a image to the mouse. Anybody can give me a idea?


      Thanks,
      lucy
        • 1. Re: How to change a mouse iamge
          EliteScientist
          look at the CursorManager class
          • 2. Re: How to change a mouse iamge
            lli123 Level 1
            Now my problem is, athought the new mouse image for Cursor is show up,but the original mouse Cursor image still show up. So there are two images are displayed the same time. Here is I copy the code fromthe Flex document, and samething by run this code.

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

            viewSourceURL="src/CursorCustom/index.html"
            width="400" height="160"
            >
            <mx:Script>
            <![CDATA[

            import mx.controls.Button;
            import mx.managers.CursorManager;
            import flash.events.*;

            // Embed the SWF that will be used as
            // the custom cursor.
            [Embed(source="images/hand.gif")]

            public var HourGlassAnimation:Class;

            private const ON_MESSAGE:String = "Custom Cursor ON";
            private const OFF_MESSAGE:String = "Custom Cursor OFF";

            private function busyCursorButtonHandler(event:MouseEvent):void
            {

            var toggleButton:Button = event.target as Button;
            if (toggleButton.selected)
            {

            // The setCursor() method returns a numeric ID for
            // the cursor being set. You can store and use this
            // ID later in a removeCursor() call, or, you can
            // use the static currentCursorID property of the
            // CursorManager class to achieve the same result.

            CursorManager.setCursor(HourGlassAnimation);
            toggleButton.label = ON_MESSAGE;
            }

            else
            {
            CursorManager.removeCursor(CursorManager.currentCursorID);
            toggleButton.label = OFF_MESSAGE;
            }

            }
            ]]>
            </mx:Script>

            <mx:Panel
            paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10"
            horizontalAlign="center" verticalAlign="middle"

            title="Custom cursor"
            >

            <!-- Toggle button turns the custom cursor on and off. -->
            <mx:Button
            label="{OFF_MESSAGE}" toggle="true"
            click="busyCursorButtonHandler(event);"

            />

            <mx:Text text="Click the button to display or hide the custom cursor."/>
            </mx:Panel>
            </mx:Application>


            Anybody has a idea how to control only show one mouse image for the mouse cursor?

            Thanks,
            lucy