Papervision (the awesome 3D engine for ActionScript 3) is limited when it comes to standard flash interactivity. Specifically something called buttonMode. When you put buttonMode = true on a 2D sprite in flash, it puts a nice cursor over your sprite, hence making it look like a button or a link.
We use Pv3d’s MovieMaterial to texture most of our interactive 3D elements. The MovieMaterial is usually made from a sprite with children that could contain links. Pv3d doesn’t render a cursor when you hover over it, but does allow event listeners when you set interactive = true on the MovieMaterial. This gives us room for applying some unconventional methods to give us a nice pointer cursor when moving the mouse over the buttons.
My first idea was to dispatch an event and have my controller class listen and then change the mouse cursor to be an image of a mouse pointer. This ended up really clunky, especially when I have heavy 3D that slows down the frame rate. So the Faux mouse cursor moved very slowly and I axed the idea.
Then I came up with an idea that actually works very smoothly. Instead of loading in a fake cursor that replaces the mouse, I wrote a 2D sprite class that follows the mouse when the mouse hovers over the interactive sprites in 3D. This sprite would then have buttonMode = true so the mouse turns to a pointer. After that I set the sprite’s alpha to 0 so the user sees nothing happening except for their mouse cursor changing. When the user clicks, it hides the sprite so the mouse event inside the 3D material is still active. Just be sure to make your links in 3D on MOUSE_UP instead of MOUSE_CLICK
_contentLink.addEventListener(MouseEvent.MOUSE_UP, onContentLinkClick);
Download the Cursors.as class
Usage:
private function onSpriteLinkOver(e:MouseEvent):void{
_cursors.start();
}
private function onSpriteLinkOut(e:MouseEvent):void{
_cursors.stop();
}
Awesome man. This helps! I’m using your Cursors class. Thanks for this tip!
I’d try to comment but I fell off the wagon at “Papervision…” I definately don’t know design software…
@ Rebekah:
Papervision isn’t design software. It’s an Actionscript class library that provides a 3D engine for Flash.