Flash Gotcha: Giving and Getting the Finger in Flash

No, not like that, though I’ve seen people give Flash the finger far too many times. In our case we want the cursor to change to the finger cursor. This is the same cursor you would get when hovering over a link. By default this is turned off for MovieClips. To enable it, we add this line of Actionscript for the movieclip:

myMovieClip.buttonMode = true;

Simply take your MovieClip’s instance name and set the attribute buttonMode to true. Now when you publish your movie, rolling over the MovieClip changes your cursor.

Here’s where it gets tricky. Let’s say there’s a MovieClip in your library that needs to be used several times to contain text, such as a list of buttons. You set up the MovieClip as a class to re-use, you pull in the XML content to each class using a for loop, and then add it to the stage with buttonMode set to true. Now here comes the pain in the neck. When you hover the mouse over the MovieClip you get the cursor change, but when you move the mouse over the part of the MovieClip with the text, bye-bye cursor change.

This result is due the default behavior of text with the cursor. To disable this behavior, set the textfield inside the MovieClip to this:

myMovieClip.myTextfield.mouseEnabled = false;

Presto! Now your MovieClip behaves like a button, the cursor is not affected by the text, and you don’t have to give Flash the finger.

Leave a Reply