The following example shows how you can set mouse cursors in Flash Player 10 by setting the Mouse object’s cursor property to one of the static constants in the MouseCursor class.

Full code after the jump.

To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see “Using the beta Gumbo SDK in Flex Builder 3″.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/11/03/setting-mouse-cursors-in-flash-player-10/ -->
<FxApplication name="Mouse_cursor_test"
        xmlns="http://ns.adobe.com/mxml/2009">
    <layout>
        <BasicLayout />
    </layout>

    <HGroup horizontalCenter="0" top="10">
        <FxButton label="{MouseCursor.ARROW}"
                click="Mouse.cursor = MouseCursor.ARROW;" />
        <FxButton label="{MouseCursor.AUTO}"
                click="Mouse.cursor = MouseCursor.AUTO;" />
        <FxButton label="{MouseCursor.BUTTON}"
                click="Mouse.cursor = MouseCursor.BUTTON;" />
        <FxButton label="{MouseCursor.HAND}"
                click="Mouse.cursor = MouseCursor.HAND;" />
        <FxButton label="{MouseCursor.IBEAM}"
                click="Mouse.cursor = MouseCursor.IBEAM;" />
    </HGroup>

    <VGroup horizontalCenter="0" verticalCenter="0">
        <TextInput text="mx:TextInput" />
        <Button label="mx:Button" buttonMode="true" />
    </VGroup>

</FxApplication>

View source is enabled in the following example.

This entry is based on a beta version of the Flex Gumbo SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Gumbo SDK.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

7 Responses to Setting mouse cursors in Flash Player 10

  1. matthew says:

    thank u r information

    it very useful

    u r blog Is very nice

  2. Dale Fraser says:

    Missing the demo again :(

  3. Lekkie says:

    Call a java class from Flex (d class is residing on the local machine not remotely)

  4. Nikos says:

    Can you have a swf as a cursor for a mouse?or a spark component

  5. Nick says:

    Thank you so much! This had bugged me for a while, as the cursor seems to like to get stuck in the IBeam display from time to time. Now I can manually change it.

  6. Rashmi Raman says:

    The examples on your blog are such a valuable resource! I wouldn’t be exaggerating if I said that I learnt Flash Builder using these code snippets! Thank you so much!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree