I realized after re-reading my last post on basic Events in Actionscript 3 , I forgot something important.
In Actionscript 2, the moment you added a mouse event handler like onRelease or OnRollOver, you got the hand cursor, indicating a clickable item.
In Actionscript 3 the hand cursor does not automatically appear when you add a mouse event handler to a movieclip. This will come in handy when you do not want to have your users think of the symbol or MovieClip as being a hyperlink. For example, a dragable item should not look like a hyperlink or a button. Short of changing the appearance of the cursor yourself, you can just leave it as an arrow.
Here's how to add the hand cursor back in.
If you remember how we left our previous code...
If you want to make your pointer into a hand cursor, just add this code before the first line.
You can place this under the first line or at the end of the code, but good practice would dictate placing it at the top.
Our code should now look like this... and we should see that beautiful hand cursor again.
--Rich
In Actionscript 2, the moment you added a mouse event handler like onRelease or OnRollOver, you got the hand cursor, indicating a clickable item.
In Actionscript 3 the hand cursor does not automatically appear when you add a mouse event handler to a movieclip. This will come in handy when you do not want to have your users think of the symbol or MovieClip as being a hyperlink. For example, a dragable item should not look like a hyperlink or a button. Short of changing the appearance of the cursor yourself, you can just leave it as an arrow.
Here's how to add the hand cursor back in.
If you remember how we left our previous code...
myClip_mc.addEventListener(MouseEvent.CLICK, doOnClick);
function doOnClick(e:MouseEvent):void
{
trace(e.currentTarget.name);
}
If you want to make your pointer into a hand cursor, just add this code before the first line.
myClip_mc.buttonMode = true;
You can place this under the first line or at the end of the code, but good practice would dictate placing it at the top.
Our code should now look like this... and we should see that beautiful hand cursor again.
myClip_mc.buttonMode = true;
myClip_mc.addEventListener(MouseEvent.CLICK, doOnClick);
function doOnClick(e:MouseEvent):void
{
trace(e.currentTarget.name);
}
In my next entry I'll show how to link this to a web page.--Rich
No comments:
Post a Comment