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
Download the Cursors.as class
Usage:
_cursors.start();
}
private function onSpriteLinkOut(e:MouseEvent):void{
_cursors.stop();
}
Can you share a code sample of a basic hello world of a Sprite panel with links and buttons (form elements) inside of a Papervision3d context using your cursor class?
Understanding the PV3D event integration of 2D stuff rendered in 3D is troublesome.
Thanks
Tony
- spam
- offensive
- disagree
- off topic
Like