Recently, i need to use a loaded swf as MovieMaterial. But i found that the simple button which i place on the timeline not working correctlly. So, i dig in the papervision code and found out why it is not working. In result, i found papervision will ignore the simple button since it is not interact with normal Mouse Event. Here is come gather a hack to deal with the simplebutton on moviematerial. Here is the hack
Edit the file VirtualMouse.as in org.papervision3d.core.utils.virtualmouse.
Find the place which ignore the SimpleButton
// invalid target if in a SimpleButton if (currentTarget && currentParent is SimpleButton) { //log.debug("found SimpleButton - setting currentTarget to null"); currentTarget = null;
change to
// invalid target if in a SimpleButton if (currentTarget && currentParent is SimpleButton) { //log.debug("found SimpleButton - setting currentTarget to null"); currentTarget = currentParent as InteractiveObject;
Hack to change the state of SimpleButton
1. Find the function
private function handleUpdate(event:Event):void
2. Add a var which hold the skin of the simpleButton.
var simpleButtonSkin:DisplayObject;
3. Add code here to swap the skin of SimpleButton upState and overState
// off of last target
if (!disabledEvents[MouseEvent.MOUSE_OUT]) {
if ( target is SimpleButton) {
simpleButtonSkin = (target as SimpleButton).overState;
(target as SimpleButton).overState = (target as SimpleButton).upState;
(target as SimpleButton).upState = swapSkin;
}
……..
// on to current target
if (!disabledEvents[MouseEvent.MOUSE_OVER]) {
if ( currentTarget is SimpleButton) {
simpleButtonSkin = (currentTarget as SimpleButton).upState;
(currentTarget as SimpleButton).upState = (currentTarget as SimpleButton).overState;
(currentTarget as SimpleButton).overState = swapSkin2;
}
……
if (!disabledEvents[MouseEvent.MOUSE_DOWN]) {
if ( currentTarget is SimpleButton) {
simpleButtonSkin = (currentTarget as SimpleButton).upState;
(currentTarget as SimpleButton).upState = (currentTarget as SimpleButton).downState;
(currentTarget as SimpleButton).downState = swapSkin3;
}
……
if (!disabledEvents[MouseEvent.MOUSE_UP]) {
if ( currentTarget is SimpleButton) {
simpleButtonSkin = (currentTarget as SimpleButton).upState;
(currentTarget as SimpleButton).upState = (currentTarget as SimpleButton).downState;
(currentTarget as SimpleButton).downState = swapSkin4;
}
…….
Here is the patched virtualmouse.as. Replace file in org.papervision3d.core.utils.virtualmouse.
Download virtualmouse.as