Setting mouse cursors in Flash Player 10

by Peter deHaan on November 3, 2008

in ActionScript, Mouse, MouseCursor

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.

{ 6 comments… read them below or add one }

1 matthew November 4, 2008 at 7:00 am

thank u r information

it very useful

u r blog Is very nice

Reply

2 jidolstar November 4, 2008 at 9:22 am

thank!

Reply

3 Dale Fraser November 4, 2008 at 9:44 am

Missing the demo again :(

Reply

4 Lekkie November 4, 2008 at 12:19 pm

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

Reply

5 Nikos November 19, 2009 at 6:32 am

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

Reply

6 Nick January 8, 2010 at 11:39 am

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.

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can 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

Previous post:

Next post: