# Problem with 3d rotation

**URL:** https://forum.kirupa.com/t/problem-with-3d-rotation/294335
**Category:** flash
**Created:** [August 12, 2009, 4:38pm UTC](https://forum.kirupa.com/t/problem-with-3d-rotation/294335 "2009-08-12T16:38:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alejandroy](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@alejandroy](https://forum.kirupa.com/u/alejandroy)
#### Post date: [August 12, 2009, 4:38pm UTC](https://forum.kirupa.com/t/problem-with-3d-rotation/294335/1 "2009-08-12T16:38:41Z")

</div>

[COLOR=Black][FONT=&quot] [FONT=Arial][SIZE=3]I was wondering if anyone would help me with a tiny problem I’m having. If you look at the test site at [/SIZE][/FONT][/FONT][http://www.designsuccess.com/proof[/COLOR][COLOR=Black][FONT=&quot][FONT=Arial][SIZE=3]](http://www.designsuccess.com/proof%5B/COLOR%5D%5BCOLOR=Black%5D%5BFONT=&quot%5D%5BFONT=Arial%5D%5BSIZE=3%5D) using Mac OS X, you’ll notice that when you change focus from Safari or Firefox to another application, the main rotating menu goes berserk. Since I develop and design on Windows, I had not noticed the problem, but one of my partners uses a Mac and he pointed it out to me. I tried including a MOUSE\_LEAVE event but the problem persists, here’s my code:[/SIZE][/FONT][/FONT][/COLOR][FONT=Arial][SIZE=3][COLOR=Black]  
[/COLOR][/SIZE][/FONT]

```auto
    [FONT=Arial][SIZE=3][COLOR=Black]import gs.TweenMax;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]var ifRotate:Boolean = false;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]stage.addEventListener(MouseEvent.MOUSE_MOVE,init);[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]function init(e:Event) {[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] ifRotate = true;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]}[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]stage.addEventListener(Event.MOUSE_LEAVE,deActivate);[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]function deActivate(e:Event) {[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] ifRotate = false;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]}[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]stage.addEventListener(Event.ENTER_FRAME,loop);[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]this.menu_container.transform.matrix = new Matrix();[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]this.menu_container.z = -500;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]function loop(e:Event) {[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] this.menu_container.x = stage.stageWidth / 2;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] this.menu_container.y = stage.stageHeight / 2;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] this.menu_container.z = 0;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] this.menu_container.y = stage.stageHeight / 2;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] var distx = mouseX / stage.stageWidth;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] var disty = mouseY / stage.stageHeight;[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]var rX = (60-(120*disty));[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] var rY = (-60+(120*distx));[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]if (ifRotate) {[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] TweenMax.to(this.menu_container, .75, {rotationX:rX, rotationY:rY});[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] } else {[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] TweenMax.to(this.menu_container, .75, {rotationX:0, rotationY:0});[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black] }[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]
  [/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]}
[/COLOR][/SIZE][/FONT]

```

[FONT=Arial][SIZE=3][COLOR=Black]  
[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]  
[/COLOR][/SIZE][/FONT] [FONT=Arial][SIZE=3][COLOR=Black]  
[/COLOR][/SIZE][/FONT] [FONT=Arial][SIZE=3][COLOR=Black]It’s really a weird behavior and I checked and rechecked the code but can’t seem to find anything wrong with it. Hope you can help out[/COLOR][/SIZE][/FONT][FONT=Arial][SIZE=3][COLOR=Black]  
[/COLOR][/SIZE][/FONT] [FONT=Arial][SIZE=3][COLOR=Black]  
Cheers[/COLOR][/SIZE][/FONT]
