-
Like (0)
When I change the rotation of a movie clip, and apply PerspectiveProjection, all mouse events applied to that movie clip and all the movie clips inside that movie clip break.
The mouse event bellow will not work for me.
a_mc.rotationX = 1;
a_mc.rotationY = 1;
a_mc.rotationZ = 1;
//
var perspective:PerspectiveProjection = new PerspectiveProjection();
perspective.fieldOfView = 45;
var point:Point = new Point((a_mc.stage.stageWidth / 2) + 200, -350);
perspective.projectionCenter = point;
a_mc.transform.perspectiveProjection = perspective;
a_mc.addEventListener(MouseEvent.MOUSE_UP, testEvent);
function testEvent (event:MouseEvent):void {
trace("testEvent");
}
But if I remove the rotation code it works:
//a_mc.rotationX = 1;
//a_mc.rotationY = 1;
//a_mc.rotationZ = 1;
//
var perspective:PerspectiveProjection = new PerspectiveProjection();
perspective.fieldOfView = 45;
var point:Point = new Point((a_mc.stage.stageWidth / 2) + 200, -350);
perspective.projectionCenter = point;
a_mc.transform.perspectiveProjection = perspective;
a_mc.addEventListener(MouseEvent.MOUSE_UP, testEvent);
function testEvent (event:MouseEvent):void {
trace("testEvent");
}
And if I remove the perspective code it works:
a_mc.rotationX = 1;
a_mc.rotationY = 1;
a_mc.rotationZ = 1;
a_mc.addEventListener(MouseEvent.MOUSE_UP, testEvent);
function testEvent (event:MouseEvent):void {
trace("testEvent");
}
Is there something I'm doing wrong?
Thanks!
I don't know what the best solution is, but I don't think you're doing anything wrong.
It appears to be related to the PerspectiveProjection....
There are some comments about this in various locations:
http://maohao.wordpress.com/category/flash/ (flex related, but the same issue)
I don't have flash CS4, but was able to get your code running in FlashDevelop....
I followed the examples above and changed the line to
a_mc.parent.transform.perspectiveProjection = perspective;
which got the mouse events working again...although perhaps not in the way you want. Sorry can't suggest anything else....
Actually this seems quite relevant:
Thanks Greg. I changed this line as you recomeneded:
a_mc.parent.transform.perspectiveProjection = perspective;
and that fixed the issue.
So until this bug is fixed, if you want mouse events you need to apply the rotation properties and PerspectiveProjection to different movie clips.
The code below applies the rotation properties to the movie clip. Then applies PerspectiveProjection to the movie clip's parent.
a_mc.rotationX = 1;
a_mc.rotationY = 1;
a_mc.rotationZ = 1;
//
var perspective:PerspectiveProjection = new PerspectiveProjection();
perspective.fieldOfView = 45;
var point:Point = new Point((a_mc.stage.stageWidth / 2) + 200, -350);
perspective.projectionCenter = point;
a_mc.parent.transform.perspectiveProjection = perspective;
a_mc.addEventListener(MouseEvent.MOUSE_UP, testEvent);
function testEvent (event:MouseEvent):void {
trace("testEvent");
}
Copyright © 2011 Adobe Systems Incorporated. All rights reserved.
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-14-2009).